CVBpy 14.1
foundation/MetricCalibrationRigidBodyTransformation
1"""
2CVBpy Example Script for AQS12 Calibration - Use Case 3.
3
4This example shows how to bring an intrinsically calibrated point cloud to
5a world coordinate system via a rigid body transformation.
6This workflow is recommended for area 3D compact sensors.
7
8See also use case 3 described in the CVB Metric documentation:
9https://help.commonvisionblox.com/NextGen/14.1/md_theory_of_operation_tools__metric.html#calibration_setup
10
11The rigid body transformation solely inlcudes rotation and translation.
12"""
13
14import os
15import cvb
16import cvb.foundation
17
18
19def create_aqs12():
20 # list of known point coordinates of the AQS12
21 points = [
22 cvb.Point3D(20.0018, 44.9941, 15.0000),
23 cvb.Point3D(24.0018, 39.9942, 14.9994),
24 cvb.Point3D(23.9994, 24.9972, 15.0001),
25 cvb.Point3D(20.0021, 20.0035, 15.0011),
26 cvb.Point3D(15.9994, 25.0079, 15.0016),
27 cvb.Point3D(16.0000, 39.9919, 15.0010),
28 cvb.Point3D(20.0095, 59.9985, 4.9902),
29 cvb.Point3D(32.0093, 44.9958, 4.9909),
30 cvb.Point3D(32.0052, 19.9925, 4.9920),
31 cvb.Point3D(20.0021, 4.9961, 4.9939),
32 cvb.Point3D(8.0024, 19.9980, 5.0009),
33 cvb.Point3D(8.0065, 45.0009, 4.9984)]
34 return cvb.foundation.AQS12Piece(points, 0)
35
36# If you like to save the calibrated point cloud, turn this flag on:
37save = False
38
39print("Estimation of a rigid body transformation (rotation and translation)")
40
41# load range map of the calibration target AQS12
42print("Loading range map and calibration file.")
43rangemap = cvb.Image(os.path.join(cvb.install_path(
44), "tutorial", "Metric", "Images", "RangeMapCalibrationPattern.tif"))
45
46# create (intrinsically) calibrated dense point cloud
47calibrator = cvb.Calibrator3D.load(os.path.join(
48 cvb.install_path(), "tutorial", "Metric", "Images", "SICalibration.json"))
49calibrator.range_map_ignore_value = 0
51 rangemap.planes[0], calibrator, cvb.PointCloudFlags.Float)
52
53# create AQS12 object with known reference coordinates of corner points
54aqs12 = create_aqs12()
55
56# create segmentor (segmenting AQS12 faces on dense point cloud)
58 cvb.foundation.SegmentationMethod.KmeansClustering)
59
60# estimate calibration parameters
61print("Estimating a rigid-body transformation.")
63 cloud_intrinsic, segmentor, aqs12)
64calibrator.extrinsic_matrix = result[0]
65
66rotation = calibrator.extrinsic_matrix.matrix.rotation_angles
67print("transformation results:")
68print("rotation about (x/y/z): ",
69 rotation[0], "/", rotation[1], "/", rotation[2], "degree")
70print("translation in (x/y/z): ", calibrator.extrinsic_matrix.translation[0], "/",
71 calibrator.extrinsic_matrix.translation[1], "/", calibrator.extrinsic_matrix.translation[2], "mm")
72
73# create point cloud
74print("Creating calibrated point cloud.")
76 rangemap.planes[0], calibrator, cvb.PointCloudFlags.Float)
77
78if save:
79 cloud.save("cloud.ply")
Union[cvb.Calibrator3DAT, cvb.LaserPlaneHomographyCalibrator3D, cvb.LaserPlaneZigZagCalibrator3D, cvb.FactorsCalibrator3D, cvb.MatrixCalibrator3D, cvb.PinholeCameraCalibrator3D] load(str file_name)
Loads a 3D calibration from file.
Definition: __init__.py:612
The Common Vision Blox image.
Definition: __init__.py:2038
Multi-purpose 3D vector class.
Definition: __init__.py:4261
cvb.DensePointCloud create_dense(cvb.ImagePlane range_map, cvb.Calibrator3D calibrator, int flags)
Creates a new dense Cartesian 3D point cloud from the given 2.5D range map image.
Definition: __init__.py:4671
Union[cvb.PointCloud, cvb.DensePointCloud, cvb.SparsePointCloud] create(cvb.ImagePlane range_map, cvb.Calibrator3D calibrator, int flags, Optional[Type[cvb.PointCloud|cvb.DensePointCloud|cvb.SparsePointCloud]] point_cloud_type=DensePointCloud)
Creates a new Cartesian 3D point cloud from the given 2.5D range map image.
Definition: __init__.py:4640
cvb.foundation.AQS12DensePointCloudSegmentor create(int method)
Creates an AQS12 segmentor for dense point clouds based on given segmentation method.
Definition: __init__.py:18
Object to collect all input parameters for the AQS12 calibration piece.
Definition: __init__.py:76
Common Vision Blox Foundation module for Python.
Definition: __init__.py:1
Tuple[cvb.AffineMatrix3D, List[cvb.Point3D]] calculate_rigid_body_transformation_from_aqs12_piece(cvb.DensePointCloud cloud, cvb.foundation.AQS12DensePointCloudSegmentor segmentor, cvb.foundation.AQS12Piece aqs12, Optional[cvb.Rect] aoi)
Calculates the correction of the laser plane inclination (affine transformation) from the given dense...
Definition: __init__.py:2232
str install_path()
Directory Common Vision Blox has been installed to.
Definition: __init__.py:8257