Blackjack Decision Maker
lccv.hpp
Go to the documentation of this file.
1 /*
2 BSD 3-Clause License
3 
4 
5  Copyright (c) 2021, Q-engineering
6  All rights reserved.
7 
8 
9  Redistribution and use in source and binary forms, with or without
10  modification, are permitted provided that the following conditions are met:
11 
12 
13  1. Redistributions of source code must retain the above copyright notice, this
14  list of conditions and the following disclaimer.
15 
16 
17  2. Redistributions in binary form must reproduce the above copyright notice,
18  this list of conditions and the following disclaimer in the documentation
19  and/or other materials provided with the distribution.
20 
21 
22  3. Neither the name of the copyright holder nor the names of its
23  contributors may be used to endorse or promote products derived from
24  this software without specific prior written permission.
25 
26 
27  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
31  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
35  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 
38 */
39 
40 #ifndef LCCV_HPP
41 #define LCCV_HPP
42 
43 #include <mutex>
44 #include <atomic>
45 #include <pthread.h>
46 #include <opencv2/opencv.hpp>
47 
48 #include "libcamera_app.hpp"
50 
51 namespace lccv {
52 
53 class PiCamera {
54 public:
55  PiCamera();
56  ~PiCamera();
57 
59 
60  //Photo mode
61  bool startPhoto();
62  bool capturePhoto(cv::Mat &frame);
63  bool stopPhoto();
64 
65  //Video mode
66  bool startVideo();
67  bool getVideoFrame(cv::Mat &frame, unsigned int timeout);
68  void stopVideo();
69 
70 protected:
71  void run();
72 protected:
74  void getImage(cv::Mat &frame, CompletedRequestPtr &payload);
75  static void *videoThreadFunc(void *p);
76  pthread_t videothread;
77  unsigned int still_flags;
78  unsigned int vw,vh,vstr;
79  std::atomic<bool> running,frameready;
80  uint8_t *framebuffer;
81  std::mutex mtx;
83 };
84 
85 }
86 #endif
Definition: libcamera_app.hpp:42
Definition: libcamera_app_options.hpp:45
Definition: lccv.hpp:53
bool startPhoto()
Definition: lccv.cpp:91
std::mutex mtx
Definition: lccv.hpp:81
bool capturePhoto(cv::Mat &frame)
Definition: lccv.cpp:108
unsigned int vh
Definition: lccv.hpp:78
unsigned int still_flags
Definition: lccv.hpp:77
~PiCamera()
Definition: lccv.cpp:71
static void * videoThreadFunc(void *p)
Definition: lccv.cpp:203
bool stopPhoto()
Definition: lccv.cpp:98
void getImage(cv::Mat &frame, CompletedRequestPtr &payload)
Definition: lccv.cpp:76
PiCamera()
Definition: lccv.cpp:47
void stopVideo()
Definition: lccv.cpp:158
unsigned int vw
Definition: lccv.hpp:78
LibcameraApp * app
Definition: lccv.hpp:73
Options * options
Definition: lccv.hpp:58
uint8_t * framebuffer
Definition: lccv.hpp:80
pthread_t videothread
Definition: lccv.hpp:76
bool startVideo()
Definition: lccv.cpp:138
std::atomic< bool > running
Definition: lccv.hpp:79
bool getVideoFrame(cv::Mat &frame, unsigned int timeout)
Definition: lccv.cpp:176
unsigned int vstr
Definition: lccv.hpp:78
std::atomic< bool > frameready
Definition: lccv.hpp:79
bool camerastarted
Definition: lccv.hpp:82
std::shared_ptr< CompletedRequest > CompletedRequestPtr
Definition: libcamera_app.hpp:36
Definition: lccv.hpp:51