Skip to content

Commit ff5de43

Browse files
committed
fix: multiply gain for new class
1 parent e9fc633 commit ff5de43

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

perception/multi_object_tracker/src/tracker/model/tracker_base.cpp

+9-18
Original file line numberDiff line numberDiff line change
@@ -65,35 +65,26 @@ void Tracker::updateClassification(
6565
// 5. Normalize the probability
6666

6767
const double gain = 0.05;
68-
const double gain_inv = 1.0 - gain;
69-
const double decay = gain_inv;
70-
68+
const double decay = 1.0 - gain;
69+
// decal all existing probability
70+
for (auto & class_ : classification_) {
71+
class_.probability *= decay;
72+
}
7173
for (const auto & new_class : classification) {
7274
bool found = false;
7375
for (auto & old_class : classification_) {
7476
// Update the matched classification probability with a gain
7577
if (new_class.label == old_class.label) {
76-
old_class.probability = old_class.probability * gain_inv + new_class.probability * gain;
78+
old_class.probability += new_class.probability * gain;
7779
found = true;
7880
break;
7981
}
8082
}
8183
// If the label is not found, add it to the classification list
8284
if (!found) {
83-
classification_.push_back(new_class);
84-
}
85-
}
86-
// If the old class probability is not found, decay the probability
87-
for (auto & old_class : classification_) {
88-
bool found = false;
89-
for (const auto & new_class : classification) {
90-
if (new_class.label == old_class.label) {
91-
found = true;
92-
break;
93-
}
94-
}
95-
if (!found) {
96-
old_class.probability *= decay;
85+
auto adding_class = new_class;
86+
adding_class.probability *= gain;
87+
classification_.push_back(adding_class);
9788
}
9889
}
9990

0 commit comments

Comments
 (0)