]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/commitdiff
bug fixed how the scaling is handled for output bbox
authorTomas Vojir <vojirtom@cmp.felk.cvut.cz>
Mon, 8 Aug 2016 10:38:49 +0000 (12:38 +0200)
committerTomas Vojir <vojirtom@cmp.felk.cvut.cz>
Mon, 8 Aug 2016 10:38:49 +0000 (12:38 +0200)
src/kcf.cpp

index d5edc11f6e73aa3beafecd86eb5c2b148e420c53..d006312f9c5535af3910eb6fa9705976408e120f 100644 (file)
@@ -65,6 +65,7 @@ void KCF_Tracker::init(cv::Mat &img, const cv::Rect & bbox)
         p_scales.push_back(1.);
 
     p_current_scale = 1.;
+
     double min_size_ratio = std::max(2.*p_cell_size/p_windows_size[0], 2.*p_cell_size/p_windows_size[1]);
     double max_size_ratio = std::min(floor(img.cols/p_cell_size)*p_cell_size/p_windows_size[0], floor(img.rows/p_cell_size)*p_cell_size/p_windows_size[1]);
     p_min_max_scale[0] = std::pow(p_scale_step, std::ceil(std::log(min_size_ratio) / log(p_scale_step)));
@@ -113,12 +114,14 @@ void KCF_Tracker::updateTrackerPosition(BBox_c &bbox)
 
 BBox_c KCF_Tracker::getBBox()
 {
-    if (p_resize_image) {
-        BBox_c tmp = p_pose;
+    BBox_c tmp = p_pose;
+    tmp.w *= p_current_scale;
+    tmp.h *= p_current_scale;
+
+    if (p_resize_image)
         tmp.scale(2);
-        return tmp;
-    } else
-        return p_pose;
+
+    return tmp;
 }
 
 void KCF_Tracker::track(cv::Mat &img)
@@ -175,7 +178,9 @@ void KCF_Tracker::track(cv::Mat &img)
         subpixel_max_loc.x = subpixel_max_loc.x - max_response_map.cols;
 
     //sub grid scale interpolation
-    double scale_subgrid = sub_grid_scale(scale_responses);
+    //2016-08-07 15:48:55+02:00 FIX : scale grid poor performance
+    //double scale_subgrid = sub_grid_scale(scale_responses);
+    double scale_subgrid = p_scales[scale_index];
 
     std::cout << "scale interp: " << p_scales[scale_index] << " vs. " << scale_subgrid  << " -> prev. final scale: " << p_current_scale << std::endl;
 
@@ -193,9 +198,6 @@ void KCF_Tracker::track(cv::Mat &img)
     if (p_pose.cy < 0) p_pose.cy = 0;
     if (p_pose.cy > img.rows-1) p_pose.cy = img.rows-1;
 
-    p_pose.w *= scale_subgrid;
-    p_pose.h *= scale_subgrid;
-
     //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);