]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/commitdiff
Draw maximum (cross) in the middle of pixels, not at the edge
authorMichal Sojka <michal.sojka@cvut.cz>
Thu, 18 Oct 2018 22:02:27 +0000 (00:02 +0200)
committerMichal Sojka <michal.sojka@cvut.cz>
Thu, 18 Oct 2018 22:02:27 +0000 (00:02 +0200)
src/kcf.cpp

index 66689250c0af5e8779a26efd01731c7005eecb4e..64baea78d4f3c8105459c9ec1c03dbe082631791 100644 (file)
@@ -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);