CCIMXDesktop
 
Loading...
Searching...
No Matches
CameraCapture.h
1#ifndef CAMERACAPTURE_H
2#define CAMERACAPTURE_H
3
4#include <QImage>
5#include <QObject>
6#include <QtClassHelperMacros>
7#include <atomic>
8
10class QThread;
11class QMutex;
12
13namespace cv {
14class VideoCapture;
15}
16
20class CameraCapture : public QObject {
21 Q_OBJECT
22public:
32
33 CameraCapture() = delete;
34
39
45 explicit CameraCapture(const int index, QObject* parent = nullptr);
46
51
57 this->widget = widget;
58 }
59
64 inline void set_capture_delay_time(const int gap_time) {
65 this->msleep_time = gap_time;
66 }
67
72 bool isActivate() const;
73
78 bool start();
79
84 bool close();
85
86signals:
91 void cameraOpened(int index);
92
97 void cameraClosed(int index);
98
104
105private:
106 cv::VideoCapture* videoCaptureHandle { nullptr };
107 int current_index { -1 };
108
109 CameraDisplayWidget* widget { nullptr };
110
111 QMutex* capMutex;
112 std::atomic_bool internal_running_state_holder { false };
113 int msleep_time { 10 };
114
118 void capture_internal();
119};
120
121#endif // CAMERACAPTURE_H
The CameraCapture class handles camera video capturing.
Definition CameraCapture.h:20
bool isActivate() const
Check if the camera is active.
Definition CameraCapture.cpp:22
Q_DISABLE_COPY(CameraCapture)
Q_DISABLE_COPY disables copy constructor and assignment operator.
~CameraCapture()
Destructor.
Definition CameraCapture.cpp:15
void errorOccur(CameraCapture::Error e)
Signal emitted when an error occurs.
void cameraClosed(int index)
Signal emitted when camera is closed.
bool close()
Close the camera capture session.
Definition CameraCapture.cpp:63
void bind_display_widget(CameraDisplayWidget *widget)
Bind a display widget for camera output.
Definition CameraCapture.h:56
Error
Error enum lists possible camera error cases.
Definition CameraCapture.h:26
@ CAMERA_UNEXISTED
Camera does not exist.
@ CAMERA_MULTI_OPENED
Camera already opened.
@ CAMERA_UNOPENED
Camera not opened.
@ CAMERA_UNBIND_DISPLAY
Camera not bound to display widget.
void cameraOpened(int index)
Signal emitted when camera is opened.
void set_capture_delay_time(const int gap_time)
Set capture delay time in milliseconds.
Definition CameraCapture.h:64
bool start()
Start the camera capture session.
Definition CameraCapture.cpp:26
The CameraDisplayWidget class A QWidget-derived class that displays camera frames....
Definition CameraDisplayWidget.h:18