Skip to content

Calibration vTool#

The Calibration vTool allows you to calibrate a camera so that pixel coordinates can be transformed into world coordinates.

You can use the Calibration vTool as a preprocessing step followed by tools like the Geometric Pattern Matching vTool, the Region Feature Extraction vTool, or the Measurements vTools. If you have calibrated your camera, any subsequent tools will output pixel coordinates as well as world coordinates (in meters).

Calibration vTool

Calibration vTool Versions#

Two versions of the Calibration vTool are available. The following table shows the differences between the versions.

Basic Pro
Can you choose between different distortion models? No Yes
Can you choose between different projection models? No Yes

How It Works#

Depending on the lens mounted on the camera, the raw image exhibits a certain amount of radial distortion. Also, without calibration, any measurements you take refer only to pixel coordinates in the image.

Using the Calibration vTool has the following benefits:

  • The calibration process produces transformation data that is applied to raw images to remove distortion effects.
    The result are images that look they were taken by an ideal and linear pinhole camera, i.e., where straight lines in the target scene are projected as straight lines onto the image.
  • Rectification eliminates perspective distortion.
    Perspective distortion occurs if lenses with wider angles are used or if the camera is not pointing perpendicularly at the measurement plane where the objects to be inspected are placed.
    As an example, if the viewing direction of the camera is oblique, a square in the world will be seen by the camera as a general quadrangle, where opposite sides aren't parallel but intersect at vanishing points.
    Therefore, if the mechanical setup doesn't allow you to mount the camera perpendicularly to the inspection plane, camera calibration will ensure that the image is rectified and will look like a true representation of the object.
  • Calibration establishes a relation between image coordinates in pixels and world coordinates in meters.
    This way, tasks like measuring a distance in the real world or determining a gripping position for a robot can be solved.
  • When using the Calibration Pro vTool, you can choose between different distortion and projection models. This makes the calibration even more precise or specific as it allows you to factor in your application type and the lenses you're using.

Calibration Process#

Step 1: Preparation#

Calibration Plate#

The Calibration vTool allows you to calibrate a camera with respect to a single measurement plane. This requires a calibration plate. Out of the box, the Calibration vTool offers different calibration plate sizes. They are available in the Calibration plate drop-down list.

Choose the size of the calibration plate according to the field of view of your camera. If your target scene includes the complete field of view, the calibration plate should cover more or less the complete image area.

In most situations, it is preferable for the calibration plate to be a little bit bigger than the image area. For optimum calibration results, you should ensure that the whole image area is covered by the point markers of the calibration plate. If your target scene includes only a portion of the complete field of view, a calibration plate that only covers that particular area is sufficient.

To create your calibration plate, print one of the templates provided and glue it onto a firm, flat, and even surface, e.g., thick cardboard or an aluminum plate. For general applications or evaluation purposes, the printing precision of standard printers or plotters is likely to be sufficient.

Distortion Models (Pro Version Only)#

By choosing a distortion model appropriate for your application, you can generate more precise transformation data for correcting distortion effects. There are two models to choose from:

  • Division: This model is suitable for most applications, especially for robot or part localization applications. It uses only one coefficient for modeling distortion. Therefore, it is very robust and produces good results.
  • Polynomial: This model achieves even more accurate calibration results. It should be used for measurement applications or in case of stronger lens distortions. Five coefficients are used for modeling distortion.

Projection Models (Pro Version Only)#

Choosing a projection model allows you to factor in the type of lens you're using. There are two models to choose from:

  • Perspective: This model is recommended when using entocentric lenses.
  • Parallel: This model is recommended when using telecentric lenses.

To perform step 1, go to Configuring the vTool.

Step 2: Camera Calibration#

In this step, you acquire an image of the calibration plate. You can grab a live image with the camera or load an image from disk. Live images are useful because they allow you to move the calibration plate on the fly to find the right position for your measurements. The upper surface of the calibration plate defines the measurement plane.

Info

Calibrating the camera enables measurements only in a single world plane. This world plane is defined by the calibration plate. If the setup of your application changes, you need to recalibrate the camera.

The objects you want to measure have to lie on or close to this plane. Therefore, the objects to be inspected have to be flat or low in height. Alternatively, you have to ensure that the calibration plate's upper surface is at the same height as the objects' surface.

If the camera is looking perpendicularly onto the measurement plane and the lens has a small opening angle, the error caused by objects lying outside of the measurement plane can be neglected. Only if the angle between the measurement plane and the camera's viewing direction is oblique, the measurement error regarding position or distance gets significant.

In that case, Basler recommends restricting the variation of height between the objects to a value between 1–5 % relative to the object distance.

Once an image has been acquired, the calibration process starts immediately and the results are displayed below the image area.

Markers highlighted in green are the markers that were detected in the image. Red markers are the ones that the calibration process didn't detect. Also, the origin of the world coordinate system is shown.

Info

The position and orientation of the world coordinate system is encoded in the calibration plate pattern and its description. You can't change this. If you want to adapt the world coordinate system to the needs of your application, use the machine calibration step to do so.

To perform step 2, go to Configuring the vTool.

Step 3: Machine Calibration#

Machine calibration is an optional step in which you align the world coordinate system of the vision system with the coordinate system of the machine of which the vision system is a part of. Based on a common coordinate system, a robot, for example, can pick up an object at the position determined by the vision system.

If camera calibration is sufficient and you don't need aligned world coordinate systems for your application, you can end the calibration process here.

Considerations#

To define the machine coordinate system, two markers are used to define two points in the coordinate system, P1 and P2. For successful machine calibration, it is important to know the relation between the machine coordinate plane and the calibration plate plane. There are two options:

  • Both planes are identical.
    In this case, you can place the markers at any position of the calibration plate to define your own machine coordinate system. Knowing machine and image coordinates of the markers defines a transformation which allows you to transform image points measured into machine coordinates.
  • The planes are parallel to each other.
    Sometimes it's not possible or desired to have identical machine and calibration planes. Alternatively, the machine plane may be at a different height than the calibration plane. However, both planes must always be parallel to each other.

    Info

    This setup is only recommended if the camera is pointing perpendicularly at the measurement plane. In practice, the viewing direction may deviate from the ideal configuration by a few degrees.

    In cases where the viewing direction is oblique to the calibration plate, the machine plane must be at least close to the calibration plane. Otherwise, a systematic error occurs that is even greater for lenses with wider opening angles and more oblique viewing angles.

Methods#

There are three methods for supplying the markers that define the machine coordinate system.

Automatic with Aztec Codes#

Aztec codes are ideal for encoding information about coordinate positions as well as for providing a good visual marker for position detection in the image.

For this method, you generate and print two Aztec codes that encode positions in millimeters:

  • One code encodes, e.g., the position of the coordinate system's origin: "0 0"
  • The second code encodes a second point on the x axis of the coordinate system, e.g., 50 mm away from the first code: "50 0"
    The notation for encoding positions is "point_coordinate_x point_coordinate_y".

The system will detect the position of the Aztec codes in the image and associate its world position with the decoded content of the codes.

Info

The center of the Aztec code defines the position of the marker in world coordinates.

The distance between the markers must be exactly the value defined by the encoded positions.

Manual with Aztec Codes#

In this method, the codes are generic and can contain any information you like, e.g., a short string. This makes the printing process easier because both codes can be identical. More importantly, this means that the codes can be placed at arbitrary positions. Just choose the positions that you want to register as machine coordinates.

For a robotics application, proceed like this: Place the codes and measure their positions with a suitable touch probe mounted on the robot hand. Then, acquire the image and enter the coordinates registered by the robot into the World Coordinates input fields.

Fully Manual#

This method gives you the flexibility to enter the coordinates of the two points in world and image coordinates. As in the method above, the world coordinates are known or registered from your system and entered into the World Coordinates input fields. You can adjust the image coordinates as required by dragging the P1 and P2 crosshairs in the image to the desired target positions.

There are two main scenarios where the fully manual method is useful:

  • You can use any kind of marker that can be registered, e.g., the center of a circle, a corner point of a rectangular shape, or even a cross quickly sketched by hand on a piece of cardboard.
  • You can include the markers in your machine's design. That way, the positions of the markers are fixed and always known. Markers can be, e.g., small holes or suitable fiducial markers.

    Info

    If the machine has fixed markers, you have to place the calibration plate such that the distance to both markers is the same.

To perform step 3, go to Configuring the vTool.

Common Use Cases#

Geometric Pattern Matching#

If you use rectified images, your matching results will be more accurate. The reason is that a flat object will look the same independent of its position on the measurement plane because lens distortion or perspective distortion are eliminated.

Also, the transformation data produced by the calibration process enables the Geometric Pattern Matching vTool to output the world coordinates of the center of a pattern.

Region Feature Extraction#

The Region Feature Extraction vTool calculates features of a region, e.g., area or center of gravity, and allows you to extract them. Using a calibrated setup allows you to transform features, e.g., coordinates, lengths, or areas, into measurement units, e.g., meters or square meters.

Measurements#

The Measurements Basic vTool determines the positions of edges or distances between edges with high precision. If you use the Calibration vTool for preprocessing, you can prevent lens distortion and perspective distortion. Also, you will be able to get the results in metric measurement units (coordinates and distances).

Info

To fully benefit from the Calibration vTool ensure that both its output pins (Image and Transformation) are connected properly to all subsequent vTools.

The Measurements Pro vTools work in a similar manner but allow you to measure complete geometric shapes.

Configuring the vTool#

To configure the Calibration vTool:

  1. In the Recipe Management pane in the vTool Settings area, click Open Settings or double-click the vTool.
    The Calibration Basic/Pro dialog opens at step 1.
    For more information, see Step 1: Preparation.
    Calibration vTool Settings - Step 1
  2. In the Calibration plate drop-down list, select the size of the plate you want to use.
  3. If you haven't got an actual plate yet, click the Print button to print the desired plate.
  4. Select a distortion model and a projection model (Pro version only).
  5. Click Next.
    Step 2 of the Calibration dialog opens.
    For more information, see Step 2: Camera Calibration.
    vTool Settings - Step 2
  6. Place the calibration plate at the position of the image where you want to measure.
    The upper surface of the calibration plate defines the measurement plane.
  7. Capture or open an image.
    Either use the Single Shot button to grab a live image or click the Open Image button to open an existing image.
    Once an image has been loaded, the calibration process starts immediately. When it's finished, the results are displayed below the image area. If the calibration process was successful, a green check mark appears below the image area.

    Info

    The sizes of the images used for calibration must be identical to the sizes of the processed images.

  8. Check the results table to see whether your requirements are met.
    Calibration Results
    You can hide the table using the arrow button. If you do, the image area expands, making it easier to inspect the image details.
    Calibration Results Table Hidden

  9. Click Next.
    Step 3 of the Calibration dialog opens.
    For more information, see Step 3: Machine Calibration.
  10. If you want to calibrate your machine, click the Enable Machine Calibration button at the right end of the toolbar.
    If you want to finish with just the camera calibration, leave the settings dialog by clicking OK.
    Calibration vTool Settings - Step 3 Enabled
  11. Decide which method you want to use to define the machine's coordinate system.
    • Automatic with Aztec Codes:
      1. Generate two Aztec codes with two different positions in the coordinate system encoded in them (typically, the origin of the coordinate system and a second position).
      2. Print the Aztec codes.
      3. Place the two Aztec codes at the exact positions of the world or machine coordinate system.
      4. Select the Use Aztec code coordinates check box.
      5. Capture or open an image.
        Either use the Single Shot button to grab a live image or click the Open Image button to open an existing image.
        Once an image has been loaded, the calibration process starts immediately. When it's finished, the results are displayed below the image area. If the calibration process was successful, a green check mark appears below the image area. The Aztec codes are visualized by crosshairs in the image, and the origin of the world coordinate system is visualized as well.
      6. Check the results table to see whether your requirements are met.
      7. If you want to define the orientation of the z axis in accordance with your machine's coordinate system, select the Invert axes check box.
        Machine Calibration - Automatic with Aztec Codes
    • Manual with Aztec Codes:
      1. Generate two Aztec codes with a generic string encoded in them.
        The strings can be identical, in which case you only need to generate one Aztec code and print two copies of it.
      2. Print the Aztec codes.
      3. Place the Aztec codes at convenient positions in the image area.
      4. Measure the positions of the Aztec codes in world coordinates.
      5. Clear the Use Aztec code coordinates check box.
      6. Capture or open an image.
        Either use the Single Shot button to grab a live image or click the Open Image button to open an existing image.
      7. Enter the coordinates for P1 and P2 in the respective World Coordinates input fields.
        Machine Calibration - Manual with Aztec Codes
    • Fully manual:
      1. Clear the Use Aztec code coordinates check box.
      2. Enter the world coordinates for P1 and P2 in the respective input fields.
        They are either known (because they are fixed by design), or you have to measure them.
      3. To specify the P1 and P2 image coordinates, drag the crosshairs in the image area to the desired positions.
        Machine Calibration - Fully Manual

You can view the result of the calibration in a pin data view. Here, you can select which outputs to display.

Inputs#

Image#

Accepts images directly from a Camera vTool or from a vTool that outputs images, e.g., the Image Format Converter vTool.

Outputs#

Image#

Returns the rectified image. The output image can be used by any vTool accepting images as input.

Transformation#

Returns the transformation data that transforms the pixel coordinates of the rectified image into world coordinates. The transformation data can be used by any tool accepting transformation data as input to determine the world coordinates for a set of pixel coordinates.

  • Data type: Transformation Data

Supported Pixel Formats#

Depending on the pixel format of the input image, the Calibration vTool outputs the following pixel formats:

Input Pixel Format Output Pixel Format
Bayer GR 8 RGB 8 Planar
Bayer GR 16 RGB 16 Planar
Bayer RG 8 RGB 8 Planar
BGRA 8 Packed RGB 8 Planar
BGR 8 Packed RGB 8 Planar
Mono 8 Mono 8
Mono 10 Mono 10
Mono 12 Mono 12
Mono 16 Mono 16
RGB 8 Packed RGB 8 Planar
RGB 16 Packed RGB 16 Planar
RGB 8 Planar RGB 8 Planar
RGB 16 Planar RGB 16 Planar

Typical Predecessors#

Typical Successors#