2CVBpy Example Script for AQS12 Calibration - Use Case 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.
8See also use case 3 described in the CVB Metric documentation:
9https://help.commonvisionblox.com/NextGen/15.0/md_theory_of_operation_tools__metric.html#calibration_setup
11The rigid body transformation solely inlcudes rotation and translation.
20def print_trafo(trafo: cvb.AffineMatrix3D) ->
None:
21 print(
"Estimated transformation:")
23 print(f
"[{trafo.translation.x}, {trafo.translation.y}, "
24 f
"{trafo.translation.z}]")
25 print(
"Transformation matrix:")
26 print(f
"[[{trafo.matrix.at(0, 0)}, "
27 f
"{trafo.matrix.at(0, 1)}, "
28 f
"{trafo.matrix.at(0, 2)}],")
29 print(f
"[{trafo.matrix.at(1, 0)}, "
30 f
"{trafo.matrix.at(1, 1)}, "
31 f
"{trafo.matrix.at(1, 2)}],")
32 print(f
"[{trafo.matrix.at(2, 0)}, "
33 f
"{trafo.matrix.at(2, 1)}, "
34 f
"{trafo.matrix.at(2, 2)}]]")
37def print_trafo_parameters(atp: cvb.AffineTransformationParameters) ->
None:
38 print(
"Rotation angles about X, Y, Z axis in degrees:")
39 print(f
"{atp.rotation_angles.x}, {atp.rotation_angles.y}, "
40 f
"{atp.rotation_angles.z}")
41 print(
"Shear Syx, Syz:")
42 print(f
"{atp.s_yx}, {atp.s_yz}")
43 print(
"Inclination of laser plane about X, Z axis in degrees:")
44 print(f
"{atp.inclination_x}, {atp.inclination_z}")
45 print(
"Scale in X, Y, Z:")
46 print(f
"{atp.scale.x}, {atp.scale.y}, {atp.scale.z}")
49def print_point_3d_list(points: list[
cvb.Point3D]) ->
None:
52 data_list.append(f
"[{p.x}, {p.y}, {p.z}]")
54 print(f
"[{delimiter.join(data_list)}]")
57def print_residuals(points: list[
cvb.Point3D]) ->
None:
59 print_point_3d_list(points)
62def print_extrinsic_matrix(matrix: cvb.AffineMatrix3D) ->
None:
63 rotation = matrix.matrix.rotation_angles
64 print(
"Transformation results:")
65 print(
"Rotation about x, y, and z in degrees:")
66 print(f
"{rotation[0]}, {rotation[1]}, {rotation[2]}")
67 print(
"Translation about x, y, and z in millimeters:")
68 print(f
"{matrix.translation.x}, {matrix.translation.y}, "
69 f
"{matrix.translation.z}")
93print(
"Estimation of a rigid body transformation (rotation and translation)")
96print(
"Loading range map and calibration file.")
97range_map_file = os.path.join(
99 "RangeMapCalibrationPattern.tif"))
103print(f
"Range map loaded with size of {range_map.width} x {range_map.height} "
104 f
"from {range_map_file}.")
107aqs12 = create_aqs12()
110calibrator_file = os.path.join(
113calibrator.range_map_ignore_value = 0.
115 range_map.planes[0], calibrator,
116 cvb.PointCloudFlags.Float | cvb.PointCloudFlags.XYZConfidence)
118print(
"Dense point cloud created from range map and calibration file "
119 f
"with {cloud_intrinsic.num_points} points.")
123 cvb.foundation.SegmentationMethod.KmeansClustering)
126print(
"Estimating a rigid-body transformation.")
127transformation_, residuals_, transformation_parameters_ = \
129 cloud_intrinsic, segmentor, aqs12)
130calibrator.extrinsic_matrix = transformation_
134 print_trafo(transformation_)
136if transformation_parameters_:
137 print_trafo_parameters(transformation_parameters_)
140 print_residuals(residuals_)
142print_extrinsic_matrix(calibrator.extrinsic_matrix)
145print(
"Creating calibrated point cloud.")
147 range_map.planes[0], calibrator,
148 cvb.PointCloudFlags.Float | cvb.PointCloudFlags.XYZConfidence)
151 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:671
The Common Vision Blox image.
Definition: __init__.py:2097
Multi-purpose 3D vector class.
Definition: __init__.py:4322
Union[cvb.PointCloud, cvb.DensePointCloud, cvb.SparsePointCloud] create(cvb.ImagePlane range_map, cvb.Calibrator3D calibrator, int flags, Union[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:4701
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:4732
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, Optional[List[cvb.Point3D]], cvb.AffineTransformationParameters] calculate_rigid_body_transformation_from_aqs12_piece(cvb.DensePointCloud cloud, cvb.foundation.AQS12DensePointCloudSegmentor segmentor, cvb.foundation.AQS12Piece aqs12, Optional[cvb.Rect] aoi=None)
Calculates a rigid body transformation from a given dense cloud of an AQS12 calibration piece.
Definition: __init__.py:2320
str install_path()
Directory Common Vision Blox has been installed to.
Definition: __init__.py:8318