]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/blob - main_vot.cpp
Updated cmake. Now you can enable visualization of results, opecv cufft implementatio...
[hercules2020/kcf.git] / main_vot.cpp
1 #include <stdlib.h>
2
3 #include "kcf.h"
4 #include "vot.hpp"
5
6 int main()
7 {
8     //load region, images and prepare for output
9     VOT vot_io("region.txt", "images.txt", "output.txt");
10
11     KCF_Tracker tracker;
12     cv::Mat image;
13
14     //img = firts frame, initPos = initial position in the first frame
15     cv::Rect init_rect = vot_io.getInitRectangle();
16     vot_io.outputBoundingBox(init_rect);
17     vot_io.getNextImage(image);
18
19     tracker.init(image, init_rect);
20
21     BBox_c bb;
22     double avg_time = 0.;
23     int frames = 0;
24     while (vot_io.getNextImage(image) == 1){
25         double time_profile_counter = cv::getCPUTickCount();
26         tracker.track(image);
27         time_profile_counter = cv::getCPUTickCount() - time_profile_counter;
28          std::cout << "  -> speed : " <<  time_profile_counter/((double)cvGetTickFrequency()*1000) << "ms. per frame" << std::endl;
29         avg_time += time_profile_counter/((double)cvGetTickFrequency()*1000);
30         frames++;
31
32         bb = tracker.getBBox();
33         vot_io.outputBoundingBox(cv::Rect(bb.cx - bb.w/2., bb.cy - bb.h/2., bb.w, bb.h));
34 #ifdef VISULIZE_RESULT
35        cv::rectangle(image, cv::Rect(bb.cx - bb.w/2., bb.cy - bb.h/2., bb.w, bb.h), CV_RGB(0,255,0), 2);
36        cv::imshow("output", image);
37        cv::waitKey();
38 #endif //VISULIZE
39
40 //        std::stringstream s;
41 //        std::string ss;
42 //        int countTmp = frames;
43 //        s << "imgs" << "/img" << (countTmp/10000);
44 //        countTmp = countTmp%10000;
45 //        s << (countTmp/1000);
46 //        countTmp = countTmp%1000;
47 //        s << (countTmp/100);
48 //        countTmp = countTmp%100;
49 //        s << (countTmp/10);
50 //        countTmp = countTmp%10;
51 //        s << (countTmp);
52 //        s << ".jpg";
53 //        s >> ss;
54 //        //set image output parameters
55 //        std::vector<int> compression_params;
56 //        compression_params.push_back(CV_IMWRITE_JPEG_QUALITY);
57 //        compression_params.push_back(90);
58 //        cv::imwrite(ss.c_str(), image, compression_params);
59     }
60
61     std::cout << "Average processing speed " << avg_time/frames <<  "ms. (" << 1./(avg_time/frames)*1000 << " fps)" << std::endl;
62
63     return EXIT_SUCCESS;
64 }