kl3m3n's blog

Community Browser
cancel
Showing results for 
Search instead for 
Did you mean: 

Re: Kalman filter (OpenCV) and MeanShift (Labview) tracking

Klemen
Active Participant

Hello,

the idea of using a Kalman filter for object tracking is to attenuate the noise associated with the position detection of the object based on estimating the system state. It can also be used to predict the position based on the state transition model when no new measurements are available. The Kalman filter has two phases - the prediction and the correction phase. In order to familiarize yourself with the Kalman filter, I recommend reading the following paper:

"An Introduction to the Kalman Filter" by Greg Welch and Gary Bishop.

There are also numerous other resources regarding the Kalman filter online (for example: http://bilgin.esme.org/BitsBytes/KalmanFilterforDummies.aspx), so I will not dwell on the mathematics behind the algorithm.

In order to use the Kalman filter, the object must be moving with constant velocity or accerelation (depends on the state transition model). The example I am showing here uses a constant velocity model, although you can rebuild the C++ code to consider the constant accerelation model (see the attached C++ code). Remember to modify the parameters of the Kalman object constructor in addition to the state transition model, when alternating between the constant velocity and accerelation models.

Below is the mouse tracking example (see the attachment for the code):

test2.png

Figure 1. Kalman mouse tracker (red curve - the mouse position, white curve - corrected/estimated state)

Additionally, I've implemented the Kalman filter on meanshift object tracking (see the attachment for the code):

test1.png

Figure 2. Object tracking using meanshift and Kalman filter (red curve - meanshift algorithm, black curve - corrected/estimated state).

The Kalman filter is the OpenCV's (2.4.9) implementation, called in Labview (2013) as a .dll. I am attaching the C++ source code, the .dll and the two examples shown in the two figures above. There are some additional comments in the code.

Hope this helps someone.

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
Comments
南京
Member

Klemen,

      Your examples about the vision teaches a lot useful knowledges. I hope you can give more examples.Thank very much!

Best regards

Ted

Change the world
xuexue0224
Member

Hey thank you for sharing the code. I was running your .dll file on Labview 2015, it keeps reporting error:

 

The library specified for this node cannot be found or cannot be loaded. Right-click the Call Library Function node and select Configure, then choose the correct library name or path.

 

Then I chose the attached "KalmanFilter_DLL.dll", and it still has the same errors. 

 

Please let me know what you think. 

 

Thank you,

Xue Yang