title: Measure actual size of object in image given pixel dimension and distance from camera
body: <p>I'm working with computer vision application, and I need to know the actual size (height) of object in image given the pixel height and the distance from camera.</p>
  
  <p>I have this setup:</p>
  
  <p><a href="https://i.stack.imgur.com/jLJXR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jLJXR.png" alt="setup_1"></a> </p>
  
  <p>the black circle in left is the object with known height of 2cm, having 18cm distance from the camera (color red). Using the Y-component of bounding rectangle I got the  pixel height of object which is 50px.</p>
  
  <p>On the second setup I placed the object closer to camera:</p>
  
  <p><a href="https://i.stack.imgur.com/BEdf8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BEdf8.png" alt="enter image description here"></a></p>
  
  <p>and I got 50px in height. I know that the relationship between the distance and height is inversley proportional. But given this information, i cannot connect these numbers to acquire the actual height of unknown object to be placed like this:</p>
  
  <p><a href="https://i.stack.imgur.com/RshiX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RshiX.png" alt="enter image description here"></a></p>
  
  <p>The distance from the camera is not fixed, I need to know the actual size given the distance and pixel height.</p>
  
  <p>any idea ??? please help me .. Thank you</p>
  
  <p>BTW 
  can i use this???</p>
  
  <p>say:
   y = actual height, x = pixel height, z = distance</p>
  
  <p>the relationship would be :     y = xz/k </p>
  
  <p>is it right ?</p>