1 | initial version |
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.