Hacker News new | past | comments | ask | show | jobs | submit login
Finding the distance from camera to object in image (pyimagesearch.com)
51 points by zionsrogue on Jan 19, 2015 | hide | past | favorite | 10 comments



This is very interesting. Does anyone know a way to do this without knowing the exact size of the object whose distance you want to measure?


If I were to do this, I'd try the following:

First, lets examine what we know. Further objects will exhibit less relative movement then closer objects when looking through a slowly moving video camera (parallax motion). We can reconstruct 3d scenes using more than one image of the same scene from slightly different angles.

I imagine your question is for single images rather than multiple images of the same scene. Thus parallax motion will not help us. However, unless the images are taken using a tripod, there will be some kind of micro blur introduced by pushing the "take picture" button on your camera. These blurs can be analyzed. Using the same principal as above, further objects will be less blurred due to the motion. This can be used to reconstruct a 3d scene from a single image.

Next, we will likely know the characteristics of our lens and the focus/zoom settings that were used to take the image. Using this, plus the 3d scene from above, we should be able to calculate the distance to any object (recognized or not).

(disclosure: I am not an expert in this and do not know if this would work)

𝒆𝒅𝒊𝒕: This may actually work (see research below)

http://www.cv-foundation.org/openaccess/content_cvpr_2013/pa...

https://www.youtube.com/watch?v=5Le0pxfRo80


Thanks! Using the accidental motion of the photographer is extremely cool. However, for my purposes I have video that is taken from a camera on a tripod, so I don't think that method will work.


The author was recently interviewed on Hanselminutes:

http://hanselminutes.com/456/computer-vision-explained-with-...


Lost me at "standard piece of 8.5 x 11in piece of paper".

Nothing in that phrase is standard!


I don't mean to be a downer, but this isn't really novel. If you know the size of the object you are looking for, you know you can reliably find it in an image, and you understand your imaging device, then determining its distance from the sensor is extremely straightforward.


Straightforward, yes. Straightforward enough to write a blog post explaining step by step for someone new to the field.


I suppose my point was that there is no shortage of information on the method either. For example, searching for "how to measure distance from camera" yields many results detailing the same method. Anyway, it doesn't really matter, it's a well written post, just nothing terribly interesting or new.


This tutorial blog posts acknowledges that.

> in general, determining the distance from a camera to a marker is actually a very well studied problem in the computer vision/image processing space.


Agreed, it's certainly not novel. Although I personally find it interesting to see the source code behind these solutions and how the pieces are glued together.




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: