-
Notifications
You must be signed in to change notification settings - Fork 0
/
capture_thread.h
91 lines (75 loc) · 2.13 KB
/
capture_thread.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifndef CAPTURE_THREAD_H
#define CAPTURE_THREAD_H
#include <QString>
#include <QThread>
#include <QMutex>
#include <string>
#include <opencv2/opencv.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/video/background_segm.hpp>
class capture_thread : public QThread
{
Q_OBJECT;
public:
capture_thread(std::string camName, QMutex *lock);
capture_thread(QString videopath, QMutex *lock);
~capture_thread();
void setRunning(bool);
void startCalcFPS(bool);
bool isFPSCalculating();
void setMirror(bool);
bool isMirror();
void setPause(bool);
enum VideoSavingStatus{
STARTING,
STARTED,
STOPPING,
STOPPED
};
void setVideoSavingStatus(VideoSavingStatus status);
VideoSavingStatus getVideoSavingStatus();
void setMotionDetectingStatus(bool);
void setVideoMode(QString);
void setWebcamMode();
private:
bool generateFrames(cv::VideoCapture &cap, cv::Mat &tmp_frame);
protected:
void run() override;
private:
void calculateFPS(cv::VideoCapture &cap, cv::Mat &tmp_frame);
void startSavingVideo(cv::Mat &firstFrame);
void stopSavingVideo();
void motionDetect(cv::Mat &frame);
signals:
void frameCaptured(cv::Mat *data);
void fgMaskCaptured(cv::Mat *data);
void bgImageCaptured(cv::Mat *data);
void fpsChanged(float fps, int width, int height);
void videoRecordStatus(int status, QString saved_video_name);
void RunComplete(bool);
private:
bool running;
bool fps_calculating;
float fps=0.0;
bool doMirror=false;
bool pause;
std::string camname;
QString videopath;
QMutex *data_lock;
cv::Mat frame;
cv::Mat *blankFrame;
cv::Mat fgMaskToEmit;
cv::Mat bgImageToEmit;
int frame_width, frame_height;
VideoSavingStatus video_saving_status;
QString saved_video_name;
cv::VideoWriter *video_writer;
// motion detecting parameters
bool motion_detecting_status=false;
bool motion_detected=false;
cv::Ptr<cv::BackgroundSubtractorMOG2> segmentor=nullptr;
//open a video mode.
bool webcam_mode;
QString videoFilePath;
};
#endif // CAPTURE_THREAD_H