Ask Your Question

Revision history [back]

If you are able to detect and track cars and you know the real distance between, then should be an easy task.

If you want velocity in km/h, you need to transform the time T from total frames to hours.

For that you have to calculate the framerate of your videostream, for which I point you to this answer of mine where I give an example of how to do that

http://answers.opencv.org/question/93379/how-to-calculate-frames-per-second/#93411

So, if you divide the total number of frames the car was present in the scene by the current framerate, you'll get the number of seconds the car was present in the scene.

Time [seconds] = Total [Frames] / [Frames / Second] .

If you are able to detect and track cars and you know the real distance between, travelled, then should be an easy task.

If you want velocity in km/h, you need to transform the time T from total frames to hours.

For that you have to calculate the framerate of your videostream, for which I point you to this answer of mine where I give an example of how to do that

http://answers.opencv.org/question/93379/how-to-calculate-frames-per-second/#93411

So, if you divide the total number of frames the car was present in the scene by the current framerate, you'll get the number of seconds the car was present in the scene.

Time [seconds] = Total [Frames] / [Frames / Second] .

If you are able to detect and track cars and you know the real distance travelled, then should be an easy task.

If you want velocity in km/h, you need to transform the time T from total frames to hours.

For that you have to calculate the framerate of your videostream, for which I point you to this answer of mine where I give an example of how to do that

http://answers.opencv.org/question/93379/how-to-calculate-frames-per-second/#93411

So, if you divide the total number of frames the car was present in the scene by the current framerate, you'll get the number of seconds the car was present in the scene.

Time [seconds] = Total [Frames] / [Frames / Second] .

Edit:

If you know the distance, the framerate, the total number of frames the car is present in the scene you don't need anything else to calculate the speed.

For each car you detect you need to create an ID, and for each frame that ID is present on the scene you need to increment a counter. This means you'll have to match each car detection in between frames to keep counting.

Imagine that the distance of the road in the scene is 200 meters, the car goes from begining to end in 120 frames and the framerate is 30 fps. The time the car was present in the video was 120 / 30 = 4 seconds. So, the car travelled 200 meters in 4 seconds. That means 50 m/s which then you can convert to 180 km/h.

If you are able to detect and track cars and you know the real distance travelled, then should be an easy task.

If you want velocity in km/h, you need to transform the time T from total frames to hours.

For that you have to calculate the framerate of your videostream, for which I point you to this answer of mine where I give an example of how to do that

http://answers.opencv.org/question/93379/how-to-calculate-frames-per-second/#93411

So, if you divide the total number of frames the car was present in the scene by the current framerate, you'll get the number of seconds the car was present in the scene.

Time [seconds] = Total [Frames] / [Frames / Second] .

Edit:

If you know the distance, the framerate, the total number of frames the car is present in the scene you don't need anything else to calculate the speed.

For each car you detect you need to create an ID, and for each frame that ID is present on the scene you need to increment a counter. This means you'll have to match each car detection in between frames to keep counting.

Imagine that the distance of the road in the scene is 200 meters, the car goes from begining to end in 120 frames and the framerate is 30 fps. The time the car was present in the video was 120 / 30 = 4 seconds. So, the car travelled 200 meters in 4 seconds. That means 50 m/s which then you can convert to 180 km/h.

If you are able to detect and track cars and you know the real distance travelled, then should be an easy task.

If you want velocity in km/h, you need to transform the time T from total frames to hours.

For that you have to calculate the framerate of your videostream, for which I point you to this answer of mine where I give an example of how to do that

http://answers.opencv.org/question/93379/how-to-calculate-frames-per-second/#93411

So, if you divide the total number of frames the car was present in the scene by the current framerate, you'll get the number of seconds the car was present in the scene.

Time [seconds] = Total [Frames] / [Frames / Second] .

Edit:

If you know the distance, the framerate, the total number of frames the car is present in the scene you don't need anything else to calculate the speed.

For each car you detect you need to create an ID, and for each frame that ID is present on the scene you need to increment a counter. This means you'll have to match each car detection in between frames to keep counting.

Imagine that the distance of the road in the scene is 200 meters, the car goes from begining to end in 120 frames and the framerate is 30 fps. The time the car was present in the video was 120 / 30 = 4 seconds. So, the car travelled 200 meters in 4 seconds. That means the speed is 50 m/s which then you can convert to 180 km/h.