I am making a camera-based application for Android. My problem, is to find the real angle subtended by an object in an image, on the camera, when I have :
1.The length of that object in the image, in pixels,
2.The vertical angle-of-view of the camera,
3.The length of the image,in pixels.
Being new to image processing, I have this (probably basic) doubt. Is there a linear relationship between the angle that an object subtends on the camera, and the number of pixels in the image of the object taken by the camera? Angle subtended: Join the topmost point of the object to camera, then join bottom most point of object to camera. The angle formed at the camera, is the angle subtended. For example: Consider an image that is vertically, 200 pixels in height. The vertical angle of view of the camera, is suppose 20 degrees. So, I can say, that this 20 degrees covers 200 pixels of the image. Now, there is a portion of the image (an object) which is 10 pixels in height. I want to find the angle subtended by this object on the camera, in physical world. Would I be right in telling that, since 200 pixels are covered by 20 degrees, 10 pixels would be covered by 1 degree? That is, this object subtends an angle of 1 degree on the camera?.

As shown in this diagram, I know the values of L (of image), P (of object in image), x (Vertical angle of view of camera), and I want to find y , the angle subtended by object on camera. My assumption is (y/P)=(x/L), that is directly proportional. Would this assumption be correct?
Draw horizontal line. It’s length D is distance to object.
D * tg(X/2) = L/2
and
D * tg(Y/2) = P/2
so
Y = 2 * Arctg(tg(X/2) * P / L)
(When angles are small, they are (rough) direct proportional)
Addition: case of non-centered object.
P0, P1 – pixel coordinates of object ends relative to center point D
distance Dx = |OD| = L * ctg (X/2)
coordinate D=(Dx,0)
Y = Angle(OP1, OP0) = ArcCos((OP1 x OP0)/(|OP1| * |OP0|)) , where x means scalar product
Y = ArcCos((Dx*Dx+P1*P0)/Sqrt((Dx*Dx+P1*P1)(DxDx+P0*P0)))
Example:
L=L1-L0=768 pixels
X = 42 degrees
Dx = 1000 (rough)
P1 position = 100 pixels
P0 position = -50 pixels
Y = ArcCos((1000*1000-100*50)/(Sqrt((1000*1000 +100*100)*(1000*1000+50*50)))) = 7 degrees (rough)