Skip to content

Commit 9e26cc3

Browse files
committed
Merge pull request #1795 from berak:tracking_csrt_threshold
2 parents aa688fb + ad8cf97 commit 9e26cc3

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

modules/tracking/doc/tracking.bib

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,10 @@ @inproceedings{MOSSE
107107
booktitle = {Conference on Computer Vision and Pattern Recognition (CVPR)},
108108
year = {2010}
109109
}
110+
111+
@Article{Lukezic_IJCV2018,
112+
author={Luke{\v{z}}i{\v{c}}, Alan and Voj{'i}{\v{r}}, Tom{'a}{\v{s}} and {\v{C}}ehovin Zajc, Luka and Matas, Ji{\v{r}}{'i} and Kristan, Matej},
113+
title={Discriminative Correlation Filter Tracker with Channel and Spatial Reliability},
114+
journal={International Journal of Computer Vision},
115+
year={2018},
116+
}

modules/tracking/include/opencv2/tracking/tracker.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,6 +1513,8 @@ class CV_EXPORTS_W TrackerCSRT : public Tracker
15131513
float scale_model_max_area;
15141514
float scale_lr;
15151515
float scale_step;
1516+
1517+
float psr_threshold; //!< we lost the target, if the psr is lower than this.
15161518
};
15171519

15181520
/** @brief Constructor

modules/tracking/src/trackerCSRT.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,12 @@ Point2f TrackerCSRTImpl::estimate_new_position(const Mat &image)
429429

430430
Mat resp = calculate_response(image, csr_filter);
431431

432+
double max_val;
432433
Point max_loc;
433-
minMaxLoc(resp, NULL, NULL, NULL, &max_loc);
434+
minMaxLoc(resp, NULL, &max_val, NULL, &max_loc);
435+
if (max_val < params.psr_threshold)
436+
return Point2f(-1,-1); // target "lost"
437+
434438
// take into account also subpixel accuracy
435439
float col = ((float) max_loc.x) + subpixel_peak(resp, "horizontal", max_loc);
436440
float row = ((float) max_loc.y) + subpixel_peak(resp, "vertical", max_loc);
@@ -472,6 +476,8 @@ bool TrackerCSRTImpl::updateImpl(const Mat& image_, Rect2d& boundingBox)
472476
}
473477

474478
object_center = estimate_new_position(image);
479+
if (object_center.x < 0 && object_center.y < 0)
480+
return false;
475481

476482
current_scale_factor = dsst.getScale(image, object_center);
477483
//update bouding_box according to new scale and location
@@ -651,6 +657,7 @@ TrackerCSRT::Params::Params()
651657
histogram_bins = 16;
652658
background_ratio = 2;
653659
histogram_lr = 0.04f;
660+
psr_threshold = 0.035f;
654661
}
655662

656663
void TrackerCSRT::Params::read(const FileNode& fn)
@@ -708,6 +715,8 @@ void TrackerCSRT::Params::read(const FileNode& fn)
708715
fn["background_ratio"] >> background_ratio;
709716
if(!fn["histogram_lr"].empty())
710717
fn["histogram_lr"] >> histogram_lr;
718+
if(!fn["psr_threshold"].empty())
719+
fn["psr_threshold"] >> psr_threshold;
711720
CV_Assert(number_of_scales % 2 == 1);
712721
CV_Assert(use_gray || use_color_names || use_hog || use_rgb);
713722
}
@@ -739,5 +748,6 @@ void TrackerCSRT::Params::write(FileStorage& fs) const
739748
fs << "histogram_bins" << histogram_bins;
740749
fs << "background_ratio" << background_ratio;
741750
fs << "histogram_lr" << histogram_lr;
751+
fs << "psr_threshold" << psr_threshold;
742752
}
743753
} /* namespace cv */

0 commit comments

Comments
 (0)