Camera positioning

Camera positioning


The camera positioning demo shows how to calculate the position of a camera with respect to a calibration template. Positioning means finding the exact location of a camera with respect to the world coordinate system. The location is represented as a matrix which, when copied to an Image Source, enables correct conversion from pixel to world coordinates (i.e. correction of perspective distortion and scale). The frame is internally attached to the image and follows it through the processing pipeline.


Detailed description

Let us walk through the processing graph below from top to bottom.

After positioning, perspective can be automatically corrected.

After positioning, perspective can be automatically corrected.

Calibration plate

A standard calibration plate must be visible in the image coming from the Image Source. The origin of the coordinate system will be set at the center of the plate and coordinate axes are aligned with the borders of plate.

The whole plate does not have to be visible. It is enough to see at least one of the four corners or the center of the plate. The origin will be set at the center of the plate even if only one corner is visible. This makes it possible to easily align multiple cameras to the same coordinate system even if they each only see a part of the plate.

Intrinsic parameters

The intrinsic calibration parameters have already been configured to the image source. This is done by setting Calibration to Manual Calibration. If the intrinsic parameters are not known, they can be estimated with Camera Calibration Tool.

The intrinsic camera parameters are:

Focal length
The distance between camera aperture and sensor, in pixels. In this example, the focal length is 1900 pixels.
Distortion factors
Used to correct non-linear distortion in the lens. Only the second and fourth degree radial distortion factors (k1 and k2, respectively) are taken into account. In this example, k1 = k2 = 0.
Principal point
Also known as the optical center, typically at the center of the image. If it is not, set Auto Center to false and configure the actual optical center with the Principal Point parameter.

Calculating camera position

Camera Positioning Tool detects the calibration plate and calculates the positioning frame. You can use the frame to position an image source by dragging and dropping Frame output to the corresponding input in Image Source. This is a one-off operation which needs to be repeated only if the camera moves with respect to the world coordinate system. The outputs of the positioning tool are:

Otherwise identical to the input image but has the new coordinate system attached.
Rotation Angles
Camera rotation in degrees around X (pitch), Y (yaw) and Z (roll) axes. The names of the angles came from aerospace nomenclature.
Detected Marker Count
Tells how many round markers have been detected on the calibration plate.
An image that shows the detected labels. Best viewed with the 'Light Colors' color map.

Verifying the result

  • Cropping Tool selects a roughly 8-by-8 millimeter square at the center of the plate. Now that the image is calibrated, you can use physical units like millimeters or inches instead of pixels.

  • Blob Detection detects the black marker in the middle of the cropped region.

  • Blob Geometry Analysis calculates e.g. the dimensions of the bounding box in which the blob fits snugly (see Size output). The units are in millimeters.

    NOTE: The Area output is accurate only if the perspective distortion has been corrected with Image Alignment Tool before passing the image to Blob Geometry Analysis. Otherwise, the area is only an approximation of the real area in world coordinates.

The size of a calibration dot is measured in millimeters.

The size of a calibration dot is measured in millimeters.