]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/commitdiff
add switchoff flags for subpixel/subgrid feature
authorTomas Vojir <vojirtom@cmp.felk.cvut.cz>
Mon, 8 Aug 2016 10:59:15 +0000 (12:59 +0200)
committerTomas Vojir <vojirtom@cmp.felk.cvut.cz>
Mon, 8 Aug 2016 10:59:15 +0000 (12:59 +0200)
src/kcf.cpp
src/kcf.h

index d006312f9c5535af3910eb6fa9705976408e120f..37837be69ea2e30a11f5e8d9a1e5f2a68e8ba4e4 100644 (file)
@@ -170,29 +170,29 @@ void KCF_Tracker::track(cv::Mat &img)
     }
 
     //sub pixel quadratic interpolation from neighbours
-    cv::Point2f subpixel_max_loc = sub_pixel_peak(max_response_pt, max_response_map);
+    cv::Point2f new_location(max_response_pt.x, max_response_pt.y);
+    if (m_use_subpixel_localization)
+        new_location = sub_pixel_peak(max_response_pt, max_response_map);
 
-    if (subpixel_max_loc.y > max_response_map.rows / 2) //wrap around to negative half-space of vertical axis
-        subpixel_max_loc.y = subpixel_max_loc.y - max_response_map.rows;
-    if (subpixel_max_loc.x > max_response_map.cols / 2) //same for horizontal axis
-        subpixel_max_loc.x = subpixel_max_loc.x - max_response_map.cols;
+    if (new_location.y > max_response_map.rows / 2) //wrap around to negative half-space of vertical axis
+        new_location.y = new_location.y - max_response_map.rows;
+    if (new_location.x > max_response_map.cols / 2) //same for horizontal axis
+        new_location.x = new_location.x - max_response_map.cols;
 
     //sub grid scale interpolation
-    //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];
+    double new_scale = p_scales[scale_index];
+    if (m_use_subgrid_scale)
+        new_scale = sub_grid_scale(scale_responses);
 
-    std::cout << "scale interp: " << p_scales[scale_index] << " vs. " << scale_subgrid  << " -> prev. final scale: " << p_current_scale << std::endl;
-
-    p_current_scale *= scale_subgrid;
+    p_current_scale *= new_scale;
 
     if (p_current_scale < p_min_max_scale[0])
         p_current_scale = p_min_max_scale[0];
     if (p_current_scale > p_min_max_scale[1])
         p_current_scale = p_min_max_scale[1];
 
-    p_pose.cx += p_cell_size * subpixel_max_loc.x;
-    p_pose.cy += p_cell_size * subpixel_max_loc.y;
+    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;
index 5c2f83d4f8725f35660484ca7837804970f27c8a..9f0f9f9f3eb11729f7042c44d5e67a86fd28a8c2 100644 (file)
--- a/src/kcf.h
+++ b/src/kcf.h
@@ -30,6 +30,8 @@ class KCF_Tracker
 public:
     bool m_use_scale {true};
     bool m_use_color {true};
+    bool m_use_subpixel_localization {true};
+    bool m_use_subgrid_scale {true};
 
     /*
     padding             ... extra area surrounding the target           (1.5)