@@ -65,35 +65,26 @@ void Tracker::updateClassification(
65
65
// 5. Normalize the probability
66
66
67
67
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
+ }
71
73
for (const auto & new_class : classification) {
72
74
bool found = false ;
73
75
for (auto & old_class : classification_) {
74
76
// Update the matched classification probability with a gain
75
77
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;
77
79
found = true ;
78
80
break ;
79
81
}
80
82
}
81
83
// If the label is not found, add it to the classification list
82
84
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);
97
88
}
98
89
}
99
90
0 commit comments