Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the real life size of an object from an image, when not knowing the distance between object and the camera?

I have to make a mobile app that calculates the real life size of an object in an image.

I have done some research on it and found helpful [question]: How would you find the height of objects given an image?

The relation of the distance of the camera and real life size of the object isn't actually that complex, the ratio of the size of the object on the sensor and the size of the object in real life is the same as the ratio between the focal length and distance to the object.

distance to object (mm) = focal length (mm) * real height of the object (mm) * image height (pixels)
                          ---------------------------------------------------------------------------
                          object height (pixels) * sensor height (mm)

But how to get the value of real height of the object if distance is not known ?

Do the tools that create 3d models from images have real life dimensions?

like image 465
Parth mehta Avatar asked Mar 30 '12 09:03

Parth mehta


People also ask

How do you measure the real size of an object from an unknown picture?

To work out the size of the object on the sensor, work out it's height in pixels, divide by the image height in pixels and multiply by the physical height of the sensor.

How do you calculate the size of an object from a distance?

The relationship is a simple inverse, i.e. If you keep the same object and the same focal length you get: size = 1/ distance (the =-sign should be proportional-sign).


1 Answers

The simple answer is you can't.

Incidentally, this is why humans have two eyes. If you want to judge size without a known distance, you'll need at least two reference points. This allows you to triangulate the position of the object, get a distance to it, and use your known focal distance to calculate the size.

The more complex answer is there are ways around this for example:

  1. Cheat by using a known reference:

    For example, if you have an object of known size, you can infer the distance. This is similar to what NASA does to calibrate its cameras, for example.

    You can make safe assumptions if you're dealing with common objects, such as the height of one storey when analysing the image of a building.

  2. Move your camera around:

    This allows you to get more than one reference point with the same camera.

    I suppose you could use the accelerometer to accurately measure the positional relation between the image captured at point T1 in time and point T2. This would give you two images of the same subject with a known distance between them. This then allows you to triangulate as if you had two eyes.

    Whether normal hand-held camera jitters will be sufficient for triangulation, or whether the accelerometer will be accurate enough to inertially position the phone, I don't know.

  3. Assume a distance:

    If your app is designed to compare something on the scale of a human hand (or other bit of human anatomy), you can probably safely assume a distance based on what people will naturally do. The focus limits of the camera itself will also give an upper and lower range on how far an object can be and still be in focus. This will probably be within a tolerable margin of error.

As you mention in your question, there is an entire subfield dedicated to this question, and it is an active research area.

like image 179
brice Avatar answered Oct 16 '22 12:10

brice