danstowell / gmphd

GM-PHD filter implementation in python (Gaussian mixture probability hypothesis density filter)
GNU General Public License v3.0
73 stars 30 forks source link

Does this code work for 2d? #1

Closed chuan137 closed 8 years ago

chuan137 commented 8 years ago

The example seems to be 1d.

danstowell commented 8 years ago

Yes, should do.

chuan137 commented 8 years ago

Here is a snippet of my code for 2d object tracking

birthgmm = [ GmphdComponent(1,  np.array([100,100,0,0]).T, initcovar) ]                                                                                                                                                                   
g = Gmphd(birthgmm, survprob, detecprob, F, Q, H, R, clutterrate)                                                                                                                                                                         

obs = np.array([102, 108]).T                                                                                                                                                                                                              
g.update([ obs ])

somehow, it fails at the update step

danstowell commented 8 years ago

[100,100,0,0] is not 2D, it's 4D

chuan137 commented 8 years ago

Extra 0 meant to be momentum in the state vector. You are indicating they are redundant here?

danstowell commented 8 years ago

Either the state vector is 2D, or the state vector is 4D. Your choice, but you have to be consistent

danstowell commented 8 years ago

Actually wait, I wasn't quite right. The state vector can be different from the observation vector. It depends on the shapes of the matrices that relate them to each other. The easiest way to clarify is if you supply a self-contained complete code example that exhibits the potential problem

danstowell commented 8 years ago

See for example obsnmatrix in syntheticexamplestuff.py - it shows two exmaples: 1D-obs-for-3D-state, and 2D-obs-for-3D-state

chuan137 commented 8 years ago

Thanks, I will look at your example.

chuan137 commented 8 years ago

Turns out I need to make sure the observations are column vectors. It works very well. Thanks for sharing the code.

Besides, I have read your two blog posts about using the filter. You mentioned the 'cold start' problem. Do you have more insights since you wrote the post?

danstowell commented 8 years ago

Great! I'm glad you got it working.

I must confess that I have not used GMPHD much since I originally did this work (summarised in this brief 2012 paper). I don't have much to say about the "cold start" problem, except that it would probably help to use a "forward-backward" approach rather than just a "filter" approach.