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

How to use EKF for SORT Algo #273

Open
iamrajee opened this issue Jul 4, 2022 · 0 comments
Open

How to use EKF for SORT Algo #273

iamrajee opened this issue Jul 4, 2022 · 0 comments

Comments

@iamrajee
Copy link

iamrajee commented Jul 4, 2022

Hello Everybody,
I'm using SORT for tracking the bounding boxes detected by YOLO. (code)

The previous implementation involves using KalmanFilter from filterpy, However I would want to replace that with ExtendedKalmanFilter.

Here is my new code, Where my dimension are as:

self.kf = ExtendedKalmanFilter(dim_x=7, dim_z=4)
    self.kf.F = np.array([[1,0,0,0,1,0,0],[0,1,0,0,0,1,0],[0,0,1,0,0,0,1],[0,0,0,1,0,0,0],  [0,0,0,0,1,0,0],[0,0,0,0,0,1,0],[0,0,0,0,0,0,1]])
    self.kf.H = np.array([[1,0,0,0,0,0,0],[0,1,0,0,0,0,0],[0,0,1,0,0,0,0],[0,0,0,1,0,0,0]])

    self.kf.R[2:,2:] *= 10.
    self.kf.P[4:,4:] *= 1000. #give high uncertainty to the unobservable initial velocities
    self.kf.P *= 10.
    self.kf.Q[-1,-1] *= 0.01
    self.kf.Q[4:,4:] *= 0.01

    self.kf.x[:4] = convert_bbox_to_z(bbox)self.kf = ExtendedKalmanFilter(dim_x=7, dim_z=4)
    self.kf.F = np.array([[1,0,0,0,1,0,0],[0,1,0,0,0,1,0],[0,0,1,0,0,0,1],[0,0,0,1,0,0,0],  [0,0,0,0,1,0,0],[0,0,0,0,0,1,0],[0,0,0,0,0,0,1]])
    self.kf.H = np.array([[1,0,0,0,0,0,0],[0,1,0,0,0,0,0],[0,0,1,0,0,0,0],[0,0,0,1,0,0,0]])

    self.kf.R[2:,2:] *= 10.
    self.kf.P[4:,4:] *= 1000. #give high uncertainty to the unobservable initial velocities
    self.kf.P *= 10.
    self.kf.Q[-1,-1] *= 0.01
    self.kf.Q[4:,4:] *= 0.01

    self.kf.x[:4] = convert_bbox_to_z(bbox)

And calling the function as

self.kf.update(convert_bbox_to_z(bbox), HJacobian=self.H_of, Hx=self.Hx)

Where I don't really don't know how to write H_of and Hx functions. Thus it would be great if you could help me write these two functions. My current dummy definition is as below:

def H_of(x,y):
     H = np.array([[1,0,0,0,0,0,0],
                [0,1,0,0,0,0,0],
                [0,0,1,0,0,0,0],
                [0,0,0,1,0,0,0]])
    return H
def Hx(x,y):
    Hx = np.array([[0],
                [0],
                [0],
                [0]])
    return Hx

Thanks!

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

1 participant