Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Kalman filter predict both velocity and position

Hi, I trying to follow the example, in this site, https://blog.csdn.net/lwplwf/article/details/74295801, 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

Kalman filter predict both velocity and position

Hi, I trying to follow the example, in this site, https://blog.csdn.net/lwplwf/article/details/74295801, 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: 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) 0]],np.float32)

Thank you for reading this post