From: Michal Sojka Date: Thu, 18 Oct 2018 14:27:11 +0000 (+0200) Subject: Allow specifying visual debug mode from command line X-Git-Url: https://rtime.felk.cvut.cz/gitweb/hercules2020/kcf.git/commitdiff_plain/f498ac81b844b016e80ce5ac694c43107a418625?hp=e0481f87752acaf666be487f9b9540e060339370 Allow specifying visual debug mode from command line --- diff --git a/README.md b/README.md index 9b44bb5..2660310 100644 --- 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 | 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 diff --git a/main_vot.cpp b/main_vot.cpp index 67b180d..5192b46 100644 --- a/main_vot.cpp +++ b/main_vot.cpp @@ -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] \n" << argv[0] << " [options] [path/to/output.txt]\n" << "Options:\n" - << " --visualize | -v[delay_ms]\n" - << " --output | -o \n" - << " --debug | -d\n" - << " --fit | -f[W[xH]]\n"; + << " --visualize | -v[delay_ms]\n" + << " --output | -o \n" + << " --fit | -f[W[xH]]\n" + << " --debug | -d\n" + << " --visual_debug | -p [p|r]\n"; exit(0); break; case 'o': diff --git a/src/kcf.cpp b/src/kcf.cpp index 01c86e3..5fbcdf0 100644 --- a/src/kcf.cpp +++ b/src/kcf.cpp @@ -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; diff --git a/src/kcf.h b/src/kcf.h index 8d6973c..4a7f9f0 100644 --- 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};