-
Notifications
You must be signed in to change notification settings - Fork 1
/
runTracker.cpp
74 lines (63 loc) · 2.02 KB
/
runTracker.cpp
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
#include "MultiTracker2.h"
#include "CarInfo.hpp"
//using namespace cardemo;
int main(int argc, char** argv)
{
//string videoFile = "F:/data/³µÁ¾Êäת/2CARS_RLFRLT.avi";
//string videoFile = "e:\\resources\\tank\\cam4\\demo0.avi";
//string videoFile = "e:\\resources\\tank\\20160312\\s1.avi";
//string videoFile = "e:\\resources\\tank\\res.avi";
//string videoFile = "e:\\resources\\tank\\cam4\\99R_LF.avi";
//string videoFile = "e:\\carTrack\\cam4\\2CARS_RLFRLT.avi";
//string videoFile = "e:\\carTrack\\cam4\\RES.avi";
//string videoFile = "e:\\resources\\tank\\20160409\\4c.avi";
string videoFile = "e:\\carTrack\\20160409\\4c.avi";
VideoCapture capture;
capture.open(videoFile);
if (!capture.isOpened())
{
cout << "read video failure" << endl;
}
VideoWriter vw;
//CV_FOURCC('M', 'J', 'P', 'G'),
Mat frame;
capture.read(frame);
//resize(frame, frame, Size(frame.cols / 4, frame.rows / 4));
int ex = static_cast<int>(capture.get(CV_CAP_PROP_FOURCC));
vw.open("res.avi", ex , capture.get(CV_CAP_PROP_FPS),
Size(frame.size().width,frame.size().height*2));
//MultiTracker2 mTracker;
CarTracker::algHandle ip = CarTracker::trackerInit();
int key;
int carNum = 0;
vector<CarTracker::CarAllInfo> *out;
while (capture.read(frame))
{
//std::vector<cv::RotatedRect> res = p->tracker.process(frame,"STC");
//resize(frame, frame, Size(frame.cols / 4, frame.rows / 4));
vector<Mat>frames;
frames.push_back(frame);
key = waitKey(1);
if (key == 27)
break;
else if (key == 32)
waitKey(0);
else if (key == 13)
{
CarTracker::CarBaseInfo cb;
cb.type = to_string(carNum);
cb.ID = to_string(carNum);
if (!CarTracker::registerCar(cb,
frame, Rect(Point(0, 0), Point(frame.cols/4, frame.rows)), ip))
carNum++;
}
//Mat dst = CarTracker::findCar(frames, &out, ip);
CarTracker::findCar(frames, &out, ip);
//std::vector<cv::RotatedRect> res = mTracker.process(frame,"STC");
//std::cout << res.size() << std::endl;
//vw << dst;
}
waitKey(0);
CarTracker::trackerDestroy(ip);
return 0;
}