fix mot id not displaying

This commit is contained in:
jario-jin 2023-08-15 09:21:40 +08:00
parent 151acbe2e3
commit b23ee6d509
1 changed files with 12 additions and 9 deletions

View File

@ -189,6 +189,7 @@ 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.age = 0;
@ -207,6 +208,7 @@ void SORT::update(TargetsInFrame& tgts)
for (int i=0; i<tgts.targets.size(); i++)
{
tgts.targets[i].tracked_id = 0;
tgts.targets[i].has_tid = true;
}
array<int, 100> match_det;
@ -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<pair<int, int> > SORT::_hungarian(vector<vector<double> > costMatrix)
for (int i=0; i<numRows; i++)
{
vector<bool> visited(numCols, false);
_augment(costMatrix, i, rowMatch, colMatch, visited);
this->_augment(costMatrix, i, rowMatch, colMatch, visited);
}
// step4: calculate the matches
matches.clear();
@ -397,7 +400,7 @@ bool SORT::_augment(const vector<vector<double> >& costMatrix, int row, vector<i
if (costMatrix[row][j] == 0 && !visited[j])
{
visited[j] = true;
if (colMatch[j] == -1 || _augment(costMatrix, colMatch[j], rowMatch, colMatch, visited))
if (colMatch[j] == -1 || this->_augment(costMatrix, colMatch[j], rowMatch, colMatch, visited))
{
rowMatch[row] = j;
colMatch[j] = row;