Fig 1: Calibration and measurement planes with emphasised differences (misalignments and offsets).
Many HALCON users are dealing with measurement tasks that are 2D, in-plane-only measurements and only require medium accuracy. For those tasks, a full 3D calibration providing many calibration images might not be necessary. In addition, there are setups that physically do not allow for more than one calibration image.
A new calibration procedure included in HALCON 17.12 and 13.0.2 addresses this topic. The HDevelop example program camera_calibration_single_image.hdev shows this new calibration procedure. Additionally, section 3.1.1 Single Image Calibration in the latest version of Solution Guide III-C also describes this type of calibration.
In the following paragraphs, we introduce this HDevelop example.
In most common measurement setups (and as assumed in the HDevelop example), the measurements are performed in a different plane than the calibration. Typically, the thickness of the calibration plate results in an offset between measurement and calibration planes.
A single calibration image does not offer enough information to fully determine all camera parameters. The equation system is undetermined and the math leaves you with the unresolved equation:
z: distance calibration plate to camera
f: focal length.
If you force the computation, you obtain arbitrary z and f values. Measurements based on those arbitrary values are only accurate for images acquired in the calibration plane, for objects points in the calibration plane.
When setting f to a fixed value, however, the equation system can be solved. In HALCON, this is done via set_calib_data(CalibHandle,’camera’,’general’, ‘excluded_settings’,’focus’). The closer your guess on f is to the real value, the more accurate are your measures.
Fixing the focus and making the best guess is the best practice for achieving the best measurements with a single-image-based calibration.
The human steps behind the script
The user acquires a single image of an MVTec calibration plate, using an area scan industry camera that is compliant to our quality standards*. Then, the user makes his/her best guess for f, calibrates with a fixed focus, removes the calibration plate, and acquires measurement images. The user can now measure within the transformed images. Alternatively, measuring can also be performed with point coordinates transformed into the measurement plane.
The HDevelop example script in short
• Line 39 names the systematic error especially as function of the guess-error on f.
• Lines 53-108 show the calibration procedure after setting f to a fixed value (line 74 is active in the first FOR iteration) to achieve a single image calibration with minimised error,
• the second FOR iteration without set-forced focus shows the Don’ts.
* Refer to the relevant points in 188.8.131.52 Recommendations for Acquiring Calibration Images from the Solution Guide III-C 3D Vision.