In this blog post, we will learn how to calibrate a camera using MVTec HALCON. We will use a dataset of images of a
calibration plate taken from different angles and distances. We will then use the images to calibrate the camera and
obtain the intrinsic and extrinsic parameters.
The Calibration Plate
When using a machine vision framework like HALCON, it is important to have a calibration plate with known dimensions.
MVTec provides a set of different calibration plates that can be used for calibration.
Further, the framework itself provides a set of tools to generate calibration plates with known dimensions. You can use
the following code to generate a calibration plate with a size of 170.3 x 129.1 mm with Halcon Progress.
See the documentation of the create_caltab
for a
detailed parameter reference.
Note that many printers do not support direct printing of PostScript files. You can use GhostScript to convert the PostScript file to a PDF file, which can then be printed.
Capturing Calibration Images
To calibrate a camera, we need a set of images of the calibration plate taken at the desired target depth. The target
should be in focus and uniformly illuminated. The images should cover the target in various poses. We outline various
factors to consider in our Bottlenose documentation.
Since Bottlenose is fully GigE Vision compliant, we can use standard machine
vision frameworks such as HALCON to
acquire images. Halcon has a built-in interface to acquire images from GigE Vision cameras that allows you to take
snapshots.
In HDevelop you can acquire new images with the Image Acquisition Assistant. Once a set has been obtained it can
import into the HDevelop Calibration assistant. For this post, we will use a set of images taken with a Bottlenose
camera with an SC0124 lens. This type of low-cost lens has a
higher distortion than other machine vision lenses with
a comparable field of view. We specifically chose it for this series to demonstrate the lens modelling.
Calibration Process
The lens has significant distortion which makes it a good candidate for calibration. Looking at the calibrated values
we can see how Halcon accurately estimated the focal length and the intrinsic parameters of the polynomial model.
If the camera calibration assistant is not available, or one has to integrate a more complex calibration process, the
calibration module of Halcon is fully scriptable. The following code snippet shows how to calibrate a camera with HALCON.
The intrinsic parameters stored in CameraParameters and the CameraPose can now be used to undistort images and perform
metric measurements in the plane where the calibration target was positioned, which we explain in the next blog post.
Cross-posted from my company blog.
Published: 2024-05-23
Updated : 2025-10-04
Not a spam bot? Want to leave comments or provide editorial guidance? Please click any
of the social links below and make an effort to connect. I promise I read all messages and
will respond at my choosing.