-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShiftTracker.h
More file actions
37 lines (26 loc) · 785 Bytes
/
ShiftTracker.h
File metadata and controls
37 lines (26 loc) · 785 Bytes
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
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/video/tracking.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace cv;
class ShiftTracker {
public:
ShiftTracker() :inited(false){};
void setId(int _id) { id = _id; }
void deactivate() { inited = false; lost = true; }
void init(Mat &image, Point2f start);
void update(Mat &frame);
inline bool isLost() { return lost; }
inline Point2f getScore() { return score; }
inline Point2f getDetCenter() { return Point2f(track_window.x + track_window.width / 2,
track_window.y + track_window.height / 2); }
private:
int id;
TermCriteria term_crit;
Mat mask, roi_hist, hsv_roi, roi;
Mat hsv, dst;
Rect track_window;
bool inited;
bool lost;
Point2f score;
Point2f prev_wnd_center;
};