Perspective errors and lens aberrations cause images to appear distorted. This distortion misplaces information in an image, but it does not necessarily destroy the information in the image. Calibrate your imaging system if you need to compensate for perspective errors or nonlinear lens distortion.
Complete the following general steps to calibrate your imaging system:
After you calibrate your imaging system, you can attach the calibration information to an image. Refer to the Attach Calibration Information section for more information. Then, depending on your needs, you can perform one of the following steps:
You can define a calibration template by supplying an image of a grid or providing a list of pixel coordinates and their corresponding real-world coordinates. This section discusses the grid method of defining a calibration template in detail.
A calibration template is a user-defined grid of circular dots. As shown in the following figure, the grid has constant spacings in the x- and y-directions. You can use any grid, but follow these guidelines for best results:
![]() |
|
| 1 Center-to-Center Distance | 3 Distance Between Dot Edges |
| 2 Center of Grid Dots | |
![]() |
Note Select Start»All Programs»National Instruments»Vision»Documentation»Calibration Grid to use the calibration grid installed with NI Vision. The dots have radii of 2 mm and center-to-center distances of 1 cm. Depending on your printer, these measurements may change by a fraction of a millimeter. You can purchase highly accurate calibration grids from optics suppliers, such as Edmund Industrial Optics. |
To express measurements in real-world units, you need to define a coordinate system in the image of the grid. Use the Calibration Axis Info control of the IMAQ Set Simple Calibration VI to define a coordinate system by its origin, angle, and axis direction.
The origin, expressed in pixels, defines the center of your coordinate system. The angle specifies the orientation of your coordinate system with respect to the angle of the topmost row of dots in the grid image. The calibration procedure automatically determines the direction of the horizontal axis in the real world. The vertical axis direction can either be indirect, as shown in Figure A, or direct, as shown in Figure B.

If you do not specify a coordinate system, the calibration process defines a default coordinate system. If you specify a grid for the calibration process, the software defines the following default coordinate system, as shown in the following figure:
![]() |
|
| 1 Origin of a Calibration Grid in the Real World | 2 Origin of the Same Calibration Grid in an Image |
If you specify a list of points instead of a grid for the calibration process, the software defines a default coordinate system, as follows:
If you define a coordinate system yourself, carefully consider the needs of your application.
![]() |
|
| 1 Default Origin in a Calibration Grid Image | 2 User-Defined Origin |
After you define a calibration grid and reference axis, acquire an image of the grid using the current imaging setup. Refer to the Acquire or Read an Image section for information about acquiring images. The grid does not need to occupy the entire image. You can choose a region within the image that contains the grid. After you acquire an image of the grid, learn the calibration information by inputting the image of the grid and the real-world distances between the dots into the IMAQ Learn Calibration Template VI.
![]() |
Note If you want to specify a list of points instead of a grid, use the Reference Points control of the IMAQ Learn Calibration Template VI to specify the pixel to real-world mapping. |
Scaling factors are the real-world distances between the dots in the calibration grid in the x- and y- directions and the units in which the distances are measured. Use the X Step and Y Step elements of the Grid Descriptor control to specify the scaling factors.
Define a learning ROI during the learning process to define a region of the calibration grid you want to learn. The software ignores dot centers outside this region when it estimates the transformation. Depending on the calibration options selected, this is an effective way to increase correction speeds. Set the learning ROI using the Calibration Learn Setup control of the IMAQ Learn Calibration Template VI.
![]() |
Note The user-defined learning ROI represents the area in which you are interested. Do not confuse the learning ROI with the calibration ROI generated by the calibration algorithm. |
Select a method in which to learn the calibration information: perspective projection or nonlinear. The following figure illustrates the types of errors your image can exhibit. Figure A shows an image of a calibration grid with no errors. Figure B shows an image of a calibration grid with perspective projection. Figure C shows an image of a calibration grid with nonlinear distortion.

Choose the perspective projection algorithm when your system exhibits perspective errors only. A perspective projection calibration has an accurate transformation even in areas not covered by the calibration grid, as shown in the following figure. Set the Distortion element of the Calibration Learn Setup control to Perspective to choose the perspective calibration algorithm. Learning and applying perspective projection is less computationally intensive than the nonlinear method. However, perspective projection is not designed to handle highly nonlinear distortions.
If your imaging setup exhibits nonlinear distortion, use the nonlinear method. The nonlinear method guarantees accurate results only in the area that the calibration grid covers, as shown in the following figure. If your system exhibits both perspective and nonlinear distortion, use the nonlinear method to correct for both. Set the Distortion element of the Calibration Learn Setup control to Nonlinear to choose the nonlinear calibration algorithm.
![]() |
|
| 1 Calibration ROI Using the Perspective Algorithm | 2 Calibration ROI Using the Nonlinear Algorithm |
The learning process returns a score that reflects how well the software learned the input image. A learning score above 800 indicates that you chose the appropriate learning algorithm, that the grid image complies with the guideline, and that your vision system setup is adequate.
If the learning process returns a learning score below 600, try the following:
![]() |
Note A high score does not reflect the accuracy of your system. |
An error map helps you gauge the quality of your complete system. The error map returns an estimated error range to expect when a pixel coordinate is transformed into a real-world coordinate. The transformation accuracy may be higher than the value the error range indicates. Set the Learn Error Map? element of the Calibration Learn Setup control to learn the error map.
If the speed of image correction is a critical factor for your application, use a correction table. A correction table is a lookup table, stored in memory, that contains the real-world location information of all the pixels in the image. The extra memory requirements for this option are based on the size of the image. Use this option when you want to correct several images at a time in your vision application. Set the Learn Correction Table? element of the Calibration Learn Setup control to learn the correction table.
Use the Corrected Image Scaling element of the Calibration Learn Setup control to choose the appearance of the corrected image. Select either Scale to Fit or Scale to Preserve Area.Refer to the System Setup and Calibration section of the NI Vision Concepts Help for more information about the scaling mode.
Any image processing operation that changes the image size or orientation voids the calibration information in a calibrated image. Examples of VIs that void calibration information include the IMAQ Resample, IMAQ Extract, IMAQ ArrayToImage, and IMAQ Unwrap VIs.