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

Wrong use of prediction when no measurements are available #18

Open
wartek69 opened this issue Oct 6, 2023 · 1 comment
Open

Wrong use of prediction when no measurements are available #18

wartek69 opened this issue Oct 6, 2023 · 1 comment

Comments

@wartek69
Copy link

wartek69 commented Oct 6, 2023

Hi,
Thank you for the clear code & useful repo!
I think there is a small mistake in the usage of the Kalmann filter update step.

        if not flag:  # update using prediction
            self.b = self.lastResult
        else:  # update using detection
            self.b = b
        C = np.dot(self.A, np.dot(self.P, self.A.T)) + self.R
        K = np.dot(self.P, np.dot(self.A.T, np.linalg.inv(C)))


        self.u = np.round(self.u + np.dot(K, (self.b - np.dot(self.A,
                                                              self.u))))

In the snippet above you are using a prediction as a measurement when the flag is set. I suppose this was done to keep predicting the vessel motions when a detection disappears for a short amount of time. I do not think it is correct since the prediction will then be overconfident as it will be using the measurement noise instead of the process noise.

The correct way of handling a situation when no detections are available for some frames is to use the predict step instead of the update step.

Is my understanding correct or am I missing something?
The link to the code above is here:
https://github.com/srianant/kalman_filter_multi_object_tracking/blob/625e6c0965bb777a888ab46ed70978ad9fc93774/kalman_filter.py#L68C1-L103C22

Br
Alex

@devnim
Copy link

devnim commented Nov 7, 2023

Hi Alex, could you please how you would do it with code?

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

No branches or pull requests

2 participants