Manual Calibration🔗

Summary🔗

Camera calibration means finding the information necessary for mapping pixel coordinates to coordinates in the camera’s reference frame, modeling the effect of the lens. If the position of the camera with respect to the world is known, pixel coordinates can then be converted to world coordinates such as millimeters.

The Calibrate Manually tool can be used to quickly find approximate values of either the focal length of a camera or the distance between the camera and a planar surface. The tool requires a known planar template object (e.g. a ruler).

  • If the distance between the camera and the template object is known, the tool calculates the focal length. This option is demonstrated is this example.

  • If the focal length in known, the tool calculates the distance between the camera and the object.

This procedure is not as accurate as proper calibration using the calibration tool in Camera Configurator. The manual calibration assumes perfect lens with no distortion. Camera Configurator is able to estimate also the distortion factors of the lens.

On the other hand the manual calibration procedure does not require a special calibration plate. An image of a common ruler will do as we’ll see below.

Detailed description🔗

Let us walk through the schema below top-down.

Complete processing graph

Complete processing graph🔗

  • The test image originates from a virtual camera configured in Image Source. At this point Position and Calibration parameters are disabled by default. We will revisit these parameters later. The test image is shown below. Is it essential that the camera is positioned directly above the target at a known distance. That is, the optical axis must be perpendicular to the plane on which the target lies. If that is not the case, the calibration procedure must be done using the calibration plate and the relevant tool in Camera Configurator.

A ruler can be used as a calibration target.

A ruler can be used as a calibration target.🔗

  • Calibrate Manually needs the following information in order to calculate the focal length:

    • Start and end points of a line on the image plane. The points can easily be positioned manually by dragging and dropping a line widget on the image window. The line widget is shown with an orange line in the above image. In this case, it spans the tick marks between 10 and 15 cm

    • Physical length of the line is 50 mm (i.e. from 10 cm to 15

    • Distance between the camera’s aperture and the plane where the ruler lies. In this case Camera Distance = 100 mm.

    • The tool calculates Focal Length in terms of pixels. In this case, the focal length is 1949 pixels.

    • Frame contains the distance between the plane and the camera as Z-coordinate of the last column (origin). The origin of the world coordinate system is by default at the center of the image (i.e. X- and Y-coordinates are zeros).

If the camera distance is known, the tool can calculate the camera’s focal length.

If the camera distance is known, the tool can calculate the camera’s focal length.🔗

  • The Image output is a copy of the input image with the newly calculated calibration parameters attached. Hence measurements done on the calibrated image will be accurate.

  • The accuracy of the measurements is demonsrated by connecting a Caliper to the calibrated image. Start and and points of the measurement line is placed with a widget between 12 and 13 centimeters so that it crosses three tick marks at 12, 12.5 and 13 cm. The tool reports that the line crosses the tick marks at distances 1, 6 and 11 millimeters measured from the beginning of the line. This is the correct answer as the tick marks are clearly 5 mm apart. There are roughly 20 pixels / millimeter in the original image so the measurement error can be expected to be about 0.05 mm.

A caliper can now be used to measure gaps in millimeters.

A caliper can now be used to measure gaps in millimeters.🔗

Now we can store the calibration parameters permanently to the parameter set of the Image Source. For this end, disconnect the image source from the calibration tool by clicking on the green dot in the Image input socket of the calibration tool. The Image Source moves to the side as seen in the following picture.

The image source is detached for reconnecting.

The image source is detached for reconnecting.🔗

The image source must be configured for manual calibration. For this end, set Position to Manual Position and Calibration to Manual Calibration. You can now drag and drop

  • Focal Length output from Simple Calibration tool to Focal Length input of Image Source, and

  • Frame output from Simple Calibration tool to Frame input of Image Source.

Now you can remove the Simple Calibration tool and connect Caliper directly to the image source. As seen below, the measurement results remain the same.

Once calibration parameters are stored, the manual calibration tool is no longer needed.

Once calibration parameters are stored, the manual calibration tool is no longer needed.🔗

The focal length is an intrinsic property of the camera. It remains the same even if you move the camera with respect to the world plane. However, refocusing can slightly alter the focal length.

The frame you stored in the image source remains valid only as long as the camera stays put with respect to the world plane. If the camera moves, the frame has to be recalculated to get a valid perspective correction and measurement results. You can position the camera using the positioning tool in Camera Configurator. The tool can calculate perspective correction from any angle of view, so the restriction on having to place the camera directly above the world plane is lifted. You can also use QR codes to the same effect. See the cookbook entry on positioning with QR codes.