I want to measure actual distance between two points like on the road there is a vehicle in front of me,Whats the distance between me and the vehicle?
I proceeded like this :
1) Found the Perspective Transform to get the top view.
2) Then tried to find the distance.
Problem is that I am unable to get the proper top view.
If there is any alternate way please tell.
For measuring the distance between two 3D points you need to find the 3D coordinates of both points. Then it is easy to calculate the euclidean distance:
d(p1,p2)= sqrt{(p1_x - p2_x)^2+(p1_y - p2_y)^2+(p1_z - p2_z)^2}
The problem here is to find the 3D point of the object in the scene (because you know where you are, at the camera, the reference coordinates).
To find a 3D position, you need to find the homography or camera pose. For this purpose you need to detect at least 4 points in the scene that matches 4 points of a known model or image you know a priori. For example, if you have a 3D model of the car and you are able to detect points of the real car in the scene that correspond to your 3D model, you will be able to calculate the homography transformation and, therefore, the 3D positions of those points.
Anyway the problem is complex, you need to use many algorithms for detection, matching, calibration and you need to know which object you want to detect.