2CVBpy Example Script for AQS12 Calibration - Use Case 2.
4This example shows how to calibrate range maps acquired by a compact 3D
5sensor where the intrinsic calibration parameters are given, but the
6laser plane is not exactly vertical to the direction of movement.
8See also use case 2 described in the CVB Metric documentation:
9https://help.commonvisionblox.com/NextGen/14.1/md_theory_of_operation_tools__metric.html#calibration_setup
11This example program estimates an affine transformation.
12The affine transformation:
13- corrects errors induced by an incline laser plane
14- corrects scaling in x, y, z
15- moves the point cloud to the coordinate system given by the reference
42def check_accuracy(residuals, desired_accuracy):
43 for point
in residuals:
44 if abs(point.x) > desired_accuracy
or abs(point.y) > desired_accuracy
or abs(point.z) > desired_accuracy:
52print(
"Estimation of an affine transformation (correcting an inclined laser plane)")
55print(
"Loading range map and calibration file.")
57),
"tutorial",
"Metric",
"Images",
"RangeMapCalibrationPattern.tif"))
62calibrator.range_map_ignore_value = 0
64 rangemap.planes[0], calibrator, cvb.PointCloudFlags.Float)
71config.is_homography_calculated =
False
72config.is_correction_of_laser_plane_inclination_calculated =
True
76 cvb.foundation.SegmentationMethod.KmeansClustering)
79print(
"Estimating affine transformation.")
81 cloud_intrinsic, segmentor, config)
82calibrator.correction_of_laser_plane_inclination = result[0]
85desired_accuracy = 0.05
86if check_accuracy(result[1], desired_accuracy):
87 print(
"The calibration was successful and accuracy is < ",
88 desired_accuracy,
"mm.")
91 print(
"Creating calibrated point cloud.")
93 rangemap.planes[0], calibrator, cvb.PointCloudFlags.Float)
97 cloud.save(
"cloud.ply")
99 print(
"Results do not have desired accuracy. Check face segmentation and extracted AQS12 points...")
102 print(
"Extracting AQ12 faces on intrinsically calibrated point cloud.")
103 facesAqs12 = segmentor.face_segmentation_from_piece(cloud_intrinsic)
107 facesAqs12.save(
"AQS12faces.bmp")
110 print(
"Extracting AQ12 corner points on intrinsically calibrated point cloud.")
111 aqs12points = segmentor.extract_projected_points_from_piece(
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
cvb.foundation.CalibrationConfiguration create(cvb.foundation.AQS12Piece aqs12)
Creates a calibration configuration object.
Definition: __init__.py:270
Common Vision Blox Foundation module for Python.
Definition: __init__.py:1
Tuple[cvb.AffineMatrix3D, List[cvb.Point3D]] calculate_correction_of_laser_plane_inclination_from_aqs12_piece(cvb.DensePointCloud cloud, cvb.foundation.AQS12DensePointCloudSegmentor segmentor, cvb.foundation.CalibrationConfiguration config, Optional[cvb.Rect] aoi)
Calculates the correction of the laser plane inclination (affine transformation) from the given dense...
Definition: __init__.py:2127
str install_path()
Directory Common Vision Blox has been installed to.
Definition: __init__.py:8257