OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Wed, 18 Dec 2019 04:30:52 -0600Kalman filter predict both velocity and positionhttp://answers.opencv.org/question/223621/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 postWed, 18 Dec 2019 04:17:14 -0600http://answers.opencv.org/question/223621/kalman-filter-predict-both-velocity-and-position/Comment by LBerger for <p>Hi,
I trying to follow the example, in this site, <a href="https://blog.csdn.net/lwplwf/article/details/74295801">https://blog.csdn.net/lwplwf/article/...</a>, 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:</p>
<pre><code>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)
</code></pre>
<p>Thank you for reading this post</p>
http://answers.opencv.org/question/223621/kalman-filter-predict-both-velocity-and-position/?comment=223622#post-id-223622old [repo](https://github.com/LaurentBerger/KalmanMouse) but may be it can help youWed, 18 Dec 2019 04:30:52 -0600http://answers.opencv.org/question/223621/kalman-filter-predict-both-velocity-and-position/?comment=223622#post-id-223622