balzer82 / Kalman

Some Python Implementations of the Kalman Filter
1.04k stars 366 forks source link

dt paramter in kalman filter #15

Open chokkarapu opened 4 years ago

chokkarapu commented 4 years ago

Hi Author,

Currently Im tracking the object with constant velocity model. The parameter "dt" is time interval as we know in kalman filer.

My query is how to compute or choose optimal value of dt?? Im detecting object using computer vision algorithm at frame rate of 20FPS... So I have computed dt = 20/30 (MyAlgo_FPS/CameraCapture_FPS). Is my computation is right ?

I eagerly wait for prompt response.

Thanks, Anil.

UnePierre commented 4 years ago

Hi Anil,

If your algorithm runs at 20fps, that means dt=1/20=0.05 [seconds].

But if your main sensor (camera) runs at 30fps, I strongly advice you to go for dt=1/30! Interpolation before a Kalman filter is hard to get right, so try to have your object tracking use the full 30fps, too.

Now you say, that your input comes from something a camera can see. In that case, please consider a model of constant acceleration: If your object does not leave the video frame, it has to change speed/velocity (unless your camera was in space, but I guess you wouldn't ask such questions then.) Constant acc is good for things that a human moves, fall down et cetera -- all the regular cases in school physics.

Greetings and good luck with your model!

chokkarapu commented 4 years ago

Hi Anil,

If your algorithm runs at 20fps, that means dt=1/20=0.05 [seconds].

But if your main sensor (camera) runs at 30fps, I strongly advice you to go for dt=1/30! Interpolation before a Kalman filter is hard to get right, so try to have your object tracking use the full 30fps, too.

Now you say, that your input comes from something a camera can see. In that case, please consider a model of constant acceleration: If your object does not leave the video frame, it has to change speed/velocity (unless your camera was in space, but I guess you wouldn't ask such questions then.) Constant acc is good for things that a human moves, fall down et cetera -- all the regular cases in school physics.

Greetings and good luck with your model!

Thanks you for your valuable inputs. Yes, i'm planning to move to constant acceleration model.

Im having input of image sensor only, for constant acceleration model, Do i need to have any inputs(such as velocity or acceleration) from other sensors as well ?? Or just image sensor input is fine..

UnePierre commented 4 years ago

The nice thing about Kalman filters is, that they interpolate, have a clue about the actual precision/reliability of the signal (deviation), and that they can cope with sensor fusion. If you have only one sensor, there is nothing to fuse, but that doesn't reduce the other advantages.

If however you can come up with more sensors with reasonable effort, a Kalman filter helps you to "make the best of it" (in terms of minimized quadratic errors): e.g. the precision can be improved in most cases.

Maybe take a look at some literature about filtering? The Wikipedia articles about Kalman filters, and extended Kalman filters are very high-level, but I think they reference some basic read-up as well.