CVB++ 15.0
decl_laser_plane_calibrator_3d.hpp
1#pragma once
2
3#include "../sensor_settings.hpp"
4#include "../shims/stdoptional.hpp"
5#include "decl_calibrator_3d.hpp"
6
7namespace Cvb
8{
9
10 CVB_BEGIN_INLINE_NS
11
17 class LaserPlaneCalibrator3D : public Calibrator3D
18 {
19 friend class Calibrator3DFactory;
20 friend class Calibrator3D;
21
22 public:
23 LaserPlaneCalibrator3D(HandleGuard<Calibrator3D> &&guard, Calibrator3D::ProtectedTag) noexcept
24 : Calibrator3D(std::move(guard), Calibrator3D::ProtectedTag{})
25 , encoderStep_(1.0)
26 {
27 CVB_CALL_CAPI(CVC3DCalibratorGetSettings(
28 Handle(), *reinterpret_cast<CExports::CVC3DSensorSettings *>(&sensorSettings_), encoderStep_));
29 }
30
32
43 {
44 AffineMatrix3D transformation;
45 AffineTransformationParameters transformationParameters;
46
47 auto result = CVB_CALL_CAPI(CVC3DCalibratorGetCorrectionOfLaserPlaneInclinationParameters(
48 Handle(), *reinterpret_cast<CExports::CVC3DTransformation *>(&transformation),
49 *reinterpret_cast<CExports::CVC3DAffineTransformationParameters *>(&transformationParameters)));
50 if (result < 0)
51 {
52 if (result == ErrorCodes::CVB_NOTPRESENT)
53 {
54 result = CVB_CALL_CAPI(CVC3DCalibratorGetCorrectionOfLaserPlaneInclination(
55 Handle(), *reinterpret_cast<CExports::CVC3DTransformation *>(&transformation)));
56 if (result < 0)
57 {
58 if (result == ErrorCodes::CVB_NOTPRESENT)
59 {
60 return {};
61 }
62 Utilities::SystemInfo::ThrowLastError(result);
63 }
65 }
66 }
67
68 return std::make_pair(transformation, transformationParameters);
69 }
70
72
81 void
83 const Cvb::optional<AffineTransformationParameters> &transformationParameters)
84 {
85 if (transformationParameters)
86 {
87 Internal::DoResCall([this, at = affineTransformation.value_or(AffineMatrix3D::Identity()),
88 transformationParameters]() {
89 return CVB_CALL_CAPI(CVC3DCalibratorSetCorrectionOfLaserPlaneInclinationParameters(
90 Handle(), *reinterpret_cast<const CExports::CVC3DTransformation *>(&at),
91 *reinterpret_cast<const CExports::CVC3DAffineTransformationParameters *>(&(*transformationParameters))));
92 });
93 }
94 else
95 {
96 Internal::DoResCall([this, at = affineTransformation.value_or(AffineMatrix3D::Identity())]() {
97 return CVB_CALL_CAPI(CVC3DCalibratorSetCorrectionOfLaserPlaneInclination(
98 Handle(), *reinterpret_cast<const CExports::CVC3DTransformation *>(&at)));
99 });
100 }
101 }
102
104
109 {
110 return sensorSettings_;
111 }
112
114
118 double YFactor() const noexcept
119 {
120 return encoderStep_;
121 }
122
123 private:
124 Cvb::SensorSettings sensorSettings_;
125 double encoderStep_ = 0;
126 };
127 CVB_END_INLINE_NS
128
129} // namespace Cvb
Affine transformation for 3D containing a transformation matrix and a translation vector.
Definition affine_matrix_3d.hpp:140
static AffineMatrix3D Identity() noexcept
The identity element.
Definition affine_matrix_3d.hpp:147
void * Handle() const noexcept
Returns C-API style handle to Node Object.
Definition decl_calibrator_3d.hpp:185
Cvb::SensorSettings SensorSettings() const noexcept
Gets sensor settings.
Definition decl_laser_plane_calibrator_3d.hpp:108
double YFactor() const noexcept
Gets the y factor (encoder step).
Definition decl_laser_plane_calibrator_3d.hpp:118
std::pair< Cvb::optional< AffineMatrix3D >, Cvb::optional< AffineTransformationParameters > > CorrectionOfLaserPlaneInclination() const
Gets the correction for the laser plane inclination (affine transformation) from the calibrator.
Definition decl_laser_plane_calibrator_3d.hpp:42
void SetCorrectionOfLaserPlaneInclination(const Cvb::optional< AffineMatrix3D > &affineTransformation, const Cvb::optional< AffineTransformationParameters > &transformationParameters)
Sets the correction for the laser plane inclination (affine transformation) to the calibrator.
Definition decl_laser_plane_calibrator_3d.hpp:82
Class to store camera sensor settings.
Definition sensor_settings.hpp:26
This class is a replacement for C++17 std::optional.
Definition optional.hpp:61
T value_or(U &&default_value) const
Gets the contained value if has_value() is true; default_value otherwise.
Definition optional.hpp:385
T make_pair(T... args)
T move(T... args)
const int CVB_NOTPRESENT
Not present.
Definition exception.hpp:113
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
Parameters of a 3D affine transformation matrix correcting an inclined laser plane.
Definition affine_matrix_3d.hpp:36