Skip to content

Commit 0ce3bcc

Browse files
author
干磊
committed
bug fix:对外输出时如果有观测值则使用观测值;如果没有观测值就使用预测值
1 parent 98b2908 commit 0ce3bcc

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

include/KalmanTracker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class KalmanTracker
4444
StateType get_state();
4545
StateType get_rect_xysr(float cx, float cy, float s, float r);
4646

47-
StateType lastRect;
47+
StateType latestRect; // 当前跟踪序列最新的bbox坐标。在对外输出时:如果有观测值则使用观测值;如果没有观测值就使用预测值
4848
static int kf_count; // 每次调用构造函数kf_count就会加1
4949

5050
int m_max_missing_observed_num = 2; // 允许连续跟丢的最大次数,比如101有效、1001有效、10001则无效

src/KalmanTracker.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,16 @@ StateType KalmanTracker::predict()
5050

5151
StateType predictBox = get_rect_xysr(p.at<float>(0, 0), p.at<float>(1, 0), p.at<float>(2, 0), p.at<float>(3, 0));
5252

53+
latestRect = predictBox; // 使用最近一次预测值更新latestRect变量
54+
5355
m_history.push_back(predictBox);
5456
return m_history.back(); // 返回对vector最后一个元素的引用
5557
}
5658

5759
// Update the state vector with observed bounding box.
5860
void KalmanTracker::update(TrackingBox track_box)
5961
{
60-
this->lastRect = track_box.box;
62+
latestRect = track_box.box; // 使用最近一次观测值更新latestRect变量
6163

6264
m_time_since_update = 0; // 每次观察到目标就重置为0
6365
m_history.clear();

src/track.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ void TRACKER::update(const vector<TrackingBox> &detFrameData)
139139
}
140140

141141
// 3.3.3,更新未匹配上的跟踪序列
142-
// 由于之前已经单独调用过predict函数,所以不再进行任何操作
142+
// 由于之前已经单独调用过predict函数,此处直接用预测的结果进行tracker的跟踪
143+
// 在predict和update函数中都对latestRect的值进行了更新,此处不再单独操作
143144

144145
// 3.3.4,remove dead tracklet
145146
for (auto it = trackers.begin(); it != trackers.end();)
@@ -170,7 +171,7 @@ vector<TrackingBox> TRACKER::getReport(){
170171
if (it->m_observed_num >= min_hits)
171172
{
172173
TrackingBox res;
173-
res.box = it->lastRect;
174+
res.box = it->latestRect; // 如果有观测值则使用观测值;如果没有观测值就使用预测值
174175
res.track_id = it->m_id + 1; // +1 as MOT benchmark requires positive
175176
res.frame_id = frame_count;
176177
res.obj_conf = it->obj_conf;

0 commit comments

Comments
 (0)