GithubHelp home page GithubHelp logo

Compute vehicle speed/velocity about norfair HOT 4 CLOSED

pg37013 avatar pg37013 commented on September 26, 2024
Compute vehicle speed/velocity

from norfair.

Comments (4)

aguscas avatar aguscas commented on September 26, 2024

Hello @pg37013 . Assuming that your Detection instances in your detections list have the pixel coordinates of its points, then the estimated velocity returned by object.estimate_velocity will be in pixels/frame (so, how many pixels in the horizontal and vertical directions does the tracked point moves between consecutive frames).

To convert it to km/h, you will need some reference length relating pixels to kilometers (for example, if you know the real size of the objects you detected, you can use that). Secondly, you also need the FPS of the video to relate the time between consecutive frames and an hour.

Please, if you need more help or guidance, don't hesitate to ask.

from norfair.

pg37013 avatar pg37013 commented on September 26, 2024

Hello @aguscas

So, suppose that I have velocities = object.estimate_velocity. How can I convert that to km/h?

If I know the real size of an object, lets say: width= x m and height=y m and the fps variable. How can I make de conversion?

from norfair.

aguscas avatar aguscas commented on September 26, 2024

So, you know the width in meters (x_meters m), and also you know it in pixels (x_pixels pixels), and similarly for the height.
width = x_meters m = x_pixels pixels
height = y_meters m = y_pixels pixels

Now, let's relate the velocity units meters/second with pixels/frame :
pixels/frame = (pixels/meters) * (meters/second) * (second/frame) = (pixels/meters) * (1/fps) * (meters/second)

So the velocity can be expressed as
velocity = velocity_in_pixels_per_frame * pixels/frame = velocity_in_pixels_per_frame * (pixels/meters) * (1/fps) * (meters/second)

So the velocity in meters per second is:
velocity_in_meters_per_second = velocity_in_pixels_per_frame * (pixels/meters) * (1/fps)

So in particular, looking in the horizontal and in the vertical directions:

horizontal_velocity_in_meters_per_second = horizontal_velocity_pixels_per_frame * (x_pixels/x_meters) * (1/fps)
vertical_velocity_in_meters_per_second = vertical_velocity_pixels_per_frame * (y_pixels/y_meters) * (1/fps)

In summary, just compute:
object.estimate_velocity @ np.diag( [(x_pixels/x_meters), (y_pixels/y_meters)] ) /fps

If this answer is not clear enough, please tell me

from norfair.

aguscas avatar aguscas commented on September 26, 2024

Will close this issue due to inactivity. Feel free to create another one if this was still unclear

from norfair.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.