Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust kalman filter used for norfair tracker #9538

Merged
merged 3 commits into from
Feb 2, 2024
Merged

Adjust kalman filter used for norfair tracker #9538

merged 3 commits into from
Feb 2, 2024

Conversation

NickM-27
Copy link
Collaborator

After testing I believe that the default values for the kalman filter are not optimal for Frigate.

This is with the current values:

Screen Shot 2024-01-31 at 12 39 28 PM Screen Shot 2024-01-31 at 12 39 36 PM

we can see that the estimate (green) is consistently behind the actual object

with this PR:

Screen Shot 2024-01-31 at 12 41 17 PM Screen Shot 2024-01-31 at 12 41 23 PM

we can see that the estimates are much more consistent with the actual detection.

I spent additional time testing this on other objects and it has performed well in tests

Copy link

netlify bot commented Jan 31, 2024

Deploy Preview for frigate-docs canceled.

Name Link
🔨 Latest commit 71fec2d
🔍 Latest deploy log https://app.netlify.com/sites/frigate-docs/deploys/65bb946f383c68000805dc3e

@blakeblackshear
Copy link
Owner

Can you add a comment or some notes about this param and how it impacts things so we dont forget how we arrived at this value?

@hawkeye217
Copy link
Collaborator

hawkeye217 commented Feb 1, 2024

Nick and I were discussing this a bit yesterday.

A Kalman filter is like a car on the road with cruise control. Several parameters are used to configure it: a position variance, R and Q. The initial position variance is how confident we are in the car's position. It's inverse, so higher is less confident, and so the filter will rely on actually checking the position to get its bearings. Process Q is like hills and bumps on the road. A higher Q means it's more responsive to ups and downs. Then R is like a noise factor, how clearly it interprets the position from the readings vs how much it relies on predictions.

Increasing Q would cause the Kalman filter to rely more on predictions rather than the actual measurements, reducing R would cause it to trust the measurements more.

We reduced R from Norfair's default (4.0) down to 3.4.

https://tryolabs.github.io/norfair/2.2/reference/filter/#norfair.filter.OptimizedKalmanFilterFactory

@blakeblackshear blakeblackshear merged commit 2d0864c into dev Feb 2, 2024
13 checks passed
@NickM-27 NickM-27 deleted the kalman branch February 2, 2024 14:30
mike2307 pushed a commit to mike2307/frigate that referenced this pull request Feb 11, 2024
* Adjust kalman filter

* Add comment

* Formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants