]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/blobdiff - main_vot.cpp
Prepare for rotation branch merge
[hercules2020/kcf.git] / main_vot.cpp
index 40dfd442fdc96140d27613e9529b53b51af19003..3a846e86af00aa4999de8d8c4e904781596c6f97 100644 (file)
@@ -2,6 +2,7 @@
 #include <getopt.h>
 #include <libgen.h>
 #include <unistd.h>
+#include <iomanip>
 
 #include "kcf.h"
 #include "vot.hpp"
 double calcAccuracy(std::string line, cv::Rect bb_rect, cv::Rect &groundtruth_rect)
 {
     std::vector<float> numbers;
-    std::istringstream s( line );
+    std::istringstream s(line);
     float x;
     char ch;
 
-    while (s >> x){
+    while (s >> x) {
         numbers.push_back(x);
         s >> ch;
     }
@@ -22,11 +23,11 @@ double calcAccuracy(std::string line, cv::Rect bb_rect, cv::Rect &groundtruth_re
     double y1 = std::min(numbers[1], std::min(numbers[3], std::min(numbers[5], numbers[7])));
     double y2 = std::max(numbers[1], std::max(numbers[3], std::max(numbers[5], numbers[7])));
 
-    groundtruth_rect = cv::Rect(x1, y1, x2-x1, y2-y1);
+    groundtruth_rect = cv::Rect(x1, y1, x2 - x1, y2 - y1);
 
     double rects_intersection = (groundtruth_rect & bb_rect).area();
     double rects_union = (groundtruth_rect | bb_rect).area();
-    double accuracy = rects_intersection/rects_union;
+    double accuracy = rects_intersection / rects_union;
 
     return accuracy;
 }
@@ -49,8 +50,7 @@ int main(int argc, char *argv[])
             {0,           0,                 0,  0 }
         };
 
-        int c = getopt_long(argc, argv, "dhv::f::o:",
-                        long_options, &option_index);
+        int c = getopt_long(argc, argv, "dhv::f::o:", long_options, &option_index);
         if (c == -1)
             break;
 
@@ -84,7 +84,7 @@ int main(int argc, char *argv[])
             sizes.erase(0, pos + delimiter.length());
 
             fit_size_x = stol(first_argument);
-           fit_size_y = stol(sizes);
+            fit_size_y = stol(sizes);
             break;
         }
     }
@@ -141,11 +141,15 @@ int main(int argc, char *argv[])
     cv::Rect bb_rect;
     double avg_time = 0., sum_accuracy = 0.;
     int frames = 0;
+
+    std::cout << std::fixed << std::setprecision(2);
+
     while (vot_io.getNextImage(image) == 1){
         double time_profile_counter = cv::getCPUTickCount();
         tracker.track(image);
         time_profile_counter = cv::getCPUTickCount() - time_profile_counter;
-         std::cout << "  -> speed : " <<  time_profile_counter/((double)cvGetTickFrequency()*1000) << "ms. per frame";
+         std::cout << "  -> speed : " <<  time_profile_counter/((double)cvGetTickFrequency()*1000) << "ms per frame, "
+                      "response : " << tracker.getFilterResponse();
         avg_time += time_profile_counter/((double)cvGetTickFrequency()*1000);
         frames++;
 
@@ -196,11 +200,12 @@ int main(int argc, char *argv[])
 //        cv::imwrite(ss.c_str(), image, compression_params);
     }
 
-    std::cout << "Average processing speed " << avg_time/frames <<  "ms. (" << 1./(avg_time/frames)*1000 << " fps)" << std::endl;
+    std::cout << "Average processing speed: " << avg_time / frames << "ms (" << 1. / (avg_time / frames) * 1000 << " fps)";
     if (groundtruth_stream.is_open()) {
-        std::cout << "Average accuracy: " << sum_accuracy/frames << std::endl;
+        std::cout << "Average accuracy: " << sum_accuracy/frames << std::endl;
         groundtruth_stream.close();
     }
+    std::cout << std::endl;
 
     return EXIT_SUCCESS;
 }