# Estimation of an objects velocity in a video

**URL:** <https://forum.opencv.org/t/estimation-of-an-objects-velocity-in-a-video/16118>\
**Category:** Python\
**Tags:** calib3d, optflow\
**Created:** [January 11, 2024, 1:42am UTC](https://forum.opencv.org/t/estimation-of-an-objects-velocity-in-a-video/16118 "2024-01-11T01:42:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bjr1973](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/bjr1973/32/9465_2.png) [@bjr1973](https://forum.opencv.org/u/bjr1973)\
**Post date:** [January 11, 2024, 1:42am UTC](https://forum.opencv.org/t/estimation-of-an-objects-velocity-in-a-video/16118/1 "2024-01-11T01:42:00Z")

</div>

I would like to calculate the velocity that the horse is moving in a video like below  
 ![b1ebe5_fe12fb24ca1743388c58938aa44577c6~mv2](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/3/3a2e521b0168f15a2a2eee1c8984ae638addc057.gif)  
I have a known distance on the horse itself so I can calculate the distances on the horse, but as the camera is ‘walking with’ the horse, I am unsure how to calculate the velocity of the horse (I presumed Optical Flow?). Any ideas appreciated

---

<div class="post-metadata">

**Author:** ![Alejandro\_Silvestri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/alejandro_silvestri/32/357_2.png) [@Alejandro\_Silvestri](https://forum.opencv.org/u/Alejandro_Silvestri)\
**Post date:** [January 12, 2024, 1:05pm UTC](https://forum.opencv.org/t/estimation-of-an-objects-velocity-in-a-video/16118/2 "2024-01-12T13:05:18Z")

</div>

Here are some ideas:

Yes, you can use optical flow or any feature2d matching to get the background velocity in pixels/frame. You can average the velocity vectors over the background, you can use a ROI to avoid the vector over the horse.

For the speed in m/s you need more info, like the distance in meters from frame’s left to right, and the time between frames (fps inverse). With this data you can scale pixels/frame to m/s .

---

<div class="post-metadata">

**Author:** ![Steve\_in\_Denver](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Steve\_in\_Denver](https://forum.opencv.org/u/Steve_in_Denver)\
**Post date:** [January 31, 2024, 5:25pm UTC](https://forum.opencv.org/t/estimation-of-an-objects-velocity-in-a-video/16118/3 "2024-01-31T17:25:07Z")

</div>

Is the camera only translating in the same direction as the horse? (no zoom or rotation?) If so, is it possible to know how how fast the camera is moving (like is it on a robotic platform, or something with a speedometer of sorts) If so you can use that as the baseline speed of the horse, then adjust based on the position of the horse in the image (scaled by the known “distances on the horse”)

Just a different approach to consider.
