31 cv::Rect_<float> bb_test,
32 cv::Rect_<float> bb_gt)
34 float bb_test_centroid_x = (bb_test.x + bb_test.width / 2);
35 float bb_test_centroid_y = (bb_test.y + bb_test.height / 2);
37 float bb_gt_centroid_x = (bb_gt.x + bb_gt.width / 2);
38 float bb_gt_centroid_y = (bb_gt.y + bb_gt.height / 2);
40 double distance = (double)sqrt(pow(bb_gt_centroid_x - bb_test_centroid_x, 2) + pow(bb_gt_centroid_y - bb_test_centroid_y, 2));
45void SortTracker::update(vector<cv::Rect> detections_cv,
int frame_count,
double image_diagonal, std::vector<float> confidences, std::vector<int> classIds)
47 vector<TrackingBox> detections;
52 for (
unsigned int i = 0; i < detections_cv.size(); i++)
56 tb.
box = cv::Rect_<float>(detections_cv[i]);
59 detections.push_back(tb);
68 for (
unsigned int i = 0; i < detections_cv.size(); i++)
71 tb.
box = cv::Rect_<float>(detections_cv[i]);
74 detections.push_back(tb);
78 int frame_age = frame_count - it->frame;
79 if (frame_age >=
_max_age || frame_age < 0)
89 for (
unsigned int i = 0; i <
trackers.size();)
91 cv::Rect_<float> pBox =
trackers[i].predict();
92 if (pBox.x >= 0 && pBox.y >= 0)
102 detNum = detections.size();
107 for (
unsigned int i = 0; i <
trkNum; i++)
109 for (
unsigned int j = 0; j <
detNum; j++)
128 for (
unsigned int n = 0; n <
detNum; n++)
131 for (
unsigned int i = 0; i <
trkNum; ++i)
140 for (
unsigned int i = 0; i <
trkNum; ++i)
149 for (
unsigned int i = 0; i <
trkNum; ++i)
166 trackers[trkIdx].update(detections[detIdx].box);
167 trackers[trkIdx].classId = detections[detIdx].classId;
168 trackers[trkIdx].confidence = detections[detIdx].confidence;
180 for (
unsigned int i = 0; i <
trackers.size();)
193 for (
unsigned int i = 0; i <
trackers.size();)
201 res.
frame = frame_count;
void update(std::vector< cv::Rect > detection, int frame_count, double image_diagonal, std::vector< float > confidences, std::vector< int > classIds)