]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/commitdiff
Allow specifying visual debug mode from command line
authorMichal Sojka <michal.sojka@cvut.cz>
Thu, 18 Oct 2018 14:27:11 +0000 (16:27 +0200)
committerMichal Sojka <michal.sojka@cvut.cz>
Thu, 18 Oct 2018 15:12:11 +0000 (17:12 +0200)
README.md
main_vot.cpp
src/kcf.cpp
src/kcf.h

index 9b44bb5f737b257a8910ed9e58b483925610fa11..26603100d409b06fc4328bee987fa8228db2cea2 100644 (file)
--- a/README.md
+++ b/README.md
@@ -176,6 +176,7 @@ top_left_y, width, height".
 | --visualize, -v[delay_ms] | Visualize the output, optionally with specified delay. If the delay is 0 the program will wait for a key press. |
 | --output, -o <output.txt>     | Specify name of output file. |
 | --debug, -d                           | Generate debug output. |
+| --visual_debug, -p[p|r] | Show graphical window with debugging information (either **p**atch or filter **r**esponse). |
 
 ## Automated testing
 
index 67b180d740d247ef351659651221f751f5324c35..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,7 +60,14 @@ int main(int argc, char *argv[])
             tracker.m_debug = true;
             break;
         case 'p':
-            tracker.m_visual_debug = true;
+            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"
@@ -68,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':
index 01c86e3f4733725e564b6e2d136eb6dec7b805a3..5fbcdf09c21bae89ee1d8aeed8065a2c286a0945 100644 (file)
@@ -346,11 +346,10 @@ double KCF_Tracker::findMaxReponse(uint &max_idx, cv::Point2d &new_location) con
     }
     DEBUG_PRINT(new_location);
 
-    if (m_visual_debug) {
-        const bool rgb = true;
+    if (m_visual_debug != vd::NONE) {
         const bool fit = 1;
-        int w = fit ? 100 : (rgb ? fit_size.width  : feature_size.width);
-        int h = fit ? 100 : (rgb ? fit_size.height : feature_size.height);
+        int w = fit ? 100 : (m_visual_debug == vd::PATCH ? fit_size.width  : feature_size.width);
+        int h = fit ? 100 : (m_visual_debug == vd::PATCH ? fit_size.height : feature_size.height);
         cv::Mat all_responses((h + 1) * p_num_scales - 1,
                               (w + 1) * p_num_angles - 1, CV_32FC3, cv::Scalar::all(0));
         for (size_t i = 0; i < p_num_scales; ++i) {
@@ -359,7 +358,7 @@ double KCF_Tracker::findMaxReponse(uint &max_idx, cv::Point2d &new_location) con
                 cv::Mat tmp;
                 cv::Point2d cross = threadctx.IF_BIG_BATCH(max(i, j), max).loc;
                 cross = wrapAroundFreq(cross, max_response_map);
-                if (rgb) {
+                if (m_visual_debug == vd::PATCH ) {
                     threadctx.dbg_patch IF_BIG_BATCH((i, j),)
                             .convertTo(tmp, all_responses.type(), 1.0 / 255);
                     cross.x = cross.x / fit_size.width  * tmp.cols + tmp.cols / 2;
index 8d6973ce7cb15fc4a5181d821b53ea9a16d437ef..4a7f9f0e499894d77ed1b0d70e4acc3034bc78cb 100644 (file)
--- a/src/kcf.h
+++ b/src/kcf.h
@@ -46,7 +46,7 @@ class KCF_Tracker
     friend Kcf_Tracker_Private;
 public:
     bool m_debug {false};
-    bool m_visual_debug {false};
+    enum class vd {NONE, PATCH, RESPONSE} m_visual_debug {vd::NONE};
     const bool m_use_scale {true};
     const bool m_use_color {true};
     const bool m_use_subpixel_localization {true};