]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/commitdiff
Integration of the visual debug, with zero changes to the tracker's API.
authorShanigen <vkaraf@gmail.com>
Thu, 27 Sep 2018 10:47:18 +0000 (12:47 +0200)
committerShanigen <vkaraf@gmail.com>
Thu, 27 Sep 2018 10:47:18 +0000 (12:47 +0200)
main_vot.cpp
src/kcf.cpp
src/kcf.h

index eddb39f9dbedfd167dd4310c1c54c604f9b26e5b..edcc8346298f864e90d27791a7b5cec2417641e2 100644 (file)
@@ -43,6 +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'},
             {"help",      no_argument,       0,  'h' },
             {"output",    required_argument, 0,  'o' },
             {"visualize", optional_argument, 0,  'v' },
@@ -50,7 +51,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, "dphv::f::o:", long_options, &option_index);
         if (c == -1)
             break;
 
@@ -58,6 +59,10 @@ int main(int argc, char *argv[])
         case 'd':
             tracker.m_debug = true;
             break;
+        case 'p':
+            tracker.m_visual_debug = true;
+            visualize_delay = 500;
+            break;
         case 'h':
             std::cerr << "Usage: \n"
                       << argv[0] << " [options]\n"
index 75119bd74ffcb5b5f0c3f9e00d348157e5ab1770..32cd9501408b71f3f7e90e3c14f661a7076c84a5 100644 (file)
@@ -321,6 +321,39 @@ double KCF_Tracker::findMaxReponse(uint &max_idx, cv::Point2d &new_location) con
         }
     }
 #endif
+
+    if (m_visual_debug) {
+        cv::Mat all_responses(cv::Size(p_num_angles * 100, p_num_scales * 100),
+                              d.threadctxs[max_idx].response.plane(0).type(), cv::Scalar::all(0));
+        for (size_t i = 0; i < p_num_scales; ++i) {
+            for (size_t j = 0; j < p_num_angles; ++j) {
+                cv::Mat in_roi(all_responses, cv::Rect(j * 100, i * 100, 100, 100));
+                cv::Mat copy_response = d.threadctxs[p_num_angles * i + j].response.plane(0).clone();
+
+                copy_response = copy_response(cv::Rect(0, 0, copy_response.cols & -2, copy_response.rows & -2));
+
+                int cx = copy_response.cols / 2;
+                int cy = copy_response.rows / 2;
+                cv::Mat q0(copy_response, cv::Rect(0, 0, cx, cy));
+                cv::Mat q1(copy_response, cv::Rect(cx, 0, cx, cy));
+                cv::Mat q2(copy_response, cv::Rect(0, cy, cx, cy));
+                cv::Mat q3(copy_response, cv::Rect(cx, cy, cx, cy));
+                cv::Mat tmp;
+                q0.copyTo(tmp);
+                q3.copyTo(q0);
+                tmp.copyTo(q3);
+                q1.copyTo(tmp);
+                q2.copyTo(q1);
+                tmp.copyTo(q2);
+
+                copy_response.copyTo(in_roi);
+            }
+        }
+        cv::namedWindow("All responses", CV_WINDOW_AUTOSIZE);
+        cv::imshow("All responses", all_responses);
+        cv::waitKey();
+    }
+
     cv::Point2i &max_response_pt = IF_BIG_BATCH(d.threadctxs[0].max[max_idx].loc,        d.threadctxs[max_idx].max.loc);
     cv::Mat max_response_map     = IF_BIG_BATCH(d.threadctxs[0].response.plane(max_idx), d.threadctxs[max_idx].response.plane(0));
 
index 42c68f7c3ed1a8e80b0cbbe5dfd8ffea50dee913..4ca1066e033efeb732bb65b0de476f2df43d6338 100644 (file)
--- a/src/kcf.h
+++ b/src/kcf.h
@@ -59,7 +59,8 @@ class KCF_Tracker
 {
     friend ThreadCtx;
 public:
-    bool m_debug     {false};
+    bool m_debug {false};
+    bool m_visual_debug {false};
     const bool m_use_scale {true};
     const bool m_use_color {true};
     const bool m_use_subpixel_localization {true};