opencv卡尔曼过滤器无法处理遮挡

时间:2020-03-26 13:42:24

标签: python opencv kalman-filter

当我尝试使用opencv卡尔曼滤波器跟踪目标时。我的初始设置如下:deltaTime = 1/30 #time大约是单帧状态= np.zeros((4,1),np.float32)measure = np.zeros((2,1),np.float32 )

kalman = cv2.KalmanFilter(4,2,0)#控制向量= 0,假设为线性运动。

kalman.measurementMatrix = np.array([[1,0,0,0],[0,1,0,0]],np.float32)

kalman.transitionMatrix = np.array([[1,0,deltaTime,0],[0,1,0,deltaTime],[0,0,1,0],[0,0,0,1 ]],np.float32)

kalman.processNoiseCov = np.array([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1 ]],np.float32)* 0.03当存在对物体的测量/观察时,我能够正确地跟踪目标。但是,当物体丢失在帧中时,卡尔曼滤波器的预测在最后一个已知位置保持不变目标。意思是,在我的情况下,卡尔曼滤波器的预测组件不起作用。检测代码和未检测代码如下所示:

        ***state = kalman.predict() #get the new predicted state from the previous state
        if ini.detection==1:
            ini.measureCentreV2[0] = currentX
            ini.measureCentreV2[1] = currentY
            state = kalman.correct(ini.measureCentreV2) #correct the newly predicted state, and use this as the next input for the prediction
        else: #when no detection, velocity will update with an interval of a single seconds 
            state[2]=ini.latestVelX 
            state[3]=ini.latestVelY

            kalman.statePost = state***

基本上,问题是,我的代码能够在没有任何障碍物的情况下很好地跟踪目标,但是一旦遇到任何障碍,预测结果将停止更改,并始终为目标提供最后的看见位置。直到目标再次出现,跟踪才会恢复。

0 个答案:

没有答案
相关问题