How to measure height, width and distance of object using camera?

124,183

Solution 1

I think I know what you are asking for. Here is what you can do.

first get the height of the person say h meters.

sample image

if you can calculate the height of the camera from ground (using height if the person i.e. h) and get angles A and B using gyroscope or something from android then you can calculate the height of the object using the above formula.

Isn't this what you were looking for???

let me know if you need any explanation.

Solution 2

For measuring distances with a single camera, you need to know some numbers. To measure height of something, say a chair, the only thing you have is the the size of it in the camera (which is in pixels, and can be converted to inches using screen size), that is all. The chance of measuring the height and width is using a reference, say a 6 foot tall person standing next to the chair.

This way you can work out in reverse using say a 10 foot tall object, using its size as appearing in the camera, you can work out the size of things at the same distance, on a surface that is not flat, even ensuring that they are at the same distance is a challenge.

So using the camera and just the camera, it is not possible. You need to know distance somehow, or need a reference.

If you are using the application to measure height of items you know the location of, then using GPS, you can find distance, and rest is math.

I have found some links using Google, they may help.

  1. http://forestjohnson.blogspot.com/2010/01/how-to-measure-size-of-object-using.html
  2. http://gigaom.com/mobile/how_to_measure_/
  3. http://www.iphonelife.com/blog/5/cameasure-use-your-camera-measure-size-or-distance

They may help you to find out what other information is needed other than what the camera can provide, so that you can think about your application as well regarding what can be done and what are the limitations.

One way is using multiple cameras, and that can be compensated using multiple pictures taken a known distance away. So the application can ask the user to take multiple images, track the distance using GPS, and probably it can work.

See these links as well:

  1. http://iopscience.iop.org/1742-6596/48/1/074/pdf/1742-6596_48_1_074.pdf
  2. http://www.optical-metrology-centre.com/Downloads/Papers/Photogrammetric%20Record%201994%20Automated%203-D%20measurement.pdf

Solution 3

If you know the viewport angle of the camera, you can use the height in pixels to determine the angle from the top to bottom of the object. Then, using the distance and arctangent calculate the height:

height = arctan(angle) * distance

To find the viewport angle, point the camera at something which is of known height, and make it exactly fill the screen. For example, point it at a ruler, and make it just far enough away that you can only barely see the ends of the ruler. Measure the distance from the camera, and then your total viewport angle is

viewportAngle = tan(ruler_length / distance)

Then, suppose your camera is 480px tall (cheap webcam), and the view angle is 20°. If you have an object onscreen which is 240px tall, then its angle is 10°. If you know it's 2 feet away, you would say 2 feet * arctan(10°) = ~4.1 inches tall. (I think... it's 2am so this may be a little off)

Solution 4

If you think about it, a body XRay scan (at the medical center) too needs this kind of measurement for estimating size of tumors. So they place a 1 Dollar Coin on the body, to do a comparative measurement.

Even newspaper is printed with some marks on the corners.

You need a reference to measure. May be you can get your person to wear a cap which has a few bright green circles. Once you recognize the size of the circle you can comparatively measure the remaining.

Or you can create a transparent 1 inch circle which will superimpose on the face, move the camera toward/away the face, aim your superimposed circle on that bright green circle on the cap. Then on your photo will be as per scale.

Solution 5

You can't.. You would have to know:

  • How far is the object (you can know your location from GPS.. but the object's location?)
  • What is the focal length of the camera

Maybe, just maybe if the object was optically tagged with for example a QR code, and you have a code-to-loc map...

Share:
124,183

Related videos on Youtube

anddev
Author by

anddev

Updated on July 09, 2022

Comments

  • anddev
    anddev almost 2 years

    I referred lot many links but still I am not able to get any point from that I can start my development. I want to measure my image height, width and distance using camera. I found this app . I want to make this type of application not exactly same but quite same but for my requirement I want to measure my image height, width and distance using camera.

    Can anyone give me/suggest me the right way or any example so that I can get more idea about this requirement.

    I tried this :

    http://android-er.blogspot.in/2012/04/gets-distances-from-camera-to-focus.html

    • Chiradeep
      Chiradeep over 10 years
      If you have found any solution can u please mail me the source code to find distance,width and height of any object.Please??
    • Jagdish
      Jagdish almost 10 years
      I am facing the same problem. Please help me.If any idea.Thanks in advance..
    • Akshit Zaveri
      Akshit Zaveri about 9 years
      Have you found any solution yet?
  • TheVillageIdiot
    TheVillageIdiot over 12 years
    good but as pointed by @Péter Varga you need to know distance from object.
  • Tim
    Tim over 12 years
    It seems that app uses the accelerometer to measure the angle to the base of the object, and then assumes a height of the phone off the ground (typically around 5 ft) to measure the distance. You could do something like that but it wouldn't be particularly accurate.
  • Tim
    Tim over 12 years
    @Mansi You should first get an idea for the conceptual methods used before writing any code. en.wikipedia.org/wiki/Inverse_trigonometric_functions
  • anddev
    anddev over 12 years
    Can you give me any example link related to this? So I can get more idea still I am not exact understanding your point.
  • נשמה קשוחה
    נשמה קשוחה about 12 years
    If you knew the view angle of the camera...
  • drulabs
    drulabs about 12 years
  • Sumant
    Sumant over 11 years
    did it worked on android? I have tried but not working? if you have sample demo can you upload it some where it can help others.. :)
  • Stan
    Stan almost 11 years
    it's really difficult to calculate "h" value - there is no API for this!
  • drulabs
    drulabs almost 11 years
    no api needed. Use math to calculate H using the formula. "h" is what you have to assume based on person's height. Maybe take the height of the person as input.
  • Keale
    Keale over 10 years
    this actually worked in iOS. I got the user's distance from the object and used this to compute the top half of the height of the object.
  • Akshit Zaveri
    Akshit Zaveri about 9 years
    @Keale, can you provide me some sample code please?
  • Akshit Zaveri
    Akshit Zaveri about 9 years
    What about when the object is inclined at an unknown angle itself?
  • Sorin Haidau
    Sorin Haidau over 5 years
    Can you please explain what A and B means? And where exactly do we use the distance?
  • drulabs
    drulabs over 5 years
    A and B are the angles of elevation & depression respectively.