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
22
25
26namespace Ocean
27{
28
29namespace CV
30{
31
32namespace Calibration
33{
34
35/**
36 * This class implements debug elements for the calibration library.
37 * Debug elements allow to visualize results and intermediate steps from calibration components and algorithms.
38 * @ingroup cvcalibration
39 */
41 public DebugElements,
42 public Singleton<CalibrationDebugElements>
43{
45
46 public:
47
48 /// True, in case debugging is allowed and debugging code will be included into the binary; False, to disable debugging code
49 static constexpr bool allowDebugging_ = true;
50
51 /**
52 * Definition of several debug elements.
53 */
54 enum ElementId : uint32_t
55 {
56 /// An invalid element id.
58
59 /// Image visualizing the detected point candidates.
61 /// LegacyPointDetector: Image visualizing the detected points without non-maximum suppression.
63 /// LegacyPointDetector: Image visualizing the detected points after non-maximum suppression.
65 /// LegacyPointDetector:: Image visualizing the optimization process.
67 /// LegacyPointDetector: Image visualizing the point patterns used for optimization.
69 /// Image visualizing the detected points after optimization.
71 /// Image visualizing the detected points after removal of redundant points.
73
74 /// CameraCalibrator: Image visualizing the detected points.
76 /// CameraCalibrator: Image visualizing the detected marker candidates with valid board indices and sign.
78 /// CalibrationBoardDetector: Image visualizing the detected marker candidates with valid ids.
80 /// CalibrationBoardDetector: Image visualizing the detected marker candidates with valid marker coordinates.
82 /// CameraCalibrator: Image visualizing the initial camera pose based on valid marker candidates.
84 /// CameraCalibrator: Image visualizing the initial camera pose based on valid marker candidates after the camera profile has been optimized.
86 /// CameraCalibrator: Image visualizing the optimized camera pose using additional points.
88 /// CameraCalibrator: Image visualizing the first iteration while the initial camera fov is optimized.
90 /// CameraCalibrator: Image visualizing the second iteration while the initial camera fov is optimized.
92 /// CameraCalibrator: Image visualizing the third iteration while the initial camera fov is optimized.
94 /// CameraCalibrator: Image visualizing the optimized camera pose with additional correspondences, this is the final step in the per-image optimization.
96 /// CameraCalibrator: Image visualizing the optimized camera pose with additional correspondences after the final refinement in the per-image optimization.
98 /// CameraCalibrator: Image visualizing the optimized camera pose with additional correspondences during the second calibration stage.
100 /// CameraCalibrator: Image visualizing the optimized camera pose with additional correspondences after the final refinement during the second calibration stage.
102 /// CameraCalibrator: Image visualizing the calibration board with detected and undetected points.
104
105 /// CameraCalibrator: Image visualizing the camera boundary of the final camera profile in the per-image optimization.
107
108 /// CameraCalibrator: Image visualizing the coverage of the camera area.
110 /// CameraCalibrator: Image visualizing the camera distortion with a grid.
112 /// CameraCalibrator: Image visualizing the camera distortion with displacement vectors.
114 /// CameraCalibrator: Image showing the final average projection error per bin.
116 };
117
118 public:
119
120 /**
121 * Updates the point element visualizing the candidates of detected points.
122 * @param yFrame The frame in which the points have been detected, must be valid
123 * @param nonMaximumSuppression The non-maximum suppression object holding the candidates, must be valid
124 */
126
127 /**
128 * Updates the point element visualizing the detected points without non-maximum suppression.
129 * @param yFrame The frame in which the points have been detected, must be valid
130 * @param points The points to be visualized before non-maximum suppression
131 */
132 inline void updatePointDetectorPointsNonSuppressed(const Frame& yFrame, const Points& points);
133
134 /**
135 * Updates the point element visualizing the detected points after non-maximum suppression.
136 * @param yFrame The frame in which the points have been detected, must be valid
137 * @param points The points to be visualized after non-maximum suppression
138 */
139 inline void updatePointDetectorPointsSuppressed(const Frame& yFrame, const Points& points);
140
141 /**
142 * Updates the point element visualizing the optimization process.
143 * @param yFrame The frame in which the points have been detected, must be valid
144 * @param pointsMovedFrom The starting point of all points which moved too much during the optimization process
145 * @param pointsMovedTo The end point of all points which moved too much during the optimization process
146 * @param pointsFlipped The points with flipped sign during the optimization process
147 * @param pointsFailed The points which failed during the optimization process
148 */
149 void updatePointDetectorPointsOptimization(const Frame& yFrame, const Vectors2& pointsMovedFrom, const Vectors2& pointsMovedTo, const Vectors2& pointsFlipped, const Vectors2& pointsFailed);
150
151 /**
152 * Updates the point element visualizing the point patterns used for optimization.
153 * @param pointPatterns The point patterns to be visualized
154 * @param imageSize The size of the resulting image with the point patterns, in pixel
155 */
156 void updatePointDetectorPointsOptimizationPointPatterns(const LegacyPointDetector::PointPatterns& pointPatterns, const unsigned int imageSize);
157
158 /**
159 * Updates the point element visualizing the detected points after optimization.
160 * @param yFrame The frame in which the points have been detected, must be valid
161 * @param points The points to be visualized after optimization
162 */
163 inline void updatePointDetectorPointsOptimized(const Frame& yFrame, const Points& points);
164
165 /**
166 * Updates the point element visualizing the detected points after removal of redundant points.
167 * @param yFrame The frame in which the points have been detected, must be valid
168 * @param points The points to be visualized after removal of redundant points
169 */
170 inline void updatePointDetectorPointsRedundantRemoved(const Frame& yFrame, const Points& points);
171
172 /**
173 * Updates a camera calibrator element visualizing the detected points.
174 * @param yFrame The frame in which the points have been detected, must be valid
175 * @param points The points to be visualized
176 */
177 inline void updateCameraCalibratorDetectedPoints(const Frame& yFrame, const Points& points);
178
179 /**
180 * Updates a camera calibrator element visualizing the detected marker candidates.
181 * @param elementId The id of the debug element to update, must be valid
182 * @param yFrame The frame in which the points and marker candidates have been detected, must be valid
183 * @param points The points associated with the marker candidates
184 * @param markerCandidates The marker candidates to be visualized
185 */
186 void updateCalibrationBoardDetectorMarkerCandidates(const ElementId elementId, const Frame& yFrame, const Points& points, const MarkerCandidates& markerCandidates);
187
188 /**
189 * Updates a camera calibrator element visualizing the initial camera pose based on valid marker candidates.
190 * @param elementId The id of the debug element to update, must be valid
191 * @param yFrame The frame in which the points and marker candidates have been detected, must be valid
192 * @param points The points associated with the marker candidates
193 * @param markerCandidates The marker candidates
194 * @param usedInitialMarkerCandidateIndices The indices of the marker candidates which have been used to determine the initial camera pose, at least one
195 * @param calibrationBoard The calibration board which was detected, must be valid
196 * @param camera The camera profile defining the projection, must be valid
197 * @param board_T_camera The camera pose transforming camera to board, must be valid
198 */
199 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);
200
201 /**
202 * Updates a camera calibration element visualizing the 2D/3D correspondences which were used to determine the camera pose.
203 * @param elementId The id of the debug element to update, must be valid
204 * @param yFrame The frame in which the calibration board has been detected, must be valid
205 * @param calibrationBoard The calibration board which was detected, must be valid
206 * @param camera The camera profile defining the projection, must be valid
207 * @param board_T_camera The camera pose transforming camera to board, must be valid
208 * @param objectPointIds The ids of the object points which have been used to determine the camera pose, at least one
209 * @param objectPoints The 3D object points which have been used to determine the camera pose, one for each object point id
210 * @param imagePoints The 2D image points which have been used to determine the camera pose, one for each object point
211 * @param text Optional text to be painted in the image
212 */
213 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());
214
215 /**
216 * Updates a camera calibrator element visualizing the calibration board with detected and undetected points.
217 * Detected points are shown with green lines connecting image points to projected object points.
218 * Undetected points from the calibration board are shown in red.
219 * @param yFrame The frame in which the calibration board has been detected, must be valid
220 * @param calibrationBoard The calibration board which was detected, must be valid
221 * @param camera The camera profile defining the projection, must be valid
222 * @param board_T_camera The camera pose transforming camera to board, must be valid
223 * @param objectPointIds The ids of the object points which have been detected, at least one
224 * @param objectPoints The 3D object points which have been detected, one for each object point id
225 * @param imagePoints The 2D image points which have been detected, one for each object point
226 */
227 void updateCameraCalibratorCalibrationBoard(const Frame& yFrame, const MetricCalibrationBoard& calibrationBoard, const AnyCamera& camera, const HomogenousMatrix4& board_T_camera, const CalibrationBoard::ObjectPointIds& objectPointIds, const Vectors3& objectPoints, const Vectors2& imagePoints);
228
229 /**
230 * Updates a camera calibrator element visualizing the camera boundary of a camera profile.
231 * @param cameraClipper The camera clipper to be used, must be valid
232 */
234
235 /**
236 * Updates a coverage element visualizing how many observations have been used per bin.
237 * @param observations The observations for which the coverage will be visualized, must be valid
238 * @param numberObservations The number of observations, with range [1, infinity)
239 * @param expectedCoverage The number of expected observations per bin, a bin with less observations will not be green, with range [1, infinity)
240 * @param showNumbers True, to paint the distortion errors in each bin
241 */
242 void updateCameraCalibratorCoverage(const CalibrationBoardObservation* observations, const size_t numberObservations, const unsigned int expectedCoverage, const bool showNumbers = true);
243
244 /**
245 * Updates a projection error element visualizing the average projection error per bin.
246 * @param observations The observations for which the projection error will be visualized, must be valid
247 * @param numberObservations The number of observations, with range [1, infinity)
248 * @param showNumbers True, to paint the distortion errors in each bin
249 */
250 void updateCameraCalibratorProjectionError(const CalibrationBoardObservation* observations, const size_t numberObservations, const bool showNumbers = true);
251
252 /**
253 * Updates a distortion element.
254 * @param elementId The id of the debug element to update, must be valid
255 * @param camera The camera profile defining the projection and distortion, must be valid
256 * @param useGrid True, to use a grid visualization; False, to use a vector visualization
257 */
258 void updateDistortionElement(const ElementId elementId, const AnyCamera& camera, const bool useGrid);
259
260 /**
261 * Updates a debug elements based on points.
262 * @param elementId The id of the debug element to update, must be valid
263 * @param yFrame The frame in which the points have been detected, must be valid
264 * @param points The points to be visualized
265 */
266 void updatePointsElement(const ElementId elementId, const Frame& yFrame, const Points& points);
267};
268
273
278
283
288
290{
292}
293
294}
295
296}
297
298}
299
300#endif // META_OCEAN_CV_CALIBRATION_CALIBRATION_DEBUG_ELEMENTS_H
This class implements a helper class allowing to check whether a 3D object point projects into the ca...
Definition AnyCamera.h:518
This class implements the abstract base class for all AnyCamera objects.
Definition AnyCamera.h:131
std::vector< ObjectPointId > ObjectPointIds
Definition of a vector holding object point ids.
Definition CalibrationBoard.h:224
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:43
ElementId
Definition of several debug elements.
Definition CalibrationDebugElements.h:55
@ EI_POINT_DETECTOR_POINTS_NON_SUPPRESSED
LegacyPointDetector: Image visualizing the detected points without non-maximum suppression.
Definition CalibrationDebugElements.h:62
@ EI_CALIBRATION_BOARD_DETECTOR_MARKER_CANDIDATES_WITH_IDS_WITH_COORDINATES
CalibrationBoardDetector: Image visualizing the detected marker candidates with valid marker coordina...
Definition CalibrationDebugElements.h:81
@ EI_CAMERA_CALIBRATOR_PROJECTION_ERROR
CameraCalibrator: Image showing the final average projection error per bin.
Definition CalibrationDebugElements.h:115
@ EI_CAMERA_CALIBRATOR_ADDITIONAL_CORRESPONDENCES_0
CameraCalibrator: Image visualizing the optimized camera pose with additional correspondences,...
Definition CalibrationDebugElements.h:95
@ EI_CAMERA_CALIBRATOR_OPTIMIZED_CAMERA_POSE_WITH_ADDITIONAL_POINTS
CameraCalibrator: Image visualizing the optimized camera pose using additional points.
Definition CalibrationDebugElements.h:87
@ EI_CAMERA_CALIBRATOR_DISTORTION_GRID
CameraCalibrator: Image visualizing the camera distortion with a grid.
Definition CalibrationDebugElements.h:111
@ EI_CAMERA_CALIBRATOR_COVERAGE
CameraCalibrator: Image visualizing the coverage of the camera area.
Definition CalibrationDebugElements.h:109
@ EI_CALIBRATION_BOARD_DETECTOR_MARKER_CANDIDATES_WITH_IDS
CalibrationBoardDetector: Image visualizing the detected marker candidates with valid ids.
Definition CalibrationDebugElements.h:79
@ EI_CAMERA_CALIBRATOR_CAMERA_BOUNDARY
CameraCalibrator: Image visualizing the camera boundary of the final camera profile in the per-image ...
Definition CalibrationDebugElements.h:106
@ EI_CAMERA_CALIBRATOR_MARKER_CANDIDATES
CameraCalibrator: Image visualizing the detected marker candidates with valid board indices and sign.
Definition CalibrationDebugElements.h:77
@ EI_POINT_DETECTOR_POINTS_SUPPRESSED
LegacyPointDetector: Image visualizing the detected points after non-maximum suppression.
Definition CalibrationDebugElements.h:64
@ 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:85
@ EI_POINT_DETECTOR_POINTS_REDUNDANT_REMOVED
Image visualizing the detected points after removal of redundant points.
Definition CalibrationDebugElements.h:72
@ EI_CAMERA_CALIBRATOR_OPTIMIZED_INITIAL_FOV_ITERATION_1
CameraCalibrator: Image visualizing the second iteration while the initial camera fov is optimized.
Definition CalibrationDebugElements.h:91
@ EI_INVALID
An invalid element id.
Definition CalibrationDebugElements.h:57
@ EI_CAMERA_CALIBRATOR_ADDITIONAL_CORRESPONDENCES_1
CameraCalibrator: Image visualizing the optimized camera pose with additional correspondences during ...
Definition CalibrationDebugElements.h:99
@ EI_POINT_DETECTOR_POINTS_CANDIDATES
Image visualizing the detected point candidates.
Definition CalibrationDebugElements.h:60
@ EI_CAMERA_CALIBRATOR_DETECTED_POINTS
CameraCalibrator: Image visualizing the detected points.
Definition CalibrationDebugElements.h:75
@ EI_POINT_DETECTOR_POINTS_OPTIMIZED
Image visualizing the detected points after optimization.
Definition CalibrationDebugElements.h:70
@ EI_CAMERA_CALIBRATOR_CALIBRATION_BOARD
CameraCalibrator: Image visualizing the calibration board with detected and undetected points.
Definition CalibrationDebugElements.h:103
@ EI_CAMERA_CALIBRATOR_ADDITIONAL_CORRESPONDENCES_0_FINAL
CameraCalibrator: Image visualizing the optimized camera pose with additional correspondences after t...
Definition CalibrationDebugElements.h:97
@ 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:83
@ EI_CAMERA_CALIBRATOR_DISTORTION_VECTORS
CameraCalibrator: Image visualizing the camera distortion with displacement vectors.
Definition CalibrationDebugElements.h:113
@ EI_CAMERA_CALIBRATOR_OPTIMIZED_INITIAL_FOV_ITERATION_0
CameraCalibrator: Image visualizing the first iteration while the initial camera fov is optimized.
Definition CalibrationDebugElements.h:89
@ EI_POINT_DETECTOR_POINTS_OPTIMIZATION
LegacyPointDetector:: Image visualizing the optimization process.
Definition CalibrationDebugElements.h:66
@ EI_POINT_DETECTOR_POINTS_OPTIMIZATION_POINT_PATTERNS
LegacyPointDetector: Image visualizing the point patterns used for optimization.
Definition CalibrationDebugElements.h:68
@ EI_CAMERA_CALIBRATOR_OPTIMIZED_INITIAL_FOV_ITERATION_2
CameraCalibrator: Image visualizing the third iteration while the initial camera fov is optimized.
Definition CalibrationDebugElements.h:93
@ EI_CAMERA_CALIBRATOR_ADDITIONAL_CORRESPONDENCES_1_FINAL
CameraCalibrator: Image visualizing the optimized camera pose with additional correspondences after t...
Definition CalibrationDebugElements.h:101
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 updateCameraCalibratorCalibrationBoard(const Frame &yFrame, const MetricCalibrationBoard &calibrationBoard, const AnyCamera &camera, const HomogenousMatrix4 &board_T_camera, const CalibrationBoard::ObjectPointIds &objectPointIds, const Vectors3 &objectPoints, const Vectors2 &imagePoints)
Updates a camera calibrator element visualizing the calibration board with detected and undetected po...
void updatePointDetectorPointsNonSuppressed(const Frame &yFrame, const CV::NonMaximumSuppressionT< int32_t > &nonMaximumSuppression)
Updates the point element visualizing the candidates of detected points.
void updatePointDetectorPointsRedundantRemoved(const Frame &yFrame, const Points &points)
Updates the point element visualizing the detected points after removal of redundant points.
Definition CalibrationDebugElements.h:284
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 updateCameraCalibratorCameraBoundary(const AnyCameraClipper &cameraClipper)
Updates a camera calibrator element visualizing the camera boundary of a camera profile.
void updatePointDetectorPointsOptimizationPointPatterns(const LegacyPointDetector::PointPatterns &pointPatterns, const unsigned int imageSize)
Updates the point element visualizing the point patterns used for optimization.
void updateCalibrationBoardDetectorMarkerCandidates(const ElementId elementId, const Frame &yFrame, const Points &points, const MarkerCandidates &markerCandidates)
Updates a camera calibrator element visualizing the detected marker candidates.
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 updateCameraCalibratorDetectedPoints(const Frame &yFrame, const Points &points)
Updates a camera calibrator element visualizing the detected points.
Definition CalibrationDebugElements.h:289
void updatePointDetectorPointsOptimized(const Frame &yFrame, const Points &points)
Updates the point element visualizing the detected points after optimization.
Definition CalibrationDebugElements.h:279
static constexpr bool allowDebugging_
True, in case debugging is allowed and debugging code will be included into the binary; False,...
Definition CalibrationDebugElements.h:49
void updatePointDetectorPointsSuppressed(const Frame &yFrame, const Points &points)
Updates the point element visualizing the detected points after non-maximum suppression.
Definition CalibrationDebugElements.h:274
std::vector< PointPattern > PointPatterns
Definition of a vector holding point patterns.
Definition LegacyPointDetector.h:254
This class extends the calibration board with metric information.
Definition MetricCalibrationBoard.h:39
This class implements the possibility to find local maximum in a 2D array by applying a non-maximum-s...
Definition NonMaximumSuppression.h:138
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:1879
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