FilterPy 의 built-in function KalmanFilter 사용
KalmanFilter - FilterPy 1.4.4 documentation
sort.py 코드 분석을 통해 우리의 model 에서 가져온 parameter를 sort.py에 연결하여
hungarian algorithm, kalman filter 적용하기
주석으로 분석 진행 중
class KalmanBoxTracker(object):
"""
This class represents the internal state of individual tracked objects observed as bbox.
"""
count = 0
def __init__(self,bbox):
"""
Initialises a tracker using initial bounding box.
"""
#define constant velocity model
#dim_x : size of the state vector
#dim_z : size of the measurement vector
self.kf = KalmanFilter(dim_x=7, dim_z=4)
# F : ndarray (dim_x, dim_x) /state transistion matrix
self.kf.F = np.array([[1,0,0,0,1,0,0],
[0,1,0,0,0,1,0],
[0,0,1,0,0,0,1],
[0,0,0,1,0,0,0],
[0,0,0,0,1,0,0],
[0,0,0,0,0,1,0],
[0,0,0,0,0,0,1]])
# H : ndarray (dim_z, dim_x) /measurement function
self.kf.H = np.array([[1,0,0,0,0,0,0],
[0,1,0,0,0,0,0],
[0,0,1,0,0,0,0],
[0,0,0,1,0,0,0]])
# R : ndarray (dim_z, dim_z), default eye(dim_x) /measurement uncertainty/noise
self.kf.R[2:,2:] *= 10.
# P : ndarray (dim_x, dim_x), default eye(dim_x) /covariance matrix
self.kf.P[4:,4:] *= 1000. #give high uncertainty to the unobservable initial velocities
self.kf.P *= 10.
#Q : ndarray (dim_x, dim_x), default eye(dim_x) /Process uncertainty/noise
self.kf.Q[-1,-1] *= 0.01
self.kf.Q[4:,4:] *= 0.01
#x : ndarray (dim_x, 1), default = [0,0,0…0] /filter state estimate
self.kf.x[:4] = convert_bbox_to_z(bbox) # [x,y,s,r]
# stage 변경시 count 증가
self.time_since_update = 0
self.id = KalmanBoxTracker.count
KalmanBoxTracker.count += 1
self.history = []
self.hits = 0
self.hit_streak = 0
self.age = 0