-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathdet_and_track.h
73 lines (60 loc) · 1.69 KB
/
det_and_track.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
#ifndef DET_AND_TRACK_H
#define DET_AND_TRACK_H
class TrackerManager;
#include <opencv2/core/utility.hpp>
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/tracking.hpp>
#include <iostream>
#include <vector>
#include <thread>
#include <mutex>
#include "lk_tracker.h"
#include "object_detection.h"
class DetAndTrack
{
bool get_new_detection_;
bool first_time_detection_;
std::vector<cv::Rect> det_boxes_;
//std::vector<cv::Rect> track_boxes_;
//std::vector<cv::Rect> final_boxes_;
cv::Mat current_frame_;
//cv::Mat last_frame_;
//cv::CascadeClassifier face_cascade_;
ObjectDetection* object_detection_ptr_;
TrackerManager* track_manager_ptr_;
int detection_sleep_time_; //milliseconds
int track_sleep_time_;
public:
std::mutex mutex_;
DetAndTrack();
DetAndTrack(int _detection_sleep_time, int _track_sleep_time);
void detectionTask();
void trackTask();
std::vector<cv::Rect> getBox()
{
if(!first_time_detection_) // means the track_manager_ptr_ is initialized
{
return track_manager_ptr_->getAllBox();
}
else
{
std::vector<cv::Rect> res;
return res;
}
}
std::vector<cv::Scalar> getColor()
{
if(!first_time_detection_)
{
return track_manager_ptr_->getAllColor();
}
else
{
std::vector<cv::Scalar> res;
return res;
}
}
void setFrame(const cv::Mat& _new_frame);
};
#endif