20 float in = (bb_test & bb_gt).area();
21 float un = bb_test.area() + bb_gt.area() - in;
26 return (
double)(in / un);
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;
double Solve(std::vector< std::vector< double > > &DistMatrix, std::vector< int > &Assignment)
This class represents the internel state of individual tracked objects observed as bounding box.
SortTracker(int max_age=7, int min_hits=2)
double max_centroid_dist_norm
std::vector< int > dead_trackers_id
std::vector< TrackingBox > frameTrackingResult
std::set< int > unmatchedDetections
std::vector< std::vector< double > > centroid_dist_matrix
std::vector< cv::Point > matchedPairs
double GetCentroidsDistance(cv::Rect_< float > bb_test, cv::Rect_< float > bb_gt)
std::vector< KalmanTracker > trackers
std::vector< cv::Rect_< float > > predictedBoxes
void update(std::vector< cv::Rect > detection, int frame_count, double image_diagonal, std::vector< float > confidences, std::vector< int > classIds)
std::vector< int > assignment
std::set< int > matchedItems
std::set< int > unmatchedTrajectories
double GetIOU(cv::Rect_< float > bb_test, cv::Rect_< float > bb_gt)