[Physics] How to calculate the size of object in pixels, knowing the camera properties

cameradistanceimage processing

I'm trying to calculate the size of an object in pixels in an image, when I have these information:

x * y = the size of the real object in meters
q = the quality of the image in dpi
d = the distance between object and the camera in meters

Do I have to know the size of image as well? If so, how can I calculate the size of the object in pixels?

Best Answer

Using the Thin Lens Equation, with object distance and focal length, work out image distance behind lens. (Or do you already know the image distance from the lens = distance between lens and screen?)

Then the ratio of image to object heights = ratio of image to object distances. Finally, convert image height in inches to number of pixels, using the resolution q = number of dpi.