]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/commitdiff
position shift take into account current window scale
authorTomas Vojir <vojirtom@cmp.felk.cvut.cz>
Mon, 19 Sep 2016 13:12:10 +0000 (15:12 +0200)
committerTomas Vojir <vojirtom@cmp.felk.cvut.cz>
Mon, 19 Sep 2016 13:12:10 +0000 (15:12 +0200)
src/kcf.cpp

index f08d333355aa8e98e8f43bafe898dce943d2bd1d..93a3d28af8bb4c1539b049502e926c4385724e60 100644 (file)
@@ -218,6 +218,13 @@ void KCF_Tracker::track(cv::Mat &img)
     if (m_use_subpixel_localization)
         new_location = sub_pixel_peak(max_response_pt, max_response_map);
 
+    p_pose.cx += p_current_scale*p_cell_size*new_location.x;
+    p_pose.cy += p_current_scale*p_cell_size*new_location.y;
+    if (p_pose.cx < 0) p_pose.cx = 0;
+    if (p_pose.cx > img.cols-1) p_pose.cx = img.cols-1;
+    if (p_pose.cy < 0) p_pose.cy = 0;
+    if (p_pose.cy > img.rows-1) p_pose.cy = img.rows-1;
+
     //sub grid scale interpolation
     double new_scale = p_scales[scale_index];
     if (m_use_subgrid_scale)
@@ -230,13 +237,6 @@ void KCF_Tracker::track(cv::Mat &img)
     if (p_current_scale > p_min_max_scale[1])
         p_current_scale = p_min_max_scale[1];
 
-    p_pose.cx += p_cell_size*new_location.x;
-    p_pose.cy += p_cell_size*new_location.y;
-    if (p_pose.cx < 0) p_pose.cx = 0;
-    if (p_pose.cx > img.cols-1) p_pose.cx = img.cols-1;
-    if (p_pose.cy < 0) p_pose.cy = 0;
-    if (p_pose.cy > img.rows-1) p_pose.cy = img.rows-1;
-
     //obtain a subwindow for training at newly estimated target position
     patch_feat = get_features(input_rgb, input_gray, p_pose.cx, p_pose.cy, p_windows_size[0], p_windows_size[1], p_current_scale);
     ComplexMat xf = fft2(patch_feat, p_cos_window);