forked from oylz/DS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NT.h
74 lines (66 loc) · 1.47 KB
/
NT.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
#ifndef _NTH_
#define _NTH_
#include <opencv2/opencv.hpp>
#include <boost/shared_ptr.hpp>
#include "NTN.h"
using namespace cv;
struct DSResult{
cv::Rect rc_;
int oriPos_;
DSResult(){
rc_ = cv::Rect(0, 0, 0, 0);
oriPos_ = -1;
}
};
class TTracker;
typedef boost::shared_ptr<TTracker> TTrackerP;
class FDSSTTracker;
typedef boost::shared_ptr<FDSSTTracker> FDSSTTrackerP;
class NT{
public:
NT();
~NT();
bool Init();
// for framebuffer
std::map<int, DSResult> UpdateAndGet(const cv::Mat &frame,
const std::vector<cv::Rect> &rcs,
int num,
std::vector<cv::Rect> &outRcs,
const std::vector<int> &oriPos=std::vector<int>(0));
private:
void UpdateFDSST(const Mat &frame, std::vector<cv::Rect> &rcs);
NewAndDelete UpdateDS(const cv::Mat &frame,
const std::vector<cv::Rect> &rcs,
int num,
const std::vector<int> &oriPos);
private:
cv::Rect ToOriRect(const cv::Rect &rc){
cv::Rect re;
float x = ((float)rc.x)/scale_;
float y = ((float)rc.y)/scale_;
float w = ((float)rc.width)/scale_;
float h = ((float)rc.height)/scale_;
re.x = x;
re.y = y;
re.width = w;
re.height = h;
return re;
}
cv::Rect ToScaleRect(const cv::Rect &rc){
cv::Rect re;
float x = ((float)rc.x)*scale_;
float y = ((float)rc.y)*scale_;
float w = ((float)rc.width)*scale_;
float h = ((float)rc.height)*scale_;
re.x = x;
re.y = y;
re.width = w;
re.height = h;
return re;
}
private:
TTrackerP tt_;
std::map<int, FDSSTTrackerP> fdssts_;
float scale_ = 0.25;
};
#endif