]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/commitdiff
Added visual debug output.
authorShanigen <vkaraf@gmail.com>
Wed, 11 Jul 2018 13:19:57 +0000 (15:19 +0200)
committerShanigen <vkaraf@gmail.com>
Mon, 10 Sep 2018 00:25:47 +0000 (02:25 +0200)
main_vot.cpp
src/kcf.cpp
src/kcf.h

index d596bdd562acf4590131ec24fbcef8656dee9c49..4b125788fe69615cca3f59dea6a251dc6435ef12 100644 (file)
@@ -42,6 +42,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' },
@@ -49,7 +50,7 @@ int main(int argc, char *argv[])
             {0,           0,                 0,  0 }
         };
 
-        int c = getopt_long(argc, argv, "dhv::f::o:",
+        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 = 0;
+            break;
         case 'h':
             std::cerr << "Usage: \n"
                       << argv[0] << " [options]\n"
@@ -67,6 +72,7 @@ int main(int argc, char *argv[])
                       << " --visualize | -v[delay_ms]\n"
                       << " --output    | -o <output.txt>\n"
                       << " --debug     | -d\n"
+                      << " --visualDebug | -p\n"
                       << " --fit       | -f[WxH]\n";
             exit(0);
             break;
index 06fc7838fd8be716b7479572d270bbae7871c062..78bf5316a98b419e2a273979a544a18f9ca5f683 100644 (file)
@@ -374,7 +374,7 @@ void KCF_Tracker::track(cv::Mat &img)
         //            std::cout << "CURRENT SCALE: " << p_current_scale * p_scales[i] << std::endl;
         //                for (size_t j = 0; j < p_angles.size(); ++j) {
         //                    patch_feat = get_features(input_rgb, input_gray, p_pose.cx, p_pose.cy, p_windows_size[0],
-        //                    p_windo>>>>>>> Commiting work done so far on rotationws_size[1], p_current_scale * p_scales[i], p_current_angle + p_angles[j]);
+        //                    p_windows_size[1], p_current_scale * p_scales[i], p_current_angle + p_angles[j]);
         //                    ComplexMat zf = fft.forward_window(patch_feat);
         //                    DEBUG_PRINTM(zf);
         //                    cv::Mat response;
@@ -387,7 +387,7 @@ void KCF_Tracker::track(cv::Mat &img)
         //                        DEBUG_PRINTM(p_model_alphaf * kzf);
         //                        response = fft.inverse(p_model_alphaf * kzf);
         //                    }
-        //                    if (1) {
+        //                    if (m_visual_debug) {
         //                        cv::Mat copy_response = response.clone();
 
         //                        // crop the spectrum, if it has an odd number of rows or columns
@@ -592,8 +592,25 @@ void KCF_Tracker::get_features(cv::Mat &input_rgb, cv::Mat &input_gray, int cx,
 
     cv::Mat patch_gray = get_subwindow(input_gray, cx, cy, size_x_scaled, size_y_scaled, angle);
     cv::Mat patch_rgb = get_subwindow(input_rgb, cx, cy, size_x_scaled, size_y_scaled, angle);
-    if (m_debug) {
-        cv::imshow("Patch RGB unresized", patch_rgb);
+       if (m_visual_debug) {
+        cv::Mat patch_rgb_copy = patch_rgb.clone();
+        // Check 4 sectors of image if they have same number of black pixels
+        for(int sector = 0; sector < 4; sector++){
+            int blackPixels = 0;
+            for (int row = (sector<2?0:1)*patch_rgb_copy.rows/2; row < (patch_rgb_copy.rows-1)/(sector<2?2:1); row++){
+                for (int col = (sector == 0 || sector == 2?0:1)*patch_rgb_copy.cols/2; col < (patch_rgb_copy.cols-1)/((sector == 0 || sector == 2?2:1)); col++){
+                    cv::Vec3b pixel = patch_rgb_copy.at<cv::Vec3b>(row,col);
+                    if (pixel.val[0] == 0 && pixel.val[1] == 0 && pixel.val[2] == 0)
+                        ++blackPixels;
+                }
+            }
+            std::cout << blackPixels << std::endl;
+        }
+        std::cout << std::endl;
+
+        cv::line(patch_rgb_copy, cv::Point(0, (patch_rgb_copy.cols-1)/2), cv::Point(patch_rgb_copy.rows-1, (patch_rgb_copy.cols-1)/2),cv::Scalar(0, 255, 0));
+        cv::line(patch_rgb_copy, cv::Point((patch_rgb_copy.rows-1)/2, 0), cv::Point((patch_rgb_copy.rows-1)/2, patch_rgb_copy.cols-1),cv::Scalar(0, 255, 0));
+        cv::imshow("Patch RGB unresized", patch_rgb_copy);
         cv::waitKey();
     }
 
@@ -631,12 +648,12 @@ void KCF_Tracker::get_features(cv::Mat &input_rgb, cv::Mat &input_gray, int cx,
 
         cv::warpAffine(patch_rgb, patch_rgb, r, cv::Size(patch_rgb.cols, patch_rgb.rows), cv::BORDER_CONSTANT, 1);
         cv::Mat patch_rgb_copy = patch_rgb.clone();
-        
-        cv::namedWindow("Patch RGB copy", CV_WINDOW_NORMAL);
-        cv::resizeWindow("Patch RGB copy", 200, 200);
-        cv::putText(patch_rgb_copy, std::to_string(angle), cv::Point(0, patch_rgb_copy.rows-1), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0,255,0),2,cv::LINE_AA);
-        cv::imshow("Patch RGB copy",  patch_rgb_copy);
-        cv::waitKey(0);
+        if(m_visual_debug){
+            cv::namedWindow("Patch RGB copy", CV_WINDOW_NORMAL);
+            cv::resizeWindow("Patch RGB copy", 200, 200);
+            cv::putText(patch_rgb_copy, std::to_string(angle), cv::Point(0, patch_rgb_copy.rows-1), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0,255,0),2,cv::LINE_AA);
+            cv::imshow("Patch RGB copy",  patch_rgb_copy);
+        }
 
     }
 
index 20ae9daf38e06fe397fc1c61d144c62fe505d66f..76428c142db9860604599836d631233bea3e9756 100644 (file)
--- a/src/kcf.h
+++ b/src/kcf.h
@@ -55,6 +55,7 @@ class KCF_Tracker
 {
 public:
     bool m_debug {false};
+       bool m_visual_debug {false};
     bool m_use_scale {false};
     bool m_use_angle {true};
     bool m_use_color {true};