A simple algorithm for multi-objects tracking.
The detector can be any model that can detect objects you want to track , such as person, car or animal. Outputs of detector should be: [x, y, a, h]. x, y - the center of bounding box; a - aspect ratio(w / h);
if you set ratio=h/w, the maha distance will be larger. And this will cause the maha distance become bigger.
So, in sort algorithm, author set aspect to be constant.
And, in my experiment i don't consider a and h in computing gating distance.
h - height of bounding box.
-
The first frame should be initialized:
measurement: [x, y, a, h] --> mean: [x, y, a, h, dx, dy, da, dy] & covariance (8, 8).
-
The initial of mean is [x, y, a, h, 0, 0, 0, 0].
-
Propagate current frame state into the next frame by using a linear constant velocity model.
If a target is associated to a detection(measurement), then update the target with kalman filter.
If no detection is associated to the target, just predict the target with linear velocity model without correcting.
-
Predicet next frame state from current frame state through linear velocity model.
-
The data distribution will be changed through transforming, and we call this prediction. $$ mean'=Fk*mean $$
$$ cov'=FkcovFk^T $$
-
Compute maha distance between prediction of this frame and detection of this frame.
-
Assign matched detection to target that we track.
-
Update prediction if it has been matched with kalman gain.
-
Use iou matching to match unconfirmed trackers of age = 1 to remain unmatched detections.
-
Delete trackers of age > 30 or tentative trackers of age > 3.
-
Create trackers with unmatched detections at this frame.
There is a problem in SORT:
if motion uncertainty is slow, maha distance is a comfortable metric.
But, if motion uncertainty is big, maha distance is not stable.
So, DeepSort add a performance descriptor to promote tracking stability.
-
Set your own test_video_path, model_path and target.
test_video_path = 'rtsp://admin:techi@192.168.X.XX/Streaming/Channels/1' # set your own video path model_path = './saved_model_coco' # set your own model path
-
Modify video_pred.py.
# modify code and set your own target # track_target: 0-person; 1-bicycle; 2-car; 7-truck main(test_video_path, model_path, track_target=0, visualize=True)
-
Results.
- DeepSort