sort
sort copied to clipboard
KalmanTracker 'history' is reset in update
self.history is reset in KalmanTracker().update()
func:
https://github.com/abewley/sort/blob/54e63a7e432491619a48678bda6f05cc3bd12859/sort.py#L109
This removes history when a new measurement is available but save state when only doing prediction.
Also, here in predict()
:
https://github.com/abewley/sort/blob/54e63a7e432491619a48678bda6f05cc3bd12859/sort.py#L125
Property history
is fed with x
predicted. But when the tracker is updated with a new measurement, the state x
is refined and should replace the old x
predicted no?
As predict()
is always followed by update()
this should look like this:
def update(self, bbox):
"""
Updates the state vector with observed bbox.
"""
self.time_since_update = 0
self.hits += 1
self.hit_streak += 1
self.kf.update(convert_bbox_to_z(bbox))
self.history[-1] = convert_bbox_to_z(self.kf.x) # history should be previously init with convert_bbox_to_z(bbox) to not be empty
def predict(self):
"""
Advances the state vector and returns the predicted bounding box estimate.
"""
if((self.kf.x[6]+self.kf.x[2])<=0):
self.kf.x[6] *= 0.0
self.kf.predict()
self.age += 1
if(self.time_since_update>0):
self.hit_streak = 0
self.time_since_update += 1
self.history.append(convert_x_to_bbox(self.kf.x))
return history[-1]