22#include "cvb/point_cloud_factory.hpp"
23#include "cvb/calibrator_3d.hpp"
24#include "cvb/foundation/metric_aqs12.hpp"
38 std::cout <<
"Estimation of homography and affine transformation (correcting an inclined laser plane)\n\n";
41 const auto rangemapFile = Cvb::InstallPath() + CVB_LIT(
"tutorial/Metric/Images/RangeMapCalibrationPattern.tif");
43 std::cout <<
"Rangemap loaded with size of " << rangemap->Width() <<
" x " << rangemap->Height() <<
" from " << rangemapFile <<
".\n\n";
46 auto aqs12 = GetAqs12();
56 auto [transformation, transformationParameters] = calibrator->CorrectionOfLaserPlaneInclination();
58 PrintTrafo(*transformation);
59 if (transformationParameters)
60 PrintTrafo(*transformationParameters);
61 PrintResiduals(residuals);
64 const double desiredAccuracy = 0.05;
65 if (!CheckAccuracy(residuals, desiredAccuracy))
67 std::cout <<
"Results do not have desired accuracy. Check face segmentation and extracted AQS12 points...\n";
68 auto facesAqs12 = segmentor->FaceSegmentationFromPiece(rangemap->Plane(0));
69 auto pointsAqs12 = segmentor->ExtractProjectedPointsFromPiece(rangemap->Plane(0));
70 PrintAqs12Points(pointsAqs12);
76 std::cout <<
"The calibration was successful and accuracy is < " << desiredAccuracy <<
" mm. :)\n";
92 {20.0018, 44.9941, 15.0000},
93 {24.0018, 39.9942, 14.9994},
94 {23.9994, 24.9972, 15.0001},
95 {20.0021, 20.0035, 15.0011},
96 {15.9994, 25.0079, 15.0016},
97 {16.0000, 39.9919, 15.0010},
98 {20.0095, 59.9985, 4.9902},
99 {32.0093, 44.9958, 4.9909},
100 {32.0052, 19.9925, 4.9920},
101 {20.0021, 4.9961, 4.9939},
102 { 8.0024, 19.9980, 5.0009},
103 { 8.0065, 45.0009, 4.9984},
111 for (
auto residual : residuals)
113 if (std::abs(residual.X()) > desiredAccuracy || std::abs(residual.Y()) > desiredAccuracy || std::abs(residual.Z()) > desiredAccuracy)
123 std::cout <<
"Estimated transformation:\n";
125 std::cout << transformation.Translation().X() <<
", " << transformation.Translation().Y() <<
", " << transformation.Translation().Z() <<
"]\n";
127 std::cout <<
"transformation matrix: [\n";
128 std::cout << transformation.Matrix()[0][0] <<
", " << transformation.Matrix()[0][1] <<
", " << transformation.Matrix()[0][2] <<
",\n";
129 std::cout << transformation.Matrix()[1][0] <<
", " << transformation.Matrix()[1][1] <<
", " << transformation.Matrix()[1][2] <<
",\n";
130 std::cout << transformation.Matrix()[2][0] <<
", " << transformation.Matrix()[2][1] <<
", " << transformation.Matrix()[2][2] <<
"]\n\n";
136 std::cout <<
"Shear Syx, Syz: " << transformationParameters.
Syx <<
", " << transformationParameters.
Syz <<
"\n";
137 std::cout <<
"Inclination of laser plane about X,Z axis in [degree]: " << transformationParameters.
InclinationX <<
", " << transformationParameters.
InclinationZ <<
"\n";
138 std::cout <<
"Scale in X,Y,Z: " << transformationParameters.
Scale.
X <<
", " << transformationParameters.
Scale.
Y <<
", " << transformationParameters.
Scale.
Z <<
"\n\n";
144 for (
auto residual : residuals)
146 std::cout << residual.X() <<
" " << residual.Y() <<
" " << residual.Z() <<
"\n";
154 for (
auto point : points)
156 std::cout << point.X() <<
" " << point.Y() <<
" " << point.Z() <<
"\n";
Affine transformation for 3D containing a transformation matrix and a translation vector.
Definition: affine_matrix_3d.hpp:147
Object to collect all input parameters for the AQS12 calibration piece.
Definition: decl_metric_aqs12_calibration_piece.hpp:28
static std::shared_ptr< AQS12RangeMapSegmentor > Create(const SegmentationMethod method)
Creates a AQS12 segmentor for range maps based on given segmentation method.
Definition: decl_metric_segmentor_range_map_aqs12.hpp:35
static std::unique_ptr< CalibrationConfiguration > Create(const AQS12Piece &aqs12)
Creates a calibration configuration object.
Definition: decl_metric_calibration_configuration.hpp:112
static std::unique_ptr< Image > Load(const String &fileName)
Loads an image with the given file name.
Definition: detail_image.hpp:32
static PointCloudPtr Create(const ImagePlane &rangeMap, const Calibrator3D &calibrator, PointCloudFlags flags)
Creates a new Cartesian 3D point cloud from the given 2.5D range map image.
Definition: point_cloud_factory.hpp:87
@ KmeansClustering
Clustering top, base and faces using kmeans.
AQS12CalibratorResult CreateCalibratorFromAqs12Piece(const ImagePlane &imagePlane, const AQS12RangeMapSegmentor &segmentor, const CalibrationConfiguration &config)
Calculates intrinsic and extrinsic calibration parameters from the given range map image of an AQS12 ...
Definition: metric_aqs12.hpp:67
double Z
The Z factor.
Definition: core_3d.hpp:23
double X
The X factor.
Definition: core_3d.hpp:19
double Y
The Y factor.
Definition: core_3d.hpp:21