@@ -429,8 +429,12 @@ Point2f TrackerCSRTImpl::estimate_new_position(const Mat &image)
429
429
430
430
Mat resp = calculate_response (image, csr_filter);
431
431
432
+ double max_val;
432
433
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
+
434
438
// take into account also subpixel accuracy
435
439
float col = ((float ) max_loc.x ) + subpixel_peak (resp, " horizontal" , max_loc);
436
440
float row = ((float ) max_loc.y ) + subpixel_peak (resp, " vertical" , max_loc);
@@ -472,6 +476,8 @@ bool TrackerCSRTImpl::updateImpl(const Mat& image_, Rect2d& boundingBox)
472
476
}
473
477
474
478
object_center = estimate_new_position (image);
479
+ if (object_center.x < 0 && object_center.y < 0 )
480
+ return false ;
475
481
476
482
current_scale_factor = dsst.getScale (image, object_center);
477
483
// update bouding_box according to new scale and location
@@ -651,6 +657,7 @@ TrackerCSRT::Params::Params()
651
657
histogram_bins = 16 ;
652
658
background_ratio = 2 ;
653
659
histogram_lr = 0 .04f ;
660
+ psr_threshold = 0 .035f ;
654
661
}
655
662
656
663
void TrackerCSRT::Params::read (const FileNode& fn)
@@ -708,6 +715,8 @@ void TrackerCSRT::Params::read(const FileNode& fn)
708
715
fn[" background_ratio" ] >> background_ratio;
709
716
if (!fn[" histogram_lr" ].empty ())
710
717
fn[" histogram_lr" ] >> histogram_lr;
718
+ if (!fn[" psr_threshold" ].empty ())
719
+ fn[" psr_threshold" ] >> psr_threshold;
711
720
CV_Assert (number_of_scales % 2 == 1 );
712
721
CV_Assert (use_gray || use_color_names || use_hog || use_rgb);
713
722
}
@@ -739,5 +748,6 @@ void TrackerCSRT::Params::write(FileStorage& fs) const
739
748
fs << " histogram_bins" << histogram_bins;
740
749
fs << " background_ratio" << background_ratio;
741
750
fs << " histogram_lr" << histogram_lr;
751
+ fs << " psr_threshold" << psr_threshold;
742
752
}
743
753
} /* namespace cv */
0 commit comments