From b23ee6d5091aedc9582a33320e8d5e2b22eea11f Mon Sep 17 00:00:00 2001 From: jario-jin Date: Tue, 15 Aug 2023 09:21:40 +0800 Subject: [PATCH] fix mot id not displaying --- algorithm/mot/sv_mot.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/algorithm/mot/sv_mot.cpp b/algorithm/mot/sv_mot.cpp index a326a0d..609cc07 100644 --- a/algorithm/mot/sv_mot.cpp +++ b/algorithm/mot/sv_mot.cpp @@ -130,7 +130,7 @@ KalmanFilter::~KalmanFilter() pair, Matrix > KalmanFilter::initiate(Vector4d &bbox) { Matrix mean; - mean << bbox(0), bbox(1), bbox(2)/bbox(3), bbox(3), 0, 0, 0, 0; + mean << bbox(0), bbox(1), bbox(2) / bbox(3), bbox(3), 0, 0, 0, 0; VectorXd stds(8); stds << 2 * this->_std_weight_position * mean(3), 2 * this->_std_weight_position * mean(3), 0.01, 2 * this->_std_weight_position * mean(3), \ 10 * this->_std_weight_vel * mean(3), 10 * this->_std_weight_vel * mean(3), 1e-5, 10 * this->_std_weight_vel * mean(3); @@ -152,7 +152,7 @@ pair, Matrix > KalmanFilter::update(Matrix_H.transpose() * S.inverse(); VectorXd measurement(4); - measurement << box.x1, box.y1, (box.x2-box.x1)/(box.y2-box.y1), box.y2-box.y1; + measurement << box.x1, box.y1, (box.x2-box.x1) / (box.y2-box.y1), box.y2-box.y1; Matrix new_mean = mean + Kalman_gain * (measurement - this->_H * mean); Matrix new_covariances = (MatrixXd::Identity(8, 8) - Kalman_gain * this->_H) * covariances; return make_pair(new_mean, new_covariances); @@ -189,14 +189,15 @@ void SORT::update(TargetsInFrame& tgts) tracklet.id = ++ this->_next_tracklet_id; // cout << tracklet.id << endl; tgts.targets[i].tracked_id = this->_next_tracklet_id; + tgts.targets[i].has_tid = true; - tracklet.bbox << box.x1,box.y1,box.x2-box.x1,box.y2-box.y1; // x,y,w,h + tracklet.bbox << box.x1, box.y1, box.x2-box.x1, box.y2-box.y1; // x,y,w,h tracklet.age = 0; tracklet.hits = 1; tracklet.misses = 0; // initate the motion pair, Matrix > motion = kf.initiate(tracklet.bbox); - tracklet.mean=motion.first; + tracklet.mean = motion.first; tracklet.covariance = motion.second; this->_tracklets.push_back(tracklet); @@ -207,6 +208,7 @@ void SORT::update(TargetsInFrame& tgts) for (int i=0; i match_det; @@ -241,7 +243,7 @@ void SORT::update(TargetsInFrame& tgts) int detectionIndex = match.second; if (trackletIndex >= 0 && detectionIndex >= 0) { - if(iouMatrix[match.first][match.second] >= 0) + if (iouMatrix[match.first][match.second] >= 0) { sv::Box box; tgts.targets[detectionIndex].getBox(box); @@ -261,7 +263,7 @@ void SORT::update(TargetsInFrame& tgts) // create new tracklets for unmatched detections for (int i = 0; i < tgts.targets.size(); i++) { - if (match_det[i]==-1) + if (match_det[i] == -1) { sv::Box box; tgts.targets[i].getBox(box); @@ -278,6 +280,7 @@ void SORT::update(TargetsInFrame& tgts) tracklet.covariance = new_covariance; tgts.targets[i].tracked_id = this->_next_tracklet_id; + tgts.targets[i].has_tid = true; this->_tracklets.push_back(tracklet); } } @@ -371,7 +374,7 @@ vector > SORT::_hungarian(vector > costMatrix) for (int i=0; i visited(numCols, false); - _augment(costMatrix, i, rowMatch, colMatch, visited); + this->_augment(costMatrix, i, rowMatch, colMatch, visited); } // step4: calculate the matches matches.clear(); @@ -383,7 +386,7 @@ vector > SORT::_hungarian(vector > costMatrix) { for (auto& match : matches) { - swap(match.first,match.second); + swap(match.first, match.second); } } return matches; @@ -397,7 +400,7 @@ bool SORT::_augment(const vector >& costMatrix, int row, vector_augment(costMatrix, colMatch[j], rowMatch, colMatch, visited)) { rowMatch[row] = j; colMatch[j] = row;