From 9ebe36c3294847c12e74583762247a36038b91c2 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Fri, 19 Oct 2018 00:02:27 +0200 Subject: [PATCH] Draw maximum (cross) in the middle of pixels, not at the edge --- src/kcf.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/kcf.cpp b/src/kcf.cpp index 6668925..64baea7 100644 --- a/src/kcf.cpp +++ b/src/kcf.cpp @@ -369,6 +369,7 @@ double KCF_Tracker::findMaxReponse(uint &max_idx, cv::Point2d &new_location) con tmp /= max; // Normalize to 1 cross += cv::Point2d(tmp.size())/2; tmp = circshift(tmp, -tmp.cols/2, -tmp.rows/2); + //drawCross(tmp, cross, false); } bool green = false; if (&*max_it == &IF_BIG_BATCH(threadctx.max(i, j), threadctx)) { @@ -376,9 +377,10 @@ double KCF_Tracker::findMaxReponse(uint &max_idx, cv::Point2d &new_location) con cross = new_location + cv::Point2d(tmp.size())/2; green = true; } - cross.x *= double(w)/tmp.cols; - cross.y *= double(h)/tmp.rows; - cv::resize(tmp, tmp, cv::Size(w, h)); + // Move to the center of pixes (if scaling up) and scale + cross.x = (cross.x + 0.5) * double(w)/tmp.cols; + cross.y = (cross.y + 0.5) * double(h)/tmp.rows; + cv::resize(tmp, tmp, cv::Size(w, h)); //, 0, 0, cv::INTER_NEAREST); drawCross(tmp, cross, green); cv::Mat resp_roi(all_responses, cv::Rect(j * (w+1), i * (h+1), w, h)); tmp.copyTo(resp_roi); -- 2.39.2