Image stitching with HALCON 12

Combining multiple images into a larger image has become quite convenient with the new calibration targets introduced with HALCON 12. Since the target contains multiple finder patterns, each camera can observe a different portion of the same target. The world coordinate system is the same for all cameras with the origin being located in the centre on the standard calibration plates.

To perform what we refer to as calibrated stitching you first need to determine the intrinsic parameters of each camera just like you would in a standard single camera calibration. In a second step you take one image of the target in its reference plane so that it covers the field-of-view of both cameras. This image will determine the pose of the world coordinate system. Now you can calibrate the left image as usual with the operators gen_image_to_world_plane_map and map_image:

gen_image_to_world_plane_map (Map, CamParamLeft, PoseLeft, …
map_image(ImageLeft, Map, ImageLeftCalibrated)

The calibrated image of the right camera needs to be mapped so that it seamlessly extends the left calibrated image. Therefore the pose for the right camera needs to be shifted along the x-axis of the world coordinate system:

set_orgin_pose(PoseLeft, Width*Scale, 0, 0, PoseRight)

Here Width is the width of the left calibrated image in pixels and Scale is the pixel size, which is also an input parameter of gen_image_to_world_plane_map. Now we can calibrate the right image:

gen_image_to_world_plane_map (Map, CamParamRight, PoseRight, …
map_image(ImageRight, Map, ImageRightCalibrated)

stitching1

Last but not least, we combine the calibrated images into a single image:

concat_obj(ImageLeft, ImageRight, BothImages)
tile_images(BothImages, CombinedImage, 2, ‘horizontal’)

stitching2

Depending on your camera configuration it may make sense to create your own calibration target with create_caltab. If you want to stitch 4 cameras horizontally, for example, you can create a long target that spans all 4 images.