CVB++ 15.0
metric_aqs12.hpp
1#pragma once
2
3#include "../calibrator_3d.hpp"
4
5#include "metric.hpp"
6#include "_decl/decl_metric_calibration_configuration.hpp"
7#include "_decl/decl_metric_segmentor_dense_point_cloud_aqs12.hpp"
8#include "_decl/decl_metric_segmentor_range_map_aqs12.hpp"
9#include "_detail/detail_metric_segmentor.hpp"
10
11namespace Cvb
12{
13CVB_BEGIN_INLINE_NS
14
15namespace Foundation
16{
17
19
23namespace Metric
24{
25using AQS12DensePointCloudSegmentorPtr = std::shared_ptr<AQS12DensePointCloudSegmentor>;
26using AQS12RangeMapSegmentorPtr = std::shared_ptr<AQS12RangeMapSegmentor>;
27
29
33
34
35}
36}
37
38
39namespace Foundation
40{
42
46namespace Metric
47{
50
68 const CalibrationConfiguration& config)
69 {
71 result.first = std::dynamic_pointer_cast<LaserPlaneHomographyCalibrator3D>(Internal::DoResCallShareOut<Calibrator3D>([&](void*& handle) {
72 return CVB_CALL_CAPI(
73 CVMAQS12CreateIntrinsicCalibratorFromPiece(
74 imagePlane.Handle(),
75 0,
76 segmentor.Handle(),
77 config.Handle(),
78 handle,
79 reinterpret_cast<CExports::CVC3DPointD*>(result.second.data())));
80 }));
81
82 return result;
83 }
84
87
106 const CalibrationConfiguration& config, Rect<int> aoi)
107{
108
110result.first = std::dynamic_pointer_cast<LaserPlaneHomographyCalibrator3D>(Internal::DoResCallShareOut<Calibrator3D>([&](void*& handle) {
111 return CVB_CALL_CAPI(
112 CVMAQS12CreateIntrinsicCalibratorFromPieceRect(
113 imagePlane.Handle(),
114 0,
115 aoi.Left(),
116 aoi.Top(),
117 aoi.Right(),
118 aoi.Bottom(),
119 segmentor.Handle(),
120 config.Handle(),
121 handle,
122 reinterpret_cast<CExports::CVC3DPointD*>(result.second.data())));
123 }));
124
125return result;
126}
127
130
147 const CalibrationConfiguration& config)
148{
149 AffineMatrix3D trafo;
151 std::vector<Point3D<double>> residuals(12);
152
153 Internal::DoResCall([&]() {
154 return CVB_CALL_CAPI(
155 CVMAQS12CalculateCorrectionOfLaserPlaneInclinationWithParamsFromPiece(
156 cloud.Handle(),
157 segmentor.Handle(),
158 config.Handle(),
159 *reinterpret_cast<CExports::CVC3DTransformation*>(&trafo),
160 *reinterpret_cast<CExports::CVC3DAffineTransformationParameters*>(&trafoPara),
161 reinterpret_cast<CExports::CVC3DPointD*>(residuals.data())));
162 });
163
164 // move transformation parameters if valid (in case of SpecificTransformationParameters)
165 if (!std::isnan(trafoPara.InclinationX))
166 return std::make_tuple(std::move(trafo), std::move(residuals), std::move(trafoPara));
167
168 return std::make_tuple(std::move(trafo), std::move(residuals), Cvb::optional<AffineTransformationParameters>{});
169}
170
173
195 const CalibrationConfiguration& config, Rect<int> aoi)
196{
197 AffineMatrix3D trafo;
199 std::vector<Point3D<double>> residuals(12);
200
201 Internal::DoResCall([&]() {
202 return CVB_CALL_CAPI(
203 CVMAQS12CalculateCorrectionOfLaserPlaneInclinationWithParamsFromPieceRect(
204 cloud.Handle(),
205 aoi.Left(),
206 aoi.Top(),
207 aoi.Right(),
208 aoi.Bottom(),
209 segmentor.Handle(),
210 config.Handle(),
211 *reinterpret_cast<CExports::CVC3DTransformation*>(&trafo),
212 *reinterpret_cast<CExports::CVC3DAffineTransformationParameters*>(&trafoPara),
213 reinterpret_cast<CExports::CVC3DPointD*>(residuals.data())));
214 });
215
216 // move transformation parameters if valid (in case of SpecificTransformationParameters)
217 if (!std::isnan(trafoPara.InclinationX))
218 return std::make_tuple(std::move(trafo), std::move(residuals), std::move(trafoPara));
219
220 return std::make_tuple(std::move(trafo), std::move(residuals), Cvb::optional<AffineTransformationParameters>{});
221}
222
225
236 const AQS12Piece& aqs12)
237{
238 AffineMatrix3D trafo;
240 std::vector<Point3D<double>> residuals(12);
241
242 Internal::DoResCall([&]() {
243 return CVB_CALL_CAPI(
244 CVMAQS12CalculateRigidBodyTransformationWithParamsFromPiece(
245 cloud.Handle(),
246 segmentor.Handle(),
247 reinterpret_cast<const CExports::CVC3DPointD*>(aqs12.Points().data()),
248 aqs12.TopBasePlaneDistance(),
249 *reinterpret_cast<CExports::CVC3DTransformation*>(&trafo),
250 *reinterpret_cast<CExports::CVC3DAffineTransformationParameters*>(&trafoPara),
251 reinterpret_cast<CExports::CVC3DPointD*>(residuals.data())));
252 });
253
254 return std::make_tuple(std::move(trafo), std::move(residuals), std::move(trafoPara));
255}
256
259
274 const AQS12Piece& aqs12, Cvb::Rect<int> aoi)
275{
276 AffineMatrix3D trafo;
278 std::vector<Point3D<double>> residuals(12);
279
280 Internal::DoResCall([&]() {
281 return CVB_CALL_CAPI(
282 CVMAQS12CalculateRigidBodyTransformationWithParamsFromPieceRect(
283 cloud.Handle(),
284 aoi.Left(),
285 aoi.Top(),
286 aoi.Right(),
287 aoi.Bottom(),
288 segmentor.Handle(),
289 reinterpret_cast<const CExports::CVC3DPointD*>(aqs12.Points().data()),
290 aqs12.TopBasePlaneDistance(),
291 *reinterpret_cast<CExports::CVC3DTransformation*>(&trafo),
292 *reinterpret_cast<CExports::CVC3DAffineTransformationParameters*>(&trafoPara),
293 reinterpret_cast<CExports::CVC3DPointD*>(residuals.data())));
294 });
295
296 return std::make_tuple(std::move(trafo), std::move(residuals), std::move(trafoPara));
297}
298}
299}
300CVB_END_INLINE_NS
301}
Affine transformation for 3D containing a transformation matrix and a translation vector.
Definition: affine_matrix_3d.hpp:147
A dense Cartesian 3D point cloud object.
Definition: decl_dense_point_cloud.hpp:31
Object to collect all input parameters for the AQS12 calibration piece.
Definition: decl_metric_aqs12_calibration_piece.hpp:28
double TopBasePlaneDistance() const noexcept
Gets the distance between the top and base plane.
Definition: decl_metric_aqs12_calibration_piece.hpp:52
const std::array< Point3D< double >, 12 > & Points() const noexcept
Gets array with AQS12 points.
Definition: decl_metric_aqs12_calibration_piece.hpp:42
Segmentor object to configure face segmentation of AQS12 calibration piece on dense point clouds.
Definition: decl_metric_segmentor_dense_point_cloud_aqs12.hpp:20
Segmentor object to configure face segmentation of AQS12 calibration piece on range maps.
Definition: decl_metric_segmentor_range_map_aqs12.hpp:20
Calibration configuration object.
Definition: decl_metric_calibration_configuration.hpp:43
void * Handle() const noexcept
Returns C-API style handle to Node Object.
Definition: decl_metric_segmentor_dense_point_cloud.hpp:113
void * Handle() const noexcept
Returns C-API style handle to Node Object.
Definition: decl_metric_segmentor_range_map.hpp:121
Image plane information container.
Definition: decl_image_plane.hpp:33
void * Handle() const noexcept override
Classic API image handle.
Definition: detail_image_plane.hpp:36
void * Handle() const noexcept
Returns C-API style handle to Node Object.
Definition: decl_point_cloud.hpp:768
This class is a replacement for C++17 std::optional.
Definition: optional.hpp:60
std::pair< LaserPlaneHomographyCalibrator3DPtr, std::array< Point3D< double >, 12 > > AQS12CalibratorResult
Result for calculating the calibrator based on the AQS12 calibration piece.
Definition: metric_aqs12.hpp:32
TransformationResult CalculateCorrectionOfLaserPlaneInclinationFromAqs12Piece(const DensePointCloud &cloud, const AQS12DensePointCloudSegmentor &segmentor, const CalibrationConfiguration &config)
Calculates an extrinsic calibration and the correction for the laser plane inclination (affine transf...
Definition: metric_aqs12.hpp:146
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
RigidBodyTransformationResult CalculateRigidBodyTransformationFromAqs12Piece(const DensePointCloud &cloud, const AQS12DensePointCloudSegmentor &segmentor, const AQS12Piece &aqs12)
Calculates a rigid body transformation from a given dense point cloud of an AQS12 calibration piece.
Definition: metric_aqs12.hpp:235
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24
Parameters of a 3D affine transformation matrix correcting an inclined laser plane.
Definition: affine_matrix_3d.hpp:37
double InclinationX
Inclination of laser plane (rotation about x axis) in [degree].
Definition: affine_matrix_3d.hpp:51