2D motion estimation using Python, OpenCV & Kalman filtering

安稳与你 提交于 2019-12-04 16:34:17

I am not sure if I can explain this here; but I will have a shot. Kalman filter is nothing but a prediction-measurement (correction) based loop.

You have your initial state (position and velocity) after two images:

X0 = [x0 v0] 

where v0 is the flow between image1 and image2.

and x0 is the position at image2.

Make an assumption (like constant velocity model). Under constant velocity assumption, you will predict this object will move to X1 = A* X0 where A is found from constant velocity model equations:

x1 = x0 + v0*T  
v1 = v0

=> X1 = [x1 v1] 
      = [1 T ; 0 1] * [x0 v0]
      = [1 T ; 0 1] * X0

T is your sampling time (generally taken as the frame rate if used with cameras). You need to know the time difference of your images here.

Later, you are going to correct this assumption with the next measurement (load image3 here and obtain v1' from flow of image2 and image3. Also take x1' from image3).

X1' = [x1' y1'] 

For a simpler version of KF, find the average point as the estimation, i.e.

~X1 = (X1 + X1')/2. 

If you want to use the exact filter, and use kalman gain and coveriance calculations, I'd say you need to check out the algorithm, page 4. Take R small if your images are accurate enough (it is the sensor noise).

The ~X1 you will find takes you to the start. Replace initial state with ~X1 and go over same procedure.

If you check the opencv doc, the algorithm might already be there for you to use.

If you are not going to use a camera and opencv methods; I would suggest you to use MATLAB, just because it is easier to manipulate matrices there.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!