Question

I do some image processing task in 3D and I have a problem.

I use a simulator which provides me an special kind of cameras which can tell the distance between the position of camera and any arbitrary point, using the pixels of that point in the image of camera. For example I can get the distance between camera and the object which is placed in pixel 21:34.

Now I need to calculate the real distance between two arbitrary pixels in the image of camera. It is easy when camera is vertical and placed on the above of the field and all objects are on the ground but when camera is horizontal the depth of objects in image is different.

So, how should I do?

Was it helpful?

Solution

Simple 3D reconstruction will accomplish this. The distance from camera to points in 3D is along optical axis that is Z, which you already have. You will need X, Y as well:

X = u*Z/f;  
Y = v*Z/f,

where f is camera focal length in pixels, Z your distance in mm or meters and u,v is an image centered coordinates: u = column-width/2, v = height/2-row. Note the asymmetry due to the fact that rows go down while Y and v go up. As soon as you get your X, Y, Z the distance in 3D is given by Euclidean formula:

dist = sqrt((X1-X2)2+(Y1-Y2)2+(Z1-Z2)2)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top