Ask Your Question
0

Multi-tracking Kalman Filter Problem

asked 2019-02-01 08:50:20 -0600

Gab gravatar image

updated 2019-02-01 08:52:29 -0600

I am attempting to perform a multi-tracking by means Kalman filter algorithm. I declared it as

KalmanFilter kf[2]

and I initialized it as

for(int i=0; i<kalNum; i++){ 
  kf[i].init(stateSize, measSize, contrSize, type); . . .

The problem is that when I update the filter, or I use statePost function like here

for(index=0;index<2;index++)
  kf[index].statePost = state[index];

where state variable is different for each kf tracked object, the algorithm updates BOTH kf[0] and kf[1] with the same value, actually the last one,state[1], and therefore I lose track of the first object I track. Indeed if I call

kf[0].statePost.at<float>(0)
kf[1].statePost.at<float>(0)

The result is the same!! How it is possible? They are two different c++ objects! I'm sure the indexing is correct!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2019-02-01 22:00:32 -0600

Tetragramm gravatar image

I'm almost certain you're making shallow Mat copies somewhere.

For example: The line

kf[index].statePost = state[index];

does not copy the values in state to statePost. It simply causes statePost to point at state[index]. I am almost certain that at some point you did something similar with the state[] array, so that instead of two different sets of values, you just overwrote the first, with the second.

edit flag offensive delete link more

Comments

Actually I made this command for the initialization

kf[index].statePost = state.clone();

but still some issue is present. How can I make it?

Gab gravatar imageGab ( 2019-02-04 07:30:47 -0600 )edit

And did you make sure the values of state[0] and state[1] are different?

Tetragramm gravatar imageTetragramm ( 2019-02-04 23:14:56 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-02-01 08:50:20 -0600

Seen: 388 times

Last updated: Feb 01 '19