Wikipedia:Reference desk/Archives/Computing/2021 June 1

= June 1 =

Get object distance from digital picture
Is there any way to obtain the object distance $$d_o$$ from a digital picture? That distance is known to the camera. Indeed, most traditional cameras lenses allow the user to adjust $$d_o$$ by turning a ring on the lens, which has markings for $$d_o$$. But I can't find $$d_o$$ in any Exif properties. (Alternatives include using the image distance $$d_i$$ and the formula $$1/f = 1/d_i+1/d_o$$, or even such information as the width of the frame in the object plane, but I can't find any of those, either.) ◅ Sebastian 09:36, 1 June 2021 (UTC)

Actually, this depends on the camera. As I just read at https://www.dpreview.com/forums/thread/3195972, the image shown at https://www.flickr.com/photos/dojoklo/4969420110/meta/in/set-72157622909766424 has that information. ◅ Sebastian 09:51, 1 June 2021 (UTC)


 * My Pixel 3a phone adds this field (assuming it's "subject distance") but the value is very inaccurate (or downright nonsense) in some of the photos (landscapes) that I've checked. -- Finlay McWalter··–·Talk 15:57, 1 June 2021 (UTC) edit yes, that field is 0x9206; the "nonsense" was 0xFFFFFFFF (==infinity), but other landscapes with the centre of the image being about 100m away report 2.7m, so it's not super useful. -- Finlay McWalter··–·Talk 16:10, 1 June 2021 (UTC)


 * The distance value in Exif of my photos is way off. Bubba73 You talkin' to me? 23:33, 1 June 2021 (UTC)


 * If you know the size of the object and the camera details, and details about how the image was cropped then you can calculate the distance. Bubba73 You talkin' to me? 00:26, 2 June 2021 (UTC)


 * To a camera, the distance to the object is relevant for focus – and maybe to set the amount of light emitted by the flash, but I don't know to what extend cameras are smart enough for that. When the object is far away compared to the size of the optical system (focal distance and aperture), changes in $$d_o$$ hardly affect $$d_i$$, so it no longer matters. And indeed, the error bars on the distance get very large for far-away objects. Phone cameras are very small, so an object farther than a few metres is practically at infinity. (The amount of light emitted by the flash should increase with the square of the distance to the object, so here accuracy in distance matters even at larger distances, except that with the object at a few metres, the flash is already at maximum output, so at large distances you can simply disable flash. Although I've seen people use flash when taking landscape pictures in the dark.) PiusImpavidus (talk) 08:24, 2 June 2021 (UTC)