I have calculated object size in terms of pixel
from the image containing object. I want to measure object size in real world. Is there any way to find out multiplying factor to measure actual size ? I'm currently using python
for implementation.
Typically you will have obtained your image with a camera which projects the 3 dimensional scene onto a 2 dimensional sensor by means of a lens. The vertical (height) projection is represented in the following diagram ( I am assuming a rectilinear lens):
You say the height of your object of interest in pixels of your image as 150 pixels:
You say the image size has a total height of 800 pixels, assuming this is the sensor resolution:
You are interested in finding the real height in metric system of the object H_{obj} that finds itself at distance D from the camera.
Expressing the angles in radians we can establish the following relationships:
where f is the focal length of the lens.
isolating terms and substituting we reach
but you have expressed h_{obj} in pixels and you want H_{obj} expressed in the metric system. So, lets first move from pixels to millimeters.
Lets assume you don't know the sensor height, so we keep it as the variable for the moment. Rearranging, expressing focal length as millimeters (mm) and substituting into the previous equation we have:
\alpha represents the Vertical Field of View (since we use the sensor height) of the camera, this is a parameter that is typically given for camera & lens calculations.
Normally its given in degrees, so we just convert it to radians.
- If you actually know the focal length of your lens and the size of your sensor, just calculate the Field of View directly. This leaves us with the following equation:
The Field of View is the parameter you are missing to be able to complete your calculation. To complete the example let's assume it is 90º:
The system of units you use now to express your distance D will define the units with which the h_{obj} will be expressed in.
Another approach is, given a Field of View, and assuming a rectilinear lens, you can calculate pixel height and pixel width at a defined distance from the camera.
Vertical resolution at distance D
For more information on Field of view:
© 2022 - 2024 — McMap. All rights reserved.