Email: sai-2008@qq.com or akaHaozhengLi@gmail.com
It's hard to do multi-target Kalman tracking in OpenCV because it only provides a single-target version.
All of us know the process of Kalman tracking, it needs a measurement state and a prediction state in each iteration.
The filter actually mix these two states into one state, then it considers the mix-state as the optimal estimate of targets' position.
Now the key problem is:
For example, in (k-1)-th frame, we got N targets, which means we got N Kalman Filters. So we now have N prediction states.
Suppose in k-th frame, we have detected/measured M targets(M != N), then these M measurement states can not match N prediction states.
The result of that is the Kalman Filter iteration can not continue.
That's why "liKalmanTracker" is here.
The algorithm is coded by C++, OpenCV 2.4.9 in Visual Studio 2013.
I coded it as a Class called liKalmanTracker.
Just open the project and run main.cpp, a multi-target Kalman tracking demo will run.
All you need to do is as followed:
API: liKalmanTracker(targetSize, targetName);
API: tracker.track(measurement);
APIs: tracker.print(nFrameCount); tracker.show(dst_tracking, 0); tracker.trackment();
As a result, liKalmanTracker deal with several problems in multi-target Kalman tracking as followed:
In one word, deal with false-rejected and false-accepted problems in multi-target Kalman tracking problem.
It will automatically match measurement states and prediction states, mix them and output the optimal estimate of targets' position.
I build a confidence model for all targets.
The confidence/score means how important one target is. It determins the level of a target to be tracked.
For example, a new appearance target's confidence should be 0.
Another example, if one target can not be detected by the classifier or other algorithm, its confidence should be decreased.
As a result, I manage to build such a model to let liKalmanTracker decise which target should be tracked.
It means new targets appear.
Match N Kalman Filters with N measurement based on mini L2 distance. Targets which successfully matched, confidence increase.
Extend and initialize (M - N) new Kalman Filters, confidence = 0.
Now M == N, cool!
It means targets is leaving or false rejected.
Match M measurement with M Kalman Filters based on mini L2 distance. Targets which successfully matched, confidence increase.
Extend (N - M) measurement with N's prediction states, but confidence decrease.
Now M == N, cool!
It means M match N, cool!
So before 1) to 3), firstly we must deal with false accepted problem.
If some measurement are really far from every Kalman Filters, then just consider them as new Kalman Filters.
So now make 4) as 0). Finish it before step 1).
After all of these step, M measurement states can match N prediction states, and all the Kalman Filters will work well.
Sure!
You can run the demo and get result as the gif below, the liKalmanTracker is tracking 4 targets.
The white rectangle is the ROI, when targets leave the ROI, they will not be detected.
If you want to know more details about the multi-target Kalman traking algorithm, or want to know more about my work,