I want to estimate vehicle speed. For calibration (converting pixels to meter) I only have two photos from camera.
- In the first photo one vehicle is on top of the image (Photo 1).
- In the second photo the same vehicle is moved for 12 meters (Photo 2).
The information that I have in meters includes:
- Movement Distance in meters (Purple line)
- License plate dimensions (X, Y -> its width and height in meters)
- H Height of the license plate from the ground in meters
I want to know how can I write a function with these information to take an arbitrary license plate L (i.e. its width and height and location on the image in pixels) and return the distance from the first photos license plate (or any arbitrary location) in meters (Orange lice marked as Question?).
If the camera were in the top of the road we could simply convert pixels to meter but in perspective view I do not know how can I do this if it is possible?
The problem is when vehicle is small for example 5 pixel of movement (up -> down) is about 0.5 meter and when vehicle is near the camera and is larger 5 pixels is about 0.2 meter (Numbers are just for example).
Update: Using a third point between Photo 1 and Photo 2 I created a polynomial function with two degrees (a + bx + cx^2) and now I can calculate distance. I measured speed and the result is about ±4 Km/h.
In the following picture X is start height of the license plate in pixels and Y is the distance in meters.