简体   繁体   中英

Conversion from pixel to general Metric(mm, in)

I am using openCV to process an image and use houghcircles to detect the circles in the image under test, and also calculating the distance between their centers using euclidean distance. Since this would be in pixels, I need the absolute distances in mm or inches, can anyone let me know how this can be done

Thanks in advance.

The image formation process implies taking a 2D projection of the real, 3D world, through a lens. In this process, a lot of information is lost (eg the third dimension), and the transformation is dependent on lens properties (eg focal distance).

The transformation between the distance in pixels and the physical distance depends on the depth (distance between the camera and the object) and the lens. The complex, but more general way, is to estimate the depth (there are specialized algorithms which can do this under certain conditions, but require multiple cameras/perspectives) or use a depth camera which can measure the depth. Once the depth is known, after taking into account the effects of the lens projection, an estimation can be made.

You do not give much information about your setup, but the transformation can be measured experimentally. You simply take a picture of an object of known dimensions and you determine the physical dimension of one pixel (eg if the object is 10x10 cm and in the picture it has 100x100px, then 10px is 1mm). This is strongly dependent on the distance to the camera from the object.

An approach a bit more automated is to use a certain pattern (eg checkerboard) of known dimensions. It can be automatically detected in the image and the same transformation can be performed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM