-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtracker_base.cpp
51 lines (42 loc) · 1.28 KB
/
tracker_base.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "tracker_base.hpp"
#include <ocv_libs/core/rect_utility.hpp>
tracker_base::tracker_base()
{
}
tracker_base::~tracker_base()
{
}
void tracker_base::track(const cv::Mat &image,
const std::vector<cv::Rect> ¤t_blobs,
const std::vector<cv::Rect2d> &roi,
double lost_track_ratio)
{
update(image);
if(!roi.empty()){
for(auto const &cblob : current_blobs){
double least_distance = 1e10;
for(auto const &r : roi){
auto const distance = ocv::center_euclidean_dist(cv::Rect2d(cblob),
r);
least_distance = std::min(distance, least_distance);
}
if(least_distance >= ocv::diagonal_euclidean_dist(cblob) * lost_track_ratio){
add_blob(image, cblob);
}
}
}else{
add_blob(image, current_blobs);
}
}
void tracker_base::add_blob(const cv::Mat &input, const std::vector<cv::Rect2d> &roi)
{
for(auto const &r : roi){
add_blob(input, r);
}
}
void tracker_base::add_blob(const cv::Mat &input, const std::vector<cv::Rect> &roi)
{
for(auto const &r : roi){
add_blob(input, cv::Rect2d(r));
}
}