From 9f6042853c1017ec504d1b6e17dd7f934a823139 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Mon, 24 Sep 2018 11:33:57 +0300 Subject: [PATCH 1/3] docs: exclude 'matlab' entry --- modules/matlab/cmake/init.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/matlab/cmake/init.cmake b/modules/matlab/cmake/init.cmake index bafa24ee6..e3adccd11 100644 --- a/modules/matlab/cmake/init.cmake +++ b/modules/matlab/cmake/init.cmake @@ -18,3 +18,8 @@ if(WITH_MATLAB AND NOT DEFINED MATLAB_FOUND) set(MATLAB_FOUND "${MATLAB_FOUND}" PARENT_SCOPE) set(MATLAB_MEX_SCRIPT "${MATLAB_MEX_SCRIPT}" PARENT_SCOPE) endif() + +if(NOT OPENCV_DOCS_INCLUDE_MATLAB) + list(APPEND DOXYGEN_BLACKLIST "matlab") + set(DOXYGEN_BLACKLIST "${DOXYGEN_BLACKLIST}" PARENT_SCOPE) +endif() From ad8cf97e9d586ff60c5619f4b48bf083759c2379 Mon Sep 17 00:00:00 2001 From: berak Date: Thu, 27 Sep 2018 12:46:10 +0200 Subject: [PATCH 2/3] tracking: add a threshold to the CSRT tracker --- modules/tracking/doc/tracking.bib | 7 +++++++ .../tracking/include/opencv2/tracking/tracker.hpp | 2 ++ modules/tracking/src/trackerCSRT.cpp | 12 +++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/modules/tracking/doc/tracking.bib b/modules/tracking/doc/tracking.bib index 191601cf2..9853b965f 100644 --- a/modules/tracking/doc/tracking.bib +++ b/modules/tracking/doc/tracking.bib @@ -107,3 +107,10 @@ author={Bolme, David S. and Beveridge, J. Ross and Draper, Bruce A. and Lui Yui, booktitle = {Conference on Computer Vision and Pattern Recognition (CVPR)}, year = {2010} } + +@Article{Lukezic_IJCV2018, +author={Luke{\v{z}}i{\v{c}}, Alan and Voj{'i}{\v{r}}, Tom{'a}{\v{s}} and {\v{C}}ehovin Zajc, Luka and Matas, Ji{\v{r}}{'i} and Kristan, Matej}, +title={Discriminative Correlation Filter Tracker with Channel and Spatial Reliability}, +journal={International Journal of Computer Vision}, +year={2018}, +} diff --git a/modules/tracking/include/opencv2/tracking/tracker.hpp b/modules/tracking/include/opencv2/tracking/tracker.hpp index 37545bfee..886ef249f 100644 --- a/modules/tracking/include/opencv2/tracking/tracker.hpp +++ b/modules/tracking/include/opencv2/tracking/tracker.hpp @@ -1513,6 +1513,8 @@ public: float scale_model_max_area; float scale_lr; float scale_step; + + float psr_threshold; //!< we lost the target, if the psr is lower than this. }; /** @brief Constructor diff --git a/modules/tracking/src/trackerCSRT.cpp b/modules/tracking/src/trackerCSRT.cpp index d34b8562b..d46cf1432 100644 --- a/modules/tracking/src/trackerCSRT.cpp +++ b/modules/tracking/src/trackerCSRT.cpp @@ -429,8 +429,12 @@ Point2f TrackerCSRTImpl::estimate_new_position(const Mat &image) Mat resp = calculate_response(image, csr_filter); + double max_val; Point max_loc; - minMaxLoc(resp, NULL, NULL, NULL, &max_loc); + minMaxLoc(resp, NULL, &max_val, NULL, &max_loc); + if (max_val < params.psr_threshold) + return Point2f(-1,-1); // target "lost" + // take into account also subpixel accuracy float col = ((float) max_loc.x) + subpixel_peak(resp, "horizontal", max_loc); float row = ((float) max_loc.y) + subpixel_peak(resp, "vertical", max_loc); @@ -472,6 +476,8 @@ bool TrackerCSRTImpl::updateImpl(const Mat& image_, Rect2d& boundingBox) } object_center = estimate_new_position(image); + if (object_center.x < 0 && object_center.y < 0) + return false; current_scale_factor = dsst.getScale(image, object_center); //update bouding_box according to new scale and location @@ -651,6 +657,7 @@ TrackerCSRT::Params::Params() histogram_bins = 16; background_ratio = 2; histogram_lr = 0.04f; + psr_threshold = 0.035f; } void TrackerCSRT::Params::read(const FileNode& fn) @@ -708,6 +715,8 @@ void TrackerCSRT::Params::read(const FileNode& fn) fn["background_ratio"] >> background_ratio; if(!fn["histogram_lr"].empty()) fn["histogram_lr"] >> histogram_lr; + if(!fn["psr_threshold"].empty()) + fn["psr_threshold"] >> psr_threshold; CV_Assert(number_of_scales % 2 == 1); CV_Assert(use_gray || use_color_names || use_hog || use_rgb); } @@ -739,5 +748,6 @@ void TrackerCSRT::Params::write(FileStorage& fs) const fs << "histogram_bins" << histogram_bins; fs << "background_ratio" << background_ratio; fs << "histogram_lr" << histogram_lr; + fs << "psr_threshold" << psr_threshold; } } /* namespace cv */ From 502970b3ccb6d35e6a7144356aa5090cb807a797 Mon Sep 17 00:00:00 2001 From: berak Date: Sun, 30 Sep 2018 10:33:41 +0200 Subject: [PATCH 3/3] cvv: fix small memleak in demo --- modules/cvv/samples/cvv_demo.cpp | 37 +++++++++++--------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/modules/cvv/samples/cvv_demo.cpp b/modules/cvv/samples/cvv_demo.cpp index 3767590f7..14aafbeb1 100644 --- a/modules/cvv/samples/cvv_demo.cpp +++ b/modules/cvv/samples/cvv_demo.cpp @@ -28,13 +28,6 @@ template std::string toString(const T& p_arg) } -void -usage() -{ - printf("usage: cvv_demo [-r WxH]\n"); - printf("-h print this help\n"); - printf("-r WxH change resolution to width W and height H\n"); -} int @@ -44,35 +37,29 @@ main(int argc, char** argv) // parser keys const char *keys = - "{ help h usage ? | | show this message }" - "{ resolution r |0x0| resolution to width and height in the format WxH }"; + "{ help h usage ? | | show this message }" + "{ width W | 0| camera resolution width. leave at 0 to use defaults }" + "{ height H | 0| camera resolution height. leave at 0 to use defaults }"; + CommandLineParser parser(argc, argv, keys); - string res(parser.get("resolution")); if (parser.has("help")) { - usage(); + parser.printMessage(); return 0; } - if (res != "0x0") { - char dummych; - resolution = new cv::Size(); - if (sscanf(res.c_str(), "%d%c%d", &resolution->width, &dummych, &resolution->height) != 3) { - cout << res << " not a valid resolution" << endl; - return 1; - } - } + int res_w = parser.get("width"); + int res_h = parser.get("height"); // setup video capture cv::VideoCapture capture(0); if (!capture.isOpened()) { std::cout << "Could not open VideoCapture" << std::endl; - return 3; + return 1; } - if (resolution) { - printf("Setting resolution to %dx%d\n", resolution->width, resolution->height); - capture.set(CV_CAP_PROP_FRAME_WIDTH, resolution->width); - capture.set(CV_CAP_PROP_FRAME_HEIGHT, resolution->height); - delete resolution; + if (res_w>0 && res_h>0) { + printf("Setting resolution to %dx%d\n", res_w, res_h); + capture.set(CV_CAP_PROP_FRAME_WIDTH, res_w); + capture.set(CV_CAP_PROP_FRAME_HEIGHT, res_h); }