wmuron / motpy

Library for tracking-by-detection multi object tracking implemented in python
MIT License
510 stars 60 forks source link

Velocity tracking #16

Closed Dmytro-Shvetsov closed 3 years ago

Dmytro-Shvetsov commented 3 years ago

Hello, I was woundering if there's a way of extending existing functionality by adding velocity parameter to the track outputs. If it is possible, could you guide me how I should change motpy/motpy/model.Model or maybe add a new preset to motpy/motpy/model.ModelPreset . I assume the speed of my objects to track is constant

Thank you in advance!

wmuron commented 3 years ago

Hi Dmytro. Please note that for order >= 1, the velocity (horizontal and vertical) is a part of the object state. I've prepared an example presenting the velocity here https://github.com/wmuron/motpy/compare/development...test-velocity (run examples/2d_multi_object_tracking.py example)

Dmytro-Shvetsov commented 3 years ago

@wmuron Excellent example! I dug into Kalman filters a bit more since I've posted the question and I tried to modify some parameters to measure a real km/h velocity of a vehicle. Am I understanding this correctly that your example evaluates pixel velocity and to solve my problem I would have to: 1) project bounding boxes on the ground 2) feed obtained boxes to the tracker and get the pixel velocity 3) multiply the velocity by meters per pixel constant given the real environment distance

wmuron commented 3 years ago

@Dmytro-Shvetsov One possible solution to project boxes on the ground is to calculate and use homography matrix to project the scene (along with each detection or track) to bird-eye view. Obviously, you'll still need to get obtain some kind of calibration data (e.g. width of the lane, lane marking length or some other known distances etc.) to calculate a relation of pixels (in bird eye view) to meters. You can apply bird-eye transform on detections and track the transformed detections in bird-eye space or track in image space and transform active tracks to bird eye view. A couple of notes:

Dmytro-Shvetsov commented 3 years ago

@wmuron Got it. Thanks a lot!