Can you calculate subject distance from two photos taken a few centimeters apart?
Asked 12/17/2015
4 views
2 answers
0
Is it possible to determine how far away a subject is using two images taken from slightly different positions, without knowing the subject’s actual size? What information would you need for this to work, such as focal length, sensor size, camera spacing, or camera alignment?
Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0
Photography Stack Exchange contributor
10y ago
2 Answers
4
Is it possible to calculate the distance of an object to the camera with two pictures which are taken a few cm apart?
It depends. You'd need to know something more than just having the two photos. Examples of helpful information include information about the camera and lens such as the sensor size and focal length, and also exactly how the camera's position changed between the two photos. How far did the camera move? Did it keep exactly the same orientation, or was the camera rotated a bit so the the object in question is in the same position in both photos? It would also help to know about other objects in the photos, such as size and distance from the camera.
We are able to estimate the distance with our eyes. But is it possible to do it mathematically without knowing anything about the object's height?
There's much more going on in human vision than just comparing the mental equivalent of two photographs. What your brain does is more like comparing two live video feeds augmented by a huge database of knowledge about the objects in the scene and past experience. And even with all that extra information (or in part because of it) we are easily fooled when reality doesn't match our assumptions. For example, an Ames room uses forced perspective to trick your brain into thinking that a person walking around is growing and shrinking rather than moving closer or farther away.
A photograph is a two-dimensional projection of a three-dimensional scene, and a lot of information, including size and distance, is lost in creating that image. Put another way: for any given image, there are many scenes that could produce that image.* Consider a photo of a Lego mini figure:
If you've ever seen a Lego mini figure, you know that this one is probably about 4cm tall. But is it really? It could be that this one is more like 4 feet tall. Having a second photo from a slightly different perspective doesn't give you any extra information about the true height of this mini (or maxi) figure unless you know how far the camera moved, etc. In other words, you need some piece of data that lets you establish a scale.
Okay let's assume I know how far the camera is moved and there is no rotation. Also there is a ruler near the camera in a given distance.
Think about the way things change when you look out the side window of a car moving at highway speed: objects on the side of the road whiz by, while faraway objects seem to move (relative to you) much more slowly, and objects very far away (stars, for example) don't seem to move at all. You can use that same principle. I don't have time at the moment to work out a formula for you, but I don't think it'd be a hard problem to solve with a diagram and a little geometry. And keep in mind that things start to get a lot more complicated if you have to account for distortion introduced by the lens; for example, a fisheye lens magnifies the center and compresses the edges.
If you're writing code to do this, the OpenCV library has features that will help, and it can even deal with the lens distortion mentioned above. Take a look at the Stack Overflow question: Distance to the object using stereo camera
* Sculptor Seward Johnson takes great advantage of that fact. When viewed from just the right spot his life-sized "Beyond the Frame" sculptures look like famous paintings, but you can walk around them and look at them from other angles and they often include funny details not visible in the original paintings.
Originally by user4262. Source · Licensed CC BY-SA 4.0
user4262
10y ago
0
Generated from our catalog & community — verify before relying on it.
Yes, but not from the two photos alone. In principle this is stereo triangulation, similar to how human vision and rangefinders work. To calculate distance mathematically, you need known camera geometry: the distance the camera moved between shots (baseline), the lens/camera parameters such as focal length and sensor size, and the relative aiming/orientation of the camera for both images. If the subject is aligned consistently in both views, the math is straightforward geometry and does not require knowing the subject’s real size. If the camera was not aligned or rotated unpredictably between shots, it becomes much harder and may require additional scene information or calibration. As an alternative, if you do know the actual size of something in the image, you can estimate distance from a single photo using that known size plus focal length and sensor size.
Recommended products
UniqueBot
AI10y ago
Your Answer
Related Questions
Can you estimate subject distance for depth of field when using a telephoto lens?
How can I estimate an object's real size from photographs if one object in the image has a known size?
Can I estimate subject distance in an old photo without knowing the lens or camera distance?
Can you calculate subject distance from its size in a photo?
How can I estimate the real-world width and height covered by an image?
