From e0481f87752acaf666be487f9b9540e060339370 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Thu, 18 Oct 2018 15:52:04 +0200 Subject: [PATCH 1/1] Take current angle into account when updating tracked object position --- src/kcf.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/kcf.cpp b/src/kcf.cpp index 3961d9c..01c86e3 100644 --- a/src/kcf.cpp +++ b/src/kcf.cpp @@ -425,6 +425,12 @@ void KCF_Tracker::track(cv::Mat &img) uint max_idx; max_response = findMaxReponse(max_idx, new_location); + double angle_change = d->IF_BIG_BATCH(threadctxs[0].max, threadctxs).angle(max_idx); + p_current_angle += angle_change; + + new_location.x = new_location.x * cos(-p_current_angle/180*M_PI) + new_location.y * sin(-p_current_angle/180*M_PI); + new_location.y = new_location.y * cos(-p_current_angle/180*M_PI) - new_location.x * sin(-p_current_angle/180*M_PI); + new_location.x *= double(p_windows_size.width) / fit_size.width; new_location.y *= double(p_windows_size.height) / fit_size.height; @@ -442,7 +448,6 @@ void KCF_Tracker::track(cv::Mat &img) clamp2(p_current_scale, p_min_max_scale[0], p_min_max_scale[1]); - p_current_angle += d->IF_BIG_BATCH(threadctxs[0].max, threadctxs).angle(max_idx); // train at newly estimated target position train(input_rgb, input_gray, p_interp_factor); -- 2.39.2