Search code examples
image-processingcomputer-visionpixelcamera-calibration

How to calculate mm per pixel of an image at a certain distance using camera calibration matrix?


I saw the answers here:

  1. How can I get pixel size in millimetres using camera calibration with checkerboard images in Matlab?

but it wasn't answered.

I have a fixed camera and an object at a certain x distance from the camera. I place a checkerboard (per square y mm) at this distance x and calibrate the camera to get camera calibration matrix. How can I use this matrix and known distance x to find mm per pixel for any image of the object placed at distance x?

As a follow up, the object size increases such that x decreases (distance between object surface and camera) to give x', will we need to recalibrate the camera for that new distance or can we somehow accommodate x' to still get accurate mm per pixel?


Solution

  • Given distance (of the reference object) and focal length (pixels) from the camera matrix, yes it's just a bit of math.

    If you want to know the length of a millimeter at a distance of 5 meters, and your focal length is 1400 pixels, calculate

    1400 pixels * (1 mm / 5 m) = 0.28 pixels
    

    So at 5 meters, you have 0.28 pixels per millimeter.