Ocean
Loading...
Searching...
No Matches
CalibrationDebugElements.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_CV_CALIBRATION_CALIBRATION_DEBUG_ELEMENTS_H
9#define META_OCEAN_CV_CALIBRATION_CALIBRATION_DEBUG_ELEMENTS_H
10
17
19#include "ocean/base/Frame.h"
20
23
24namespace Ocean
25{
26
27namespace CV
28{
29
30namespace Calibration
31{
32
33/**
34 * This class implements debug elements for the calibration library.
35 * Debug elements allow to visualize results and intermediate steps from calibration components and algorithms.
36 * @ingroup cvcalibration
37 */
39 public DebugElements,
40 public Singleton<CalibrationDebugElements>
41{
43
44 public:
45
46 /// True, in case debugging is allowed and debugging code will be included into the binary; False, to disable debugging code
47 static constexpr bool allowDebugging_ = true;
48
49 /**
50 * Definition of several debug elements.
51 */
52 enum ElementId : uint32_t
53 {
54 /// An invalid element id.
56
57 /// PointDetector: Image visualizing the detected point candidates.
59 /// PointDetector: Image visualizing the detected points without non-maximum suppression.
61 /// PointDetector: Image visualizing the detected points after non-maximum suppression.
63 /// PointDetector:: Image visualizing the optimization process.
65 /// PointDetector: Image visualizing the point patterns used for optimization.
67 /// PointDetector: Image visualizing the detected points after optimization.
69
70 /// CameraCalibrator: Image visualizing the detected points.
72 /// CameraCalibrator: Image visualizing the detected marker candidates with valid board indices and sign.
74 /// CameraCalibrator: Image visualizing the detected marker candidates with valid ids.
76 /// CameraCalibrator: Image visualizing the detected marker candidates with valid marker coordinates.
78 /// CameraCalibrator: Image visualizing the initial camera pose based on valid marker candidates.
80 /// CameraCalibrator: Image visualizing the initial camera pose based on valid marker candidates after the camera profile has been optimized.
82 /// CameraCalibrator: Image visualizing the optimized camera pose using additional points.
84 /// CameraCalibrator: Image visualizing the first iteration while the initial camera fov is optimized.
86 /// CameraCalibrator: Image visualizing the second iteration while the initial camera fov is optimized.
88 /// CameraCalibrator: Image visualizing the third iteration while the initial camera fov is optimized.
90 /// CameraCalibrator: Image visualizing the optimized camera pose with additional correspondences, this is the final step in the per-image optimization.
92 /// CameraCalibrator: Image visualizing the camera boundary of the final camera profile in the per-image optimization.
94
95 /// CameraCalibrator: Image visualizing the coverage of the camera area.
97 /// CameraCalibrator: Image visualizing the camera distortion with a grid.
99 /// CameraCalibrator: Image visualizing the camera distortion with displacement vectors.
101 /// CameraCalibrator: Image showing the final average projection error per bin.
103 };
104
105 public:
106
107 /**
108 * Updates the point element visualizing the detected points without non-maximum suppression.
109 * @param yFrame The frame in which the points have been detected, must be valid
110 * @param points The points to be visualized before non-maximum suppression
111 */
112 inline void updatePointDetectorPointsNonSuppressed(const Frame& yFrame, const Points& points);
113
114 /**
115 * Updates the point element visualizing the detected points after non-maximum suppression.
116 * @param yFrame The frame in which the points have been detected, must be valid
117 * @param points The points to be visualized after non-maximum suppression
118 */
119 inline void updatePointDetectorPointsSuppressed(const Frame& yFrame, const Points& points);
120
121 /**
122 * Updates the point element visualizing the optimization process.
123 * @param yFrame The frame in which the points have been detected, must be valid
124 * @param pointsMoveFrom The starting point of all points which moved too much during the optimization process
125 * @param pointsMoveTo The end point of all points which moved too much during the optimization process
126 * @param pointsFlip The points with flipped sign during the optimization process
127 * @param pointsFailed The points which failed during the optimization process
128 */
129 void updatePointDetectorPointsOptimization(const Frame& yFrame, const Vectors2& pointsMovedFrom, const Vectors2& pointsMovedTo, const Vectors2& pointsFlipped, const Vectors2& pointsFailed);
130
131 /**
132 * Updates the point element visualizing the point patterns used for optimization.
133 * @param pointPatterns The point patterns to be visualized
134 * @param imageSize The size of the resulting image with the point patterns, in pixel
135 */
136 void updatePointDetectorPointsOptimizationPointPatterns(const PointDetector::PointPatterns& pointPatterns, const unsigned int imageSize);
137
138 /**
139 * Updates the point element visualizing the detected points after optimization.
140 * @param yFrame The frame in which the points have been detected, must be valid
141 * @param points The points to be visualized after optimization
142 */
143 inline void updatePointDetectorPointsOptimized(const Frame& yFrame, const Points& points);
144
145 /**
146 * Updates a camera calibrator element visualizing the detected points.
147 * @param yFrame The frame in which the points have been detected, must be valid
148 * @param points The points to be visualized
149 */
150 inline void updateCameraCalibratorDetectedPoints(const Frame& yFrame, const Points& points);
151
152 /**
153 * Updates a camera calibrator element visualizing the detected marker candidates.
154 * @param elementId The id of the debug element to update, must be valid
155 * @param yFrame The frame in which the points and marker candidates have been detected, must be valid
156 * @param points The points associated with the marker candidates
157 * @param markerCandidates The marker candidates to be visualized
158 */
159 void updateCameraCalibratorMarkerCandidates(const ElementId elementId, const Frame& yFrame, const Points& points, const MarkerCandidates& markerCandidates);
160
161 /**
162 * Updates a camera calibrator element visualizing the initial camera pose based on valid marker candidates.
163 * @param elementId The id of the debug element to update, must be valid
164 * @param yFrame The frame in which the points and marker candidates have been detected, must be valid
165 * @param points The points associated with the marker candidates
166 * @param markerCandidates The marker candidates
167 * @param usedInitialMarkerCandidateIndices The indices of the marker candidates which have been used to determine the initial camera pose, at least one
168 * @param calibrationBoard The calibration board which was detected, must be valid
169 * @param camera The camera profile defining the projection, must be valid
170 * @param board_T_camera The camera pose transforming camera to board, must be valid
171 */
172 void updateCameraCalibratorInitialCameraPoseWithValidMarkerCandidates(const ElementId elementId, const Frame& yFrame, const Points& points, const MarkerCandidates& markerCandidates, const Indices32& usedInitialMarkerCandidateIndices, const MetricCalibrationBoard& calibrationBoard, const AnyCamera& camera, const HomogenousMatrix4& board_T_camera);
173
174 /**
175 * Updates a camera calibration element visualizing the 2D/3D correspondences which were used to determine the camera pose.
176 * @param elementId The id of the debug element to update, must be valid
177 * @param yFrame The frame in which the calibration board has been detected, must be valid
178 * @param calibrationBoard The calibration board which was detected, must be valid
179 * @param camera The camera profile defining the projection, must be valid
180 * @param board_T_camera The camera pose transforming camera to board, must be valid
181 * @param objectPointIds The ids of the object points which have been used to determine the camera pose, at least one
182 * @param objectPoints The 3D object points which have been used to determine the camera pose, one for each object point id
183 * @param imagePoints The 2D image points which have been used to determine the camera pose, one for each object point
184 * @param text Optional text to be painted in the image
185 */
186 void updateCameraCalibratorCorrespondences(const ElementId elementId, const Frame& yFrame, const MetricCalibrationBoard& calibrationBoard, const AnyCamera& camera, const HomogenousMatrix4& board_T_camera, const CalibrationBoard::ObjectPointIds& objectPointIds, const Vectors3& objectPoints, const Vectors2& imagePoints, const std::string& text = std::string());
187
188 /**
189 * Updates a camera calibrator element visualizing the camera boundary of a camera profile.
190 * @param cameraProjectionChecker The camera projection checker to be used, must be valid
191 */
193
194 /**
195 * Updates a coverage element visualizing how many observations have been used per bin.
196 * @param observations The observations for which the coverage will be visualized, must be valid
197 * @param numberObservations The number of observations, with range [1, infinity)
198 * @param expectedCoverage The number of expected observations per bin, a bin with less observations will not be green, with range [1, infinity)
199 * @param showNumbers True, to paint the distortion errors in each bin
200 */
201 void updateCameraCalibratorCoverage(const CalibrationBoardObservation* observations, const size_t numberObservations, const unsigned int expectedCoverage, const bool showNumbers = true);
202
203 /**
204 * Updates a projection error element visualizing the average projection error per bin.
205 * @param observations The observations for which the projection error will be visualized, must be valid
206 * @param numberObservations The number of observations, with range [1, infinity)
207 * @param showNumbers True, to paint the distortion errors in each bin
208 */
209 void updateCameraCalibratorProjectionError(const CalibrationBoardObservation* observations, const size_t numberObservations, const bool showNumbers = true);
210
211 /**
212 * Updates a distortion element.
213 * @param elementId The id of the debug element to update, must be valid
214 * @param camera The camera profile defining the projection and distortion, must be valid
215 * @param useGrid True, to use a grid visualization; False, to use a vector visualization
216 */
217 void updateDistortionElement(const ElementId elementId, const AnyCamera& camera, const bool useGrid);
218
219 /**
220 * Updates a debug elements based on points.
221 * @param elementId The id of the debug element to update, must be valid
222 * @param yFrame The frame in which the points have been detected, must be valid
223 * @param points The points to be visualized
224 */
225 void updatePointsElement(const ElementId elementId, const Frame& yFrame, const Points& points);
226};
227
232
237
242
244{
246}
247
248}
249
250}
251
252}
253
254#endif // META_OCEAN_CV_CALIBRATION_CALIBRATION_DEBUG_ELEMENTS_H
This class implements the abstract base class for all AnyCamera objects.
Definition AnyCamera.h:130
std::vector< ObjectPointId > ObjectPointIds
Definition of a vector holding object point ids.
Definition CalibrationBoard.h:219
This class implements an observation of a calibration board.
Definition CalibrationBoardObservation.h:45
This class implements debug elements for the calibration library.
Definition CalibrationDebugElements.h:41
void updatePointDetectorPointsOptimizationPointPatterns(const PointDetector::PointPatterns &pointPatterns, const unsigned int imageSize)
Updates the point element visualizing the point patterns used for optimization.
ElementId
Definition of several debug elements.
Definition CalibrationDebugElements.h:53
@ EI_POINT_DETECTOR_POINTS_NON_SUPPRESSED
PointDetector: Image visualizing the detected points without non-maximum suppression.
Definition CalibrationDebugElements.h:60
@ EI_CAMERA_CALIBRATOR_PROJECTION_ERROR
CameraCalibrator: Image showing the final average projection error per bin.
Definition CalibrationDebugElements.h:102
@ EI_CAMERA_CALIBRATOR_OPTIMIZED_CAMERA_POSE_WITH_ADDITIONAL_POINTS
CameraCalibrator: Image visualizing the optimized camera pose using additional points.
Definition CalibrationDebugElements.h:83
@ EI_CAMERA_CALIBRATOR_DISTORTION_GRID
CameraCalibrator: Image visualizing the camera distortion with a grid.
Definition CalibrationDebugElements.h:98
@ EI_CAMERA_CALIBRATOR_COVERAGE
CameraCalibrator: Image visualizing the coverage of the camera area.
Definition CalibrationDebugElements.h:96
@ EI_CAMERA_CALIBRATOR_CAMERA_BOUNDARY
CameraCalibrator: Image visualizing the camera boundary of the final camera profile in the per-image ...
Definition CalibrationDebugElements.h:93
@ EI_CAMERA_CALIBRATOR_MARKER_CANDIDATES
CameraCalibrator: Image visualizing the detected marker candidates with valid board indices and sign.
Definition CalibrationDebugElements.h:73
@ EI_CAMERA_CALIBRATOR_ADDITIONAL_CORRESPONDENCES
CameraCalibrator: Image visualizing the optimized camera pose with additional correspondences,...
Definition CalibrationDebugElements.h:91
@ EI_POINT_DETECTOR_POINTS_SUPPRESSED
PointDetector: Image visualizing the detected points after non-maximum suppression.
Definition CalibrationDebugElements.h:62
@ EI_CAMERA_CALIBRATOR_INITIAL_CAMERA_POSE_WITH_VALID_MARKER_CANDIDATES_OPTIMIZED_CAMERA
CameraCalibrator: Image visualizing the initial camera pose based on valid marker candidates after th...
Definition CalibrationDebugElements.h:81
@ EI_CAMERA_CALIBRATOR_OPTIMIZED_INITIAL_FOV_ITERATION_1
CameraCalibrator: Image visualizing the second iteration while the initial camera fov is optimized.
Definition CalibrationDebugElements.h:87
@ EI_INVALID
An invalid element id.
Definition CalibrationDebugElements.h:55
@ EI_CAMERA_CALIBRATOR_MARKER_CANDIDATES_WITH_IDS_WITH_COORDINATES
CameraCalibrator: Image visualizing the detected marker candidates with valid marker coordinates.
Definition CalibrationDebugElements.h:77
@ EI_POINT_DETECTOR_POINTS_CANDIDATES
PointDetector: Image visualizing the detected point candidates.
Definition CalibrationDebugElements.h:58
@ EI_CAMERA_CALIBRATOR_DETECTED_POINTS
CameraCalibrator: Image visualizing the detected points.
Definition CalibrationDebugElements.h:71
@ EI_CAMERA_CALIBRATOR_MARKER_CANDIDATES_WITH_IDS
CameraCalibrator: Image visualizing the detected marker candidates with valid ids.
Definition CalibrationDebugElements.h:75
@ EI_POINT_DETECTOR_POINTS_OPTIMIZED
PointDetector: Image visualizing the detected points after optimization.
Definition CalibrationDebugElements.h:68
@ EI_CAMERA_CALIBRATOR_INITIAL_CAMERA_POSE_WITH_VALID_MARKER_CANDIDATES
CameraCalibrator: Image visualizing the initial camera pose based on valid marker candidates.
Definition CalibrationDebugElements.h:79
@ EI_CAMERA_CALIBRATOR_DISTORTION_VECTORS
CameraCalibrator: Image visualizing the camera distortion with displacement vectors.
Definition CalibrationDebugElements.h:100
@ EI_CAMERA_CALIBRATOR_OPTIMIZED_INITIAL_FOV_ITERATION_0
CameraCalibrator: Image visualizing the first iteration while the initial camera fov is optimized.
Definition CalibrationDebugElements.h:85
@ EI_POINT_DETECTOR_POINTS_OPTIMIZATION
PointDetector:: Image visualizing the optimization process.
Definition CalibrationDebugElements.h:64
@ EI_POINT_DETECTOR_POINTS_OPTIMIZATION_POINT_PATTERNS
PointDetector: Image visualizing the point patterns used for optimization.
Definition CalibrationDebugElements.h:66
@ EI_CAMERA_CALIBRATOR_OPTIMIZED_INITIAL_FOV_ITERATION_2
CameraCalibrator: Image visualizing the third iteration while the initial camera fov is optimized.
Definition CalibrationDebugElements.h:89
void updatePointsElement(const ElementId elementId, const Frame &yFrame, const Points &points)
Updates a debug elements based on points.
void updateCameraCalibratorInitialCameraPoseWithValidMarkerCandidates(const ElementId elementId, const Frame &yFrame, const Points &points, const MarkerCandidates &markerCandidates, const Indices32 &usedInitialMarkerCandidateIndices, const MetricCalibrationBoard &calibrationBoard, const AnyCamera &camera, const HomogenousMatrix4 &board_T_camera)
Updates a camera calibrator element visualizing the initial camera pose based on valid marker candida...
void updateDistortionElement(const ElementId elementId, const AnyCamera &camera, const bool useGrid)
Updates a distortion element.
void updateCameraCalibratorProjectionError(const CalibrationBoardObservation *observations, const size_t numberObservations, const bool showNumbers=true)
Updates a projection error element visualizing the average projection error per bin.
void updatePointDetectorPointsOptimization(const Frame &yFrame, const Vectors2 &pointsMovedFrom, const Vectors2 &pointsMovedTo, const Vectors2 &pointsFlipped, const Vectors2 &pointsFailed)
Updates the point element visualizing the optimization process.
void updateCameraCalibratorCorrespondences(const ElementId elementId, const Frame &yFrame, const MetricCalibrationBoard &calibrationBoard, const AnyCamera &camera, const HomogenousMatrix4 &board_T_camera, const CalibrationBoard::ObjectPointIds &objectPointIds, const Vectors3 &objectPoints, const Vectors2 &imagePoints, const std::string &text=std::string())
Updates a camera calibration element visualizing the 2D/3D correspondences which were used to determi...
void updateCameraCalibratorCoverage(const CalibrationBoardObservation *observations, const size_t numberObservations, const unsigned int expectedCoverage, const bool showNumbers=true)
Updates a coverage element visualizing how many observations have been used per bin.
void updateCameraCalibratorMarkerCandidates(const ElementId elementId, const Frame &yFrame, const Points &points, const MarkerCandidates &markerCandidates)
Updates a camera calibrator element visualizing the detected marker candidates.
void updateCameraCalibratorCameraBoundary(const CameraProjectionChecker &cameraProjectionChecker)
Updates a camera calibrator element visualizing the camera boundary of a camera profile.
void updateCameraCalibratorDetectedPoints(const Frame &yFrame, const Points &points)
Updates a camera calibrator element visualizing the detected points.
Definition CalibrationDebugElements.h:243
void updatePointDetectorPointsOptimized(const Frame &yFrame, const Points &points)
Updates the point element visualizing the detected points after optimization.
Definition CalibrationDebugElements.h:238
static constexpr bool allowDebugging_
True, in case debugging is allowed and debugging code will be included into the binary; False,...
Definition CalibrationDebugElements.h:47
void updatePointDetectorPointsNonSuppressed(const Frame &yFrame, const Points &points)
Updates the point element visualizing the detected points without non-maximum suppression.
Definition CalibrationDebugElements.h:228
void updatePointDetectorPointsSuppressed(const Frame &yFrame, const Points &points)
Updates the point element visualizing the detected points after non-maximum suppression.
Definition CalibrationDebugElements.h:233
This class extends the calibration board with metric information.
Definition MetricCalibrationBoard.h:39
std::vector< PointPattern > PointPatterns
Definition of a vector holding point patterns.
Definition PointDetector.h:209
This class implements a helper class allowing to check whether a 3D object point projects into the ca...
Definition AnyCamera.h:516
This class implements the base class for a container for debug elements.
Definition DebugElements.h:29
This class implements Ocean's image class.
Definition Frame.h:1808
This template class is the base class for all singleton objects.
Definition Singleton.h:71
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition Base.h:96
std::vector< Point > Points
Definition of a vector holding points.
Definition cv/calibration/Point.h:31
std::vector< MarkerCandidate > MarkerCandidates
Definition of a vector holding marker candidates.
Definition MarkerCandidate.h:33
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition Vector2.h:64
std::vector< Vector3 > Vectors3
Definition of a vector holding Vector3 objects.
Definition Vector3.h:65
The namespace covering the entire Ocean framework.
Definition Accessor.h:15