# How to calculate vehicle speed?

1. May 31, 2014

### ramdas

hello everyone ,i am doing my project in image processing.i am taking video of car moving on the road and taking video frames of the same.

i want to calculate speed of vehicle.using frame rate i can calculate the time elapsed by vehicle to cover some distance. but i have one difficulty, As the vehicle goes away its size goes down also we can’t use linear scale to compute the distance .for this can anybody help me for distance computation?
i am adding images ,so that u can get an idea about it..thank u

#### Attached Files:

• ###### 123.jpg
File size:
20.1 KB
Views:
146
2. May 31, 2014

### Matterwave

Can't you just use some markers? Or just go measure the distance between two landmarks that are already there?

3. May 31, 2014

### ramdas

sir, my project is based on image processing and i have to measure the distance traveled by vehicle by subtracting vehicle's position at frame 4 to position of the same at frame 1 from the video frames that i will capture with some time intervals(frame rate). can i use some geometrical relation or any mathematical theory to calculate the distance???? thank u..

4. May 31, 2014

### Staff: Mentor

You can get the tangential component of the velocity by measuring the change in position of any single point in the image of the vehicle. But that won't give you the radial component, which you will have to calculate from the change in the size of the image of the vehicle. And for both calculations... Brush up on your trigonometry - you'll be needing it.

5. May 31, 2014

### Staff: Mentor

If the height h is known, the road is not tilted and you can make some reasonable assumption for the height of the tracked point above the road, you can calculate the radial distance (and everything else) from the tangential component.

6. May 31, 2014

### Staff: Mentor

Ah - yes, you're right. Although the assumption that the road is not tilted is a fairly strong constraint on the possible motion of the vehicle, the more I think about it, the more reasonable that constraint seems, at least for a "project".

7. May 31, 2014

### Staff: Mentor

A tilted or even a curved road can be taken into account, if necessary. Just makes calculations a bit more complicated.

8. Jul 16, 2015

### Strong Eagle

You don't have enough information, simply taking a picture of a moving vehicle to computer its speed. In its simplest form the vehicle is moving directly towards you, eliminating all the more complex equations.

Consider this thought experiment. You put a piece of poster board at one end of a hallway and shoot a photo of it from 10 ft away and from 20 ft away. When you check the pixel dimensions of the poster board in the images, the one 10 ft away was 969 pixels high, the one 20 ft away was 510 pixels high, a close approximation to a linear ratio of distance to height, ie, Hx/Hy = Dx/Dy; 510/969 = 10/20; .52 = .5

So then you go outside and shoot some images of your garage door… at 25 feet and 50 feet. As you might expect the ratios of height to distance are again nearly identical. And again, the height measurements are in pixels.

But it turns out this is not enough data to compute speed. You are looking for dX/dT. dT is easy. Sample every 30th frame and I get a ‘per second’ dT. But what about dX. Suppose that with dT = 1 sec, I discern that the height becomes twice as large as it was 1 second ago… but which is the correct distance… from 20 to 10 feet or from 50 to 25 feet? I can’t tell and obviously, one would have to be moving more than twice as fast as the other.

So what if the real initial height is known? My poster board is 3 feet tall. It still doesn’t work without knowing an initial distance… I need to know 3 of the 4 variables in order to solve for the fourth. But, I don’t have any practical way of measuring distance with the camera.

You have got to have two initial conditions to be able to know the final conditions in order to be able to compute dX.