-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathruntracker.cpp
More file actions
101 lines (77 loc) · 2.09 KB
/
Copy pathruntracker.cpp
File metadata and controls
101 lines (77 loc) · 2.09 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <time.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <vector>
#include "fdssttracker.hpp"
#include <windows.h>
//#include <dirent.h>
using namespace std;
using namespace cv;
std::vector <cv::Mat> imgVec;
int main(int argc, char* argv[]){
if (argc > 5) return -1;
bool HOG = true;
bool FIXEDWINDOW = false;
bool MULTISCALE = true;
bool SILENT = true;
bool LAB = false;
// Create KCFTracker object
FDSSTTracker tracker(HOG, FIXEDWINDOW, MULTISCALE, LAB);
// DSSTTracker tracker;
int count = 1;
cv::Mat processImg;
char name[7];
std::string imgName;
std::string imgPath = "./person19/";
//get init target box params from information file
std::ifstream initInfoFile;
std::string fileName = imgPath + "initInfo.txt";
initInfoFile.open(fileName);
std::string firstLine;
std::getline(initInfoFile, firstLine);
float initX, initY, initWidth, initHegiht;
char ch;
std::istringstream ss(firstLine);
ss >> initX, ss >> ch;
ss >> initY, ss >> ch;
ss >> initWidth, ss >> ch;
ss >> initHegiht, ss >> ch;
cv::Rect initRect = cv::Rect(initX, initY, initWidth, initHegiht);
double duration = 0;
for (;;)
{
auto t_start = clock();
sprintf_s(name, "%06d", count);
std::string imgFinalPath = imgPath + std::string(name) + ".jpg";
processImg = cv::imread(imgFinalPath, IMREAD_GRAYSCALE);
//processImg = cv::imread(imgFinalPath, CV_LOAD_IMAGE_COLOR);
if (processImg.empty())
{
break;
}
cv::Rect showRect;
if (count == 1)
{
tracker.init(initRect, processImg);
showRect = initRect;
}
else{
showRect = tracker.update(processImg);
// printf( "rect (w h): %d %d \n" , showRect.width, showRect.height);
}
auto t_end = clock();
duration += (double)(t_end - t_start) / CLOCKS_PER_SEC;
// cout << "all duration: " << duration << "\n";
cv::rectangle(processImg, showRect, cv::Scalar(0, 255, 0));
cv::imshow("windows", processImg);
cv::waitKey(1);
count++;
}
std::cout << "FPS: " <<count / duration << "\n";
system("pause");
return 0;
}