norfair icon indicating copy to clipboard operation
norfair copied to clipboard

Why is "dt" always equal to 1?

Open ltiseni94 opened this issue 2 years ago • 3 comments

I was trying to understand how to tune the FilterSetup values R, Q, and P for my application.

After having a closer look to how the filter works, I have started wondering why, in the function "create_filter", inside the "filter.py" module, the "dt" value is set to 1. Shouldn't "dt" be dependent on the period of time after which the tracker.update() method is called again?

If I understood correctly, having dt=1 means that we have a fixed period of 1 second between subsequent predictions. However, the real period depends on the application.

I think this value should be at least tunable by the user, depending on the application. Probably, it would be even better if the time after two subsequent calls of the filter.predict() method could be considered to update the filter.F matrix accordingly at each new tracker step.

Hope this helps you, congrats on this really nice package!

ltiseni94 avatar Apr 28 '22 13:04 ltiseni94

Hey thanks for the feedback! I interpreted dt=1 as it referring to one frame, not one second, but to be honest I haven't given it too much thought; and the need to change it hasn't appeared. What would be your use case for this?

joaqo avatar May 13 '22 19:05 joaqo

Hi,

I think period may be just 1 for simple applications, but any application with non-uniform sampling should be able to define a non-integer non-constant temporal difference between steps (and dt should be equal). This should influence tracker_step, and the kalman matrices/equations (as discussed here and here).

The required changes should be backward compatible with the default of 1.

My use case is a detector that's based on comparing two frames, so an object appearing in frame K, may be detected during frame K (compared to the previous frame K-1), during frame K+1 (while frame K is the previous reference frame), both, or not at all. I thought I'll make two updates every frame, one with a very short period, and one with period almost equal to 1.

If these changes are desirable I will consider working on a PR. Either way, thanks for a great package!

berebid avatar Jun 02 '22 13:06 berebid

Hi @berebid sorry for the late response, we were focused on some new features.

If I understood correctly you have a detector that makes the prediction by looking at 2 consecutive frames, what I don't understand is why that translates into 2 updates every frame.

I would imagine something like this could work, but I'm probably missing something

previous_frame = None
for current_frame in video:
    if previous_frame is not None:
        detections_on_current_frame = your_detector(previous_frame,current_frame)
        tracker.update(detections_on_current_frame)
    previous_frame = current_frame

javiber avatar Sep 01 '22 21:09 javiber

Closing due to lack of activity. Initial question seems to have been answered

javiber avatar Oct 17 '22 15:10 javiber

If we set dt=2, can we predict the position of objects in two frame later? Or for dt=3, predict the position of an object in 3 second later?

Mr-Akbari avatar Dec 21 '22 11:12 Mr-Akbari