Ask Your Question
0

Formula to calculate the speed of moving vehicle using focal length in openCV

asked 2016-03-24 12:08:47 -0600

Dsm gravatar image

Hello, I am doing a project on Estimating the speed of moving vehicle from the video captured in openCV. Now I have computed the speed using – (Euclidean distance between two centroids)/ time. But I exactly want the actual speed of vehicle which’s calculated using the focal length of the camera. I want to know the formula for the same. I googled it but it’s of no use.

I would be grateful for your help. Thanks in advance :)

edit retag flag offensive close merge delete

Comments

HELLO THERE, I M WORKING ON SAME PROJECT, CAN U PLS SHARE UR CODE TO FIND SPEED USING CENTROIDS

rohit18 gravatar imagerohit18 ( 2017-02-21 04:12:44 -0600 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2016-03-24 12:25:00 -0600

Giorgos_ts gravatar image

updated 2016-03-24 12:25:57 -0600

image description

In this image : f stands for focal length , q1,q2 distances of an object from the camera , y a dimension of the object and x1,x2 the real size of the object in an image.

Let Dq=q1-q2 : image description , where k is the size of the CCD of the camera , so Px1,Px2 are the pixel sizes in the image .

In that way , between two successive frames you can compute :

Dq and divide it by the time between two successive frames to find the velocity .

Basic assumption is that the camera is centered in the middle of the car and that there are no turns etc. in the road .

edit flag offensive delete link more

Comments

This was what I exactly needed. Just perfect. Thank you so much :)

Dsm gravatar imageDsm ( 2016-03-25 11:30:21 -0600 )edit

Glad i helped ! :) Hope i will get voted up

Giorgos_ts gravatar imageGiorgos_ts ( 2016-03-26 07:46:17 -0600 )edit

I didnt get what exactly is 'y' in the above figure. And most importantly how can we calculate the real height of the object? And what is x1 and x2 in the above figure? I lately read the basic assumption you have mentioned, but here in our project we are using a static camera to capture the video. I would be glad if you answer my above doubts.

Dsm gravatar imageDsm ( 2016-03-28 09:20:00 -0600 )edit

Y is for example the height of an object in real life . You have to have one unknown parameter . So you have to suppose the height of the object as known, e.g. of a traffic signs 40 cm radius or of a tree 5m height. Then x1,x2 are the dimensions of the tree for example in two images , if you open it via paint for example you can see how many pixel each object takes . It is logical that the size of the objects in pixels grow as the camera approaches the real object .

Giorgos_ts gravatar imageGiorgos_ts ( 2016-03-31 10:20:40 -0600 )edit

We are using a stationery camera. So does this formula work for the same?

Dsm gravatar imageDsm ( 2016-04-05 09:47:25 -0600 )edit

Yes it is the same , but now the object is approaching the camera not the opposite .

Giorgos_ts gravatar imageGiorgos_ts ( 2016-04-05 10:44:45 -0600 )edit

CAN U PLEASE SHARE THE PYTHON CODE FOR SPEED MEASUREMENT BY CENTROID METHOD??

rohit18 gravatar imagerohit18 ( 2017-02-21 04:14:37 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-03-24 12:08:47 -0600

Seen: 2,381 times

Last updated: Mar 24 '16