Kalman filter predict both velocity and position

asked 2019-12-18 04:17:14 -0600

MingCheng gravatar image

updated 2019-12-18 08:39:29 -0600

supra56 gravatar image

Hi, I trying to follow the example, in this site, https://blog.csdn.net/lwplwf/article/..., through observation, the output (current_prediction) is a 4x1 matrix, where 1st and 2nd element stores the predicted x and y pixel coordinates. However, when I trying to add velocity for x and y into the "current_measurement", (so it becomes 4x1 matrix instead of 2x1). I did change the other parameters, after I increase the dimension of "current_measurement", but the when I trying to run the program, I still get error messages, "OpenCV Error: Assertion failed (C.type() == type) in gemm, file /tmp/binarydeb/ros-kinetic-opencv3-3.3.1/modules/core/src/matmul.cpp, line 1588" Below is the lines of code that I changed:

last_mes = current_mes = np.array((4,1),np.float32) 
last_pre = current_pre = np.array((4,1),np.float32) 
current_mes = np.array([[np.float32(x)],[np.float32(y)],[1.0],[1.0]]) # just a sample velocity for dx dy
kalman = cv2.KalmanFilter(4,4) 
kalman.measurementMatrix = np.array([[1, 0, 1, 0], [0, 1, 0, 1],[0, 0, 0, 0],[0, 0, 0, 0]],np.float32)

Thank you for reading this post

edit retag flag offensive close merge delete

Comments

old repo but may be it can help you

LBerger gravatar imageLBerger ( 2019-12-18 04:30:52 -0600 )edit