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{
13 CVB_BEGIN_INLINE_NS
14
15 namespace Foundation
16 {
17
19
23 namespace Metric
24 {
25 using AQS12DensePointCloudSegmentorPtr = std::shared_ptr<AQS12DensePointCloudSegmentor>;
26 using AQS12RangeMapSegmentorPtr = std::shared_ptr<AQS12RangeMapSegmentor>;
27
29
33
34 } // namespace Metric
35 } // namespace Foundation
36
37 namespace Foundation
38 {
40
44 namespace Metric
45 {
48
65 const AQS12RangeMapSegmentor &segmentor,
66 const CalibrationConfiguration &config)
67 {
70 Internal::DoResCallShareOut<Calibrator3D>([&](void *&handle) {
71 return CVB_CALL_CAPI(CVMAQS12CreateIntrinsicCalibratorFromPiece(
72 imagePlane.Handle(), 0, segmentor.Handle(), config.Handle(), handle,
73 reinterpret_cast<CExports::CVC3DPointD *>(result.second.data())));
74 }));
75
76 return result;
77 }
78
81
99 const AQS12RangeMapSegmentor &segmentor,
100 const CalibrationConfiguration &config, Rect<int> aoi)
101 {
102
105 Internal::DoResCallShareOut<Calibrator3D>([&](void *&handle) {
106 return CVB_CALL_CAPI(CVMAQS12CreateIntrinsicCalibratorFromPieceRect(
107 imagePlane.Handle(), 0, aoi.Left(), aoi.Top(), aoi.Right(), aoi.Bottom(), segmentor.Handle(),
108 config.Handle(), handle, reinterpret_cast<CExports::CVC3DPointD *>(result.second.data())));
109 }));
110
111 return result;
112 }
113
116
135 const AQS12DensePointCloudSegmentor &segmentor,
136 const CalibrationConfiguration &config)
137 {
138 AffineMatrix3D trafo;
140 std::vector<Point3D<double>> residuals(12);
141
142 Internal::DoResCall([&]() {
143 return CVB_CALL_CAPI(CVMAQS12CalculateCorrectionOfLaserPlaneInclinationWithParamsFromPiece(
144 cloud.Handle(), segmentor.Handle(), config.Handle(),
145 *reinterpret_cast<CExports::CVC3DTransformation *>(&trafo),
146 *reinterpret_cast<CExports::CVC3DAffineTransformationParameters *>(&trafoPara),
147 reinterpret_cast<CExports::CVC3DPointD *>(residuals.data())));
148 });
149
150 // move transformation parameters if valid (in case of SpecificTransformationParameters)
151 if (!std::isnan(trafoPara.InclinationX))
152 return std::make_tuple(std::move(trafo), std::move(residuals), std::move(trafoPara));
153
155 }
156
159
183 const AQS12DensePointCloudSegmentor &segmentor,
184 const CalibrationConfiguration &config, Rect<int> aoi)
185 {
186 AffineMatrix3D trafo;
188 std::vector<Point3D<double>> residuals(12);
189
190 Internal::DoResCall([&]() {
191 return CVB_CALL_CAPI(CVMAQS12CalculateCorrectionOfLaserPlaneInclinationWithParamsFromPieceRect(
192 cloud.Handle(), aoi.Left(), aoi.Top(), aoi.Right(), aoi.Bottom(), segmentor.Handle(), config.Handle(),
193 *reinterpret_cast<CExports::CVC3DTransformation *>(&trafo),
194 *reinterpret_cast<CExports::CVC3DAffineTransformationParameters *>(&trafoPara),
195 reinterpret_cast<CExports::CVC3DPointD *>(residuals.data())));
196 });
197
198 // move transformation parameters if valid (in case of SpecificTransformationParameters)
199 if (!std::isnan(trafoPara.InclinationX))
200 return std::make_tuple(std::move(trafo), std::move(residuals), std::move(trafoPara));
201
203 }
204
207
217 const DensePointCloud &cloud, const AQS12DensePointCloudSegmentor &segmentor, const AQS12Piece &aqs12)
218 {
219 AffineMatrix3D trafo;
221 std::vector<Point3D<double>> residuals(12);
222
223 Internal::DoResCall([&]() {
224 return CVB_CALL_CAPI(CVMAQS12CalculateRigidBodyTransformationWithParamsFromPiece(
225 cloud.Handle(), segmentor.Handle(),
226 reinterpret_cast<const CExports::CVC3DPointD *>(aqs12.Points().data()), aqs12.TopBasePlaneDistance(),
227 *reinterpret_cast<CExports::CVC3DTransformation *>(&trafo),
228 *reinterpret_cast<CExports::CVC3DAffineTransformationParameters *>(&trafoPara),
229 reinterpret_cast<CExports::CVC3DPointD *>(residuals.data())));
230 });
231
232 return std::make_tuple(std::move(trafo), std::move(residuals), std::move(trafoPara));
233 }
234
237
252 const AQS12DensePointCloudSegmentor &segmentor,
253 const AQS12Piece &aqs12, Cvb::Rect<int> aoi)
254 {
255 AffineMatrix3D trafo;
257 std::vector<Point3D<double>> residuals(12);
258
259 Internal::DoResCall([&]() {
260 return CVB_CALL_CAPI(CVMAQS12CalculateRigidBodyTransformationWithParamsFromPieceRect(
261 cloud.Handle(), aoi.Left(), aoi.Top(), aoi.Right(), aoi.Bottom(), segmentor.Handle(),
262 reinterpret_cast<const CExports::CVC3DPointD *>(aqs12.Points().data()), aqs12.TopBasePlaneDistance(),
263 *reinterpret_cast<CExports::CVC3DTransformation *>(&trafo),
264 *reinterpret_cast<CExports::CVC3DAffineTransformationParameters *>(&trafoPara),
265 reinterpret_cast<CExports::CVC3DPointD *>(residuals.data())));
266 });
267
268 return std::make_tuple(std::move(trafo), std::move(residuals), std::move(trafoPara));
269 }
270 } // namespace Metric
271 } // namespace Foundation
272 CVB_END_INLINE_NS
273} // namespace Cvb
Affine transformation for 3D containing a transformation matrix and a translation vector.
Definition affine_matrix_3d.hpp:140
A dense Cartesian 3D point cloud object.
Definition decl_dense_point_cloud.hpp:30
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:56
const std::array< Point3D< double >, 12 > & Points() const noexcept
Gets array with AQS12 points.
Definition decl_metric_aqs12_calibration_piece.hpp:46
Segmentor object to configure face segmentation of AQS12 calibration piece on dense point clouds.
Definition decl_metric_segmentor_dense_point_cloud_aqs12.hpp:19
Segmentor object to configure face segmentation of AQS12 calibration piece on range maps.
Definition decl_metric_segmentor_range_map_aqs12.hpp:19
Calibration configuration object.
Definition decl_metric_calibration_configuration.hpp:47
void * Handle() const noexcept
Returns C-API style handle to Node Object.
Definition decl_metric_calibration_configuration.hpp:319
void * Handle() const noexcept
Returns C-API style handle to Node Object.
Definition decl_metric_segmentor_dense_point_cloud.hpp:123
void * Handle() const noexcept
Returns C-API style handle to Node Object.
Definition decl_metric_segmentor_range_map.hpp:133
Image plane information container.
Definition decl_image_plane.hpp:29
void * Handle() const noexcept override
Classic API image handle.
Definition detail_image_plane.hpp:35
void * Handle() const noexcept
Returns C-API style handle to Node Object.
Definition decl_point_cloud.hpp:773
Rectangle object.
Definition rect.hpp:24
This class is a replacement for C++17 std::optional.
Definition optional.hpp:61
T isnan(T... args)
T make_tuple(T... args)
T move(T... args)
Namespace for metric calibration.
Definition decl_metric_aqs12_calibration_piece.hpp:19
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:134
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:64
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:216
std::tuple< AffineMatrix3D, Cvb::optional< std::vector< Point3D< double > > >, Cvb::optional< AffineTransformationParameters > > TransformationResult
Result for calculating an extrinsic transformation.
Definition metric.hpp:41
std::tuple< AffineMatrix3D, Cvb::optional< std::vector< Point3D< double > > >, AffineTransformationParameters > RigidBodyTransformationResult
Result for calculating a rigid body transformation.
Definition metric.hpp:49
Namespace for the Foundation package.
Definition decl_metric_aqs12_calibration_piece.hpp:11
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
T dynamic_pointer_cast(T... args)
Parameters of a 3D affine transformation matrix correcting an inclined laser plane.
Definition affine_matrix_3d.hpp:36
double InclinationX
Inclination of laser plane (rotation about x axis) in [degree].
Definition affine_matrix_3d.hpp:50