Kalman filter for object tracking
-
Use model to get bounding box for each plate
-
get centroid from bounding box
-
compare each detection to know plates
if detection matches known plate, use it to do the kalman update
if detection does not match know plate, create new plate
-
predict location for any know plates that were not detected
We are using yolov5 as the object detection model for measurements.
The model returns two coordinates
centroid coordinates = $ (\frac{x_1 + x_2}{2}, \frac{y_1 + y_2}{2})$
At each measurement, we update the velocity of the object as well as the predicted location.
average velocity:
current time:
displacement between measurements:
change in time:
Step 1: Prediction
- prior.x = prior.x + velocity_x
- prior.y = prior.y + velocity_y
Step 2: Update (if the object is detected)
- z = center of bounding box
- velocity update
- velocity_x = z.x - prev.x
- velocity_y = z.y - prev.y
- prev update
- prev = z
- prior update
- new_x = (prior.x + z.x) / 2
- new_y = (self.prior.y + z.y) / 2)
- prior = (new_x, new_y)
To track multiple objects you need to:
-
correctly assign each measurement to a tracker
-
use the distance formula to figure out which measurement is closest to the pre-update prediction
-
use that measurement to update the prediction
-
if distance to the closest prediction is greater than some threshold, don't assign the measurement to any tracker
note: any trackers that don't receive a measurement for a given frame will skip the update step of the Kalman filter
-
for any unassigned measurements, initialize a new tracker object
- get rid of duplicate measurements
- use distance formula to find the nearest measurement for known plates