]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/commitdiff
Merge branch 'master' of https://github.com/Shanigen/kcf
authorShanigen <vkaraf@gmail.com>
Tue, 6 Mar 2018 16:04:45 +0000 (17:04 +0100)
committerShanigen <vkaraf@gmail.com>
Tue, 6 Mar 2018 16:04:45 +0000 (17:04 +0100)
CMakeLists.txt
README.md
main_vot.cpp
src/kcf.cpp
src/kcf.h

index 5606b6407b053462752f24ecbdb2d1d3eb1eeb90..9ff939cd9bc462b4d8f93220fda6d45dc9dbc8e9 100644 (file)
@@ -10,18 +10,12 @@ MESSAGE(STATUS "FFT implementation: ${FFT}")
 
 option(OPENMP "Use OpenMP library. Works with FFTW and OpenCV implementation." OFF)
 option(ASYNC "Works only if OPENCV_CUFFT is not ON. Will enable C++ async directive." OFF)
-option(DEBUG_MODE "Additional terminal outputs and screens. " OFF)
 option(PROFILING "Enable profiling using perf_event_open together with libpfm4. " OFF)
 
-IF(DEBUG_MODE )
-  add_definitions(-DDEBUG_MODE )
-  MESSAGE(STATUS "Debug mode")
-ENDIF() #DEBUG_MODE 
-
 IF(PROFILING)
   add_definitions(-DPROFILING )
   MESSAGE(STATUS "Profiling mode")
-ENDIF() #DEBUG_MODE 
+ENDIF()
 
 SET(use_cuda OFF)
 
index 1b075e0d2ffdd799bd40e400c5a79532d82ac74f..96ff95cd5e30cac477816f2d4b42f299f2bcc6c7 100644 (file)
--- a/README.md
+++ b/README.md
@@ -39,10 +39,6 @@ The following table shows multiple options how to run cmake to get different ver
 
 To all of these you can also add these additional options:
 
-| Option| Description |
-| --- | --- |
-| `-DDEBUG_MODE=ON` | Debug terminal output and debug screens.|
-
 There is also option for profiling. Currently only profiles *get_features* function for which it calculates average number of CPU cycles. Works with default single threaded version using OpenCV. The code was taken from [libpfm4](https://sourceforge.net/p/perfmon2/libpfm4/ci/master/tree/) perf_examples self_basic.c:
 
 | Option| Description |
index 6591d416dcc16bf58aebf9492d32c0ac36fd510f..5944f440f457c7d49a90ce7166d4f2728cca56aa 100644 (file)
@@ -11,29 +11,36 @@ int main(int argc, char *argv[])
     //load region, images and prepare for output
     std::string region, images, output;
     int visualize_delay = -1;
+    KCF_Tracker tracker;
 
     while (1) {
         int option_index = 0;
         static struct option long_options[] = {
+            {"debug",     no_argument,       0,  'd' },
             {"help",      no_argument,       0,  'h' },
             {"output",    required_argument, 0,  'o' },
             {"visualize", optional_argument, 0,  'v' },
             {0,           0,                 0,  0 }
         };
 
-        int c = getopt_long(argc, argv, "hv::o:",
+        int c = getopt_long(argc, argv, "dhv::o:",
                         long_options, &option_index);
         if (c == -1)
             break;
 
         switch (c) {
+        case 'd':
+            tracker.m_debug = true;
+            break;
         case 'h':
             std::cerr << "Usage: \n"
                       << argv[0] << " [options]\n"
                       << 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";
+                      << " --visualize | -v [delay_ms]\n"
+                      << " --output    | -o <outout.txt>\n"
+                      << " --debug     | -d\n";
             exit(0);
             break;
         case 'o':
@@ -76,7 +83,6 @@ int main(int argc, char *argv[])
     }
     VOT vot_io(region, images, output);
 
-    KCF_Tracker tracker;
     cv::Mat image;
 
     //img = firts frame, initPos = initial position in the first frame
index 05f7223460b628da8eeb68bee205996dc0aa5ee0..41293808a5dd9f7705ab86958598c067c7abcd9b 100644 (file)
@@ -573,34 +573,36 @@ ComplexMat KCF_Tracker::fft2(const cv::Mat &input)
 #if !defined OPENCV_CUFFT || !defined FFTW
     cv::dft(input, complex_result, cv::DFT_COMPLEX_OUTPUT);
 #endif //!defined OPENCV_CUFFT || !defined FFTW
-#ifdef DEBUG_MODE
-    //extraxt x and y channels
-    cv::Mat xy[2]; //X,Y
-    cv::split(complex_result, xy);
-
-    //calculate angle and magnitude
-    cv::Mat magnitude, angle;
-    cv::cartToPolar(xy[0], xy[1], magnitude, angle, true);
-
-    //translate magnitude to range [0;1]
-    double mag_max;
-    cv::minMaxLoc(magnitude, 0, &mag_max);
-    magnitude.convertTo(magnitude, -1, 1.0 / mag_max);
-
-    //build hsv image
-    cv::Mat _hsv[3], hsv;
-    _hsv[0] = angle;
-    _hsv[1] = cv::Mat::ones(angle.size(), CV_32F);
-    _hsv[2] = magnitude;
-    cv::merge(_hsv, 3, hsv);
-
-    //convert to BGR and show
-    cv::Mat bgr;//CV_32FC3 matrix
-    cv::cvtColor(hsv, bgr, cv::COLOR_HSV2BGR);
-    cv::resize(bgr, bgr, cv::Size(600,600));
-    cv::imshow("DFT", bgr);
-    cv::waitKey(0);
-#endif //DEBUG_MODE
+    
+    if (m_debug) {
+        //extraxt x and y channels
+        cv::Mat xy[2]; //X,Y
+        cv::split(complex_result, xy);
+
+        //calculate angle and magnitude
+        cv::Mat magnitude, angle;
+        cv::cartToPolar(xy[0], xy[1], magnitude, angle, true);
+
+        //translate magnitude to range [0;1]
+        double mag_max;
+        cv::minMaxLoc(magnitude, 0, &mag_max);
+        magnitude.convertTo(magnitude, -1, 1.0 / mag_max);
+
+        //build hsv image
+        cv::Mat _hsv[3], hsv;
+        _hsv[0] = angle;
+        _hsv[1] = cv::Mat::ones(angle.size(), CV_32F);
+        _hsv[2] = magnitude;
+        cv::merge(_hsv, 3, hsv);
+
+        //convert to BGR and show
+        cv::Mat bgr;//CV_32FC3 matrix
+        cv::cvtColor(hsv, bgr, cv::COLOR_HSV2BGR);
+        cv::resize(bgr, bgr, cv::Size(600,600));
+        cv::imshow("DFT", bgr);
+        cv::waitKey(10);
+    }
+    
     return ComplexMat(complex_result);
 }
 
index 1b4840464faf7d22e6d0984f0a12cfec21e75a84..56ecadb02fcd6fb6acb3cf5a95a82f3bbd31a809 100644 (file)
--- a/src/kcf.h
+++ b/src/kcf.h
@@ -33,6 +33,7 @@ struct BBox_c
 class KCF_Tracker
 {
 public:
+    bool m_debug     {false};
 #ifdef OPENCV_CUFFT
     bool m_use_scale {false};
     bool m_use_color {false};