-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdetector_thread.h
59 lines (43 loc) · 1.17 KB
/
detector_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
#ifndef DETECTOR_THREAD_H
#define DETECTOR_THREAD_H
#include "concurrent_util.h"
#include "dnnfacedetect.h"
#include <atomic>
#include <functional>
#include <mutex>
#include <thread>
#include <type_traits>
extern const char *model_binary;
extern const char *model_configuration;
class detector_thread {
public:
using display_listener_t = std::function<void(const QImage &)>;
enum State { NOT_STARTED, RUNNING, PAUSED, CLOSED };
enum invocation_result {
OK,
ILLEGAL_STATE,
CAMERA_ERROR,
DNN_INITIALIZATION_FAILURE
};
std::atomic<State> state;
detector_thread();
virtual ~detector_thread();
void set_display_listener(display_listener_t);
invocation_result start(int);
void close();
void pause();
void resume();
private:
using result_vector = std::vector<cv::Rect>;
display_listener_t display_listener;
cv::VideoCapture capture;
dnnfacedetect *face_detection = nullptr;
std::mutex update_lock;
std::thread *t = nullptr;
std::thread *detection_worker = nullptr;
cv::Mat frame;
result_vector results;
void loop();
void work();
};
#endif // DETECTOR_THREAD_H