]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/blobdiff - main_vot.cpp
Allow specifying visual debug mode from command line
[hercules2020/kcf.git] / main_vot.cpp
index 27c776fd8644646c6c01bfdeb15fc7510159f61e..5192b463ced4a8518a6fc3cec8974519396760b0 100644 (file)
@@ -43,7 +43,7 @@ int main(int argc, char *argv[])
         int option_index = 0;
         static struct option long_options[] = {
             {"debug",     no_argument,       0,  'd' },
-            {"visualDebug", no_argument, 0, 'p'},
+            {"visual_debug", optional_argument,    0, 'p'},
             {"help",      no_argument,       0,  'h' },
             {"output",    required_argument, 0,  'o' },
             {"visualize", optional_argument, 0,  'v' },
@@ -51,7 +51,7 @@ int main(int argc, char *argv[])
             {0,           0,                 0,  0 }
         };
 
-        int c = getopt_long(argc, argv, "dphv::f::o:", long_options, &option_index);
+        int c = getopt_long(argc, argv, "dp::hv::f::o:", long_options, &option_index);
         if (c == -1)
             break;
 
@@ -60,8 +60,14 @@ int main(int argc, char *argv[])
             tracker.m_debug = true;
             break;
         case 'p':
-            tracker.m_visual_debug = true;
-            visualize_delay = 500;
+            if (!optarg || *optarg == 'p')
+                tracker.m_visual_debug = KCF_Tracker::vd::PATCH;
+            else if (optarg && *optarg == 'r')
+                tracker.m_visual_debug = KCF_Tracker::vd::RESPONSE;
+            else {
+                fprintf(stderr, "Unknown visual debug mode: %c", *optarg);
+                return 1;
+            }
             break;
         case 'h':
             std::cerr << "Usage: \n"
@@ -69,10 +75,11 @@ int main(int argc, char *argv[])
                       << argv[0] << " [options] <directory>\n"
                       << argv[0] << " [options] <path/to/region.txt or groundtruth.txt> <path/to/images.txt> [path/to/output.txt]\n"
                       << "Options:\n"
-                      << " --visualize | -v[delay_ms]\n"
-                      << " --output    | -o <output.txt>\n"
-                      << " --debug     | -d\n"
-                      << " --fit       | -f[W[xH]]\n";
+                      << " --visualize    | -v[delay_ms]\n"
+                      << " --output       | -o <output.txt>\n"
+                      << " --fit          | -f[W[xH]]\n"
+                      << " --debug        | -d\n"
+                      << " --visual_debug | -p [p|r]\n";
             exit(0);
             break;
         case 'o':
@@ -180,11 +187,21 @@ int main(int argc, char *argv[])
         std::cout << std::endl;
 
         if (visualize_delay >= 0) {
-            cv::rectangle(image, bb_rect, CV_RGB(0,255,0), 2);
-            cv::imshow("output", image);
+            cv::Point pt(bb.cx, bb.cy);
+            cv::Size size(bb.w, bb.h);
+            cv::RotatedRect rotatedRectangle(pt, size, bb.a);
+
+            cv::Point2f vertices[4];
+            rotatedRectangle.points(vertices);
+
+            for (int i = 0; i < 4; i++)
+                cv::line(image, vertices[i], vertices[(i + 1) % 4], cv::Scalar(0, 255, 0), 2);
+            cv::imshow("KCF output", image);
             int ret = cv::waitKey(visualize_delay);
-            if (visualize_delay > 0 && ret != -1 && ret < 128)
+            if ((visualize_delay > 0 && ret != -1 && ret < 128) ||
+                (visualize_delay == 0 && (ret == 27 /*esc*/ || ret == 'q')))
                 break;
+
         }
 
 //        std::stringstream s;