measurement_noise = 10.0 process_noise = 0.1
We can now initialize the Kalman filter using these parameters:
kalman = cv2.KalmanFilter(4, 2) kalman.transitionMatrix = F kalman.measurementMatrix = H kalman.processNoiseCov = np.eye(4, dtype=np.float32)*process_noise kalman.measurementNoiseCov = np.eye(2, dtype=np.float32)*measurement_noise kalman.errorCovPost = np.eye(4, dtype=np.float32) kalman.statePost = state
Step 2: Update the Kalman Filter
The next step is to update the Kalman filter using the new observation. We will simulate the observation by adding some noise to the true position of the object:
observation = true_position + np.random.randn(2)*measurement_noise
We can now update the Kalman filter using this observation: