Ocean
Loading...
Searching...
No Matches
CalibrationBoard.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_BOARD_H
9#define META_OCEAN_CV_CALIBRATION_CALIBRATION_BOARD_H
10
14
16
18
20#include "ocean/math/Vector3.h"
21
22namespace Ocean
23{
24
25namespace CV
26{
27
28namespace Calibration
29{
30
31/**
32 * This class implements a basic calibration board.
33 * The calibration board is defined by a unique id, a number of horizontal and vertical markers, and the actual board markers with their positions and orientations.
34 * @see MetricCalibrationBoard.
35 * @ingroup cvcalibration
36 */
37class OCEAN_CV_CALIBRATION_EXPORT CalibrationBoard
38{
39 public:
40
41 /**
42 * Definition of a coordinate for markers.
43 */
45
46 /**
47 * This class implements a marker in a calibration board.
48 */
49 class BoardMarker : public Marker
50 {
51 public:
52
53 /**
54 * Creates a new valid board marker.
55 * @param markerId The id of the marker, with range [0, Marker::numberMarkerIds() - 1]
56 * @param sign True, if the marker has positive sign (mainly black dot's on white background); False, if the marker has negative sign (mainly white dot's on black background)
57 * @param orientation The orientation of this marker in relation to the calibration board, must be valid
58 * @param coordinate The coordinate of the marker in the calibration board, with range [0, CalibrationBoard::xMarkers() - 1]x[0, CalibrationBoard::yMarkers() - 1]
59 */
60 inline BoardMarker(const size_t markerId, const bool sign, const CV::PixelDirection orientation, const MarkerCoordinate& coordinate);
61
62 /**
63 * Returns the orientation of this marker in relation to the calibration board.
64 * @return The marker's orientation
65 */
66 inline CV::PixelDirection orientation() const;
67
68 /**
69 * Returns the coordinate of this marker within the calibration board.
70 * @return The marker's coordinate, with range [0, CalibrationBoard::xMarkers() - 1]x[0, CalibrationBoard::yMarkers() - 1]
71 */
72 inline const MarkerCoordinate& coordinate() const;
73
74 /**
75 * Returns the sign of point in this marker.
76 * @param x The horizontal position of the point in the marker, with range [0, Marker::numberRowsColumns() - 1]
77 * @param y The vertical position of the point in the marker, with range [0, Marker::numberRowsColumns() - 1]
78 * @return True, if the point has a positive sign (black dot on white background); False, if the point has a negative sign (white dot on black background)
79 * @tparam tOriented True, if the specified point is defined within the marker's orientation; False, if the specified point is defined within the marker's unoriented layout
80 */
81 template <bool tOriented>
82 inline bool pointSign(const size_t x, const size_t y) const;
83
84 /**
85 * Returns the sign of point in this marker.
86 * @param indexInMarkerUnoriented The index of the point in the marker, with range [0, numberPoints() - 1]
87 * @return True, if the point has a positive sign (black dot on white background); False, if the point has a negative sign (white dot on black background)
88 * @tparam tOriented True, if the specified point is defined within the marker's orientation; False, if the specified point is defined within the marker's unoriented layout
89 */
90 template <bool tOriented>
91 inline bool pointSign(const size_t indexInMarker) const;
92
93 /**
94 * Returns the 3D object point of a marker point of this board marker in the coordinate system of the calibration board.
95 * @param markerPosition The position of the marker in the calibration board, defined in the board's xz-plane
96 * @param xMarkerSize The horizontal size of the marker in the calibration board, with range (0, infinity)
97 * @param zMarkerSize The vertical size of the marker in the calibration board, with range (0, infinity)
98 * @param indexInMarker The index of the marker point, with range [0, Marker::numberPoints() - 1]
99 * @return The 3D object point of the marker point, defined in the calibration board
100 */
101 Vector3 objectPoint(const Vector3& markerPosition, const Scalar xMarkerSize, const Scalar zMarkerSize, const size_t indexInMarker) const;
102
103 /**
104 * Returns the direction to a neighbor marker in relation to this marker's orientation.
105 * @param neighborBoardMarker The neighbor marker to which the direction will be determined, must be valid
106 * @return The direction to the neighbor marker, in relation to this marker's orientation
107 */
108 CV::PixelDirection neighborDirection(const BoardMarker& neighborBoardMarker) const;
109
110 /**
111 * Returns the marker coordinate for a neighbor marker.
112 * @param neighborDirection The direction to the neighbor marker, in relation to this marker's orientation, must be valid
113 * @param xMarkers The number of horizontal markers in the calibration board, with range [1, CalibrationBoard::xMarkers()]
114 * @param yMarkers The number of vertical markers in the calibration board, with range [1, CalibrationBoard::yMarkers()]
115 * @return The marker coordinate of the neighbor marker, if the neighbor marker exists, otherwise an invalid marker coordinate
116 */
117 MarkerCoordinate boardMarkerNeighborCoordinate(const CV::PixelDirection& neighborDirection, const size_t xMarkers, const size_t yMarkers) const;
118
119 /**
120 * Returns whether this board maker is valid.
121 * A valid board marker has a valid marker id, a valid sign, a valid orientation, and a valid coordinate.
122 * @return True, if so
123 */
124 inline bool isValid() const;
125
126 protected:
127
128 /// The orientation of this marker in relation to the calibration board.
129 CV::PixelDirection orientation_ = CV::PD_INVALID;
130
131 /// The rotation between the marker and the calibration board, a rotation around the y-axis with 90 deg steps.
132 Quaternion board_R_marker_ = Quaternion(false);
133
134 /// The coordinate of the marker in the calibration board, with range [0, CalibrationBoard::xMarkers() - 1]x[0, CalibrationBoard::yMarkers() - 1]
136 };
137
138 /**
139 * Definition of a vector holding board markers.
140 */
141 using BoardMarkers = std::vector<BoardMarker>;
142
143 /**
144 * Definition of a static vector allowing to store up to four marker coordinates.
145 */
147
148 /**
149 * Definition of a map mapping neighbor directions to (up to four) marker coordinates.
150 */
151 using NeighborMarkerCoordinateMap = std::unordered_map<CV::PixelDirection, MarkerCoordinate>;
152
153 /**
154 * Definition of an object point id composed of a marker coordinate and marker point index.
155 */
157 {
158 public:
159
160 /**
161 * Definition of a hash object for object point ids.
162 */
163 struct Hash
164 {
165 /**
166 * Hash function for object point ids.
167 * @param objectPointId The object point id to be hashed
168 * @return The hash value
169 */
170 inline size_t operator()(const ObjectPointId& objectPointId) const;
171 };
172
173 public:
174
175 /**
176 * Default constructor creating an invalid object point id.
177 */
178 ObjectPointId() = default;
179
180 /**
181 * Creates a new object point id.
182 * @param markerCoordinate The coordinate of the marker to which the object point belongs
183 * @param indexInMarker The index of the marker point, with range [0, 24]
184 */
185 inline ObjectPointId(const MarkerCoordinate& markerCoordinate, const size_t indexInMarker);
186
187 /**
188 * Returns the coordinate of the marker to which the object point belongs.
189 * @return The marker coordinate
190 */
191 inline const MarkerCoordinate& markerCoordinate() const;
192
193 /**
194 * Returns the index of the marker point, with range [0, 24].
195 * @return The index of the marker point
196 */
197 inline size_t indexInMarker() const;
198
199 /**
200 * Returns whether this object point id is valid.
201 * @return True, if so
202 */
203 inline bool isValid() const;
204
205 /**
206 * Returns whether two object point ids are identical.
207 * @param objectPointId The second object point id to compare
208 * @return True, if so
209 */
210 inline bool operator==(const ObjectPointId& objectPointId) const;
211
212 protected:
213
214 /// The coordinate of the marker to which the object point belongs.
216
217 /// The index of the marker point, with range [0, 24].
218 size_t indexInMarker_ = size_t(-1);
219 };
220
221 /**
222 * Definition of a vector holding object point ids.
223 */
224 using ObjectPointIds = std::vector<ObjectPointId>;
225
226 /**
227 * Definition of an unordered set holding object point ids.
228 */
229 using ObjectPointIdSet = std::unordered_set<ObjectPointId, ObjectPointId::Hash>;
230
231 protected:
232
233 /**
234 * Definition of an unordered map mapping unique values for pairs of markers to counters.
235 */
236 using NeighborMap = std::unordered_map<uint64_t, unsigned int>;
237
238 /**
239 * Definition of an unordered map mapping marker types to marker coordinates.
240 */
241 using MarkerIdMap = std::unordered_map<BoardMarker::MarkerType, MarkerCoordinates>;
242
243 public:
244
245 /**
246 * Default constructor creating an invalid calibration board.
247 */
248 CalibrationBoard() = default;
249
250 /**
251 * Default copy constructor.
252 * @param calibrationBoard The calibration board to copy
253 */
254 CalibrationBoard(const CalibrationBoard& calibrationBoard) = default;
255
256 /**
257 * Creates a new calibration board.
258 * @param xMarkers The number of horizontal markers the calibration board will have, with range [1, infinity)
259 * @param yMarkers The number of vertical markers the calibration board will have, with range [1, infinity)
260 * @param boardMarkers The board markers of the calibration board, must be xMarkers * yMarkers markers
261 */
262 CalibrationBoard(const size_t xMarkers, const size_t yMarkers, BoardMarkers&& boardMarkers);
263
264 /**
265 * Returns the hash of this calibration board.
266 * @return The calibration board's hash
267 */
268 inline uint64_t hash() const;
269
270 /**
271 * Returns the board marker at a specific position.
272 * @param markerCoordinate The coordinate of the marker to return, with range [0, xMarkers() - 1]x[0, yMarkers() - 1]
273 * @return The board marker at the specified position
274 */
275 inline const BoardMarker& marker(const MarkerCoordinate& markerCoordinate) const;
276
277 /**
278 * Returns the board marker at a specific position.
279 * @param xMarker The horizontal position of the marker, with range [0, xMarkers() - 1]
280 * @param yMarker The vertical position of the marker, with range [0, yMarkers() - 1]
281 * @return The board marker at the specified position
282 */
283 inline const BoardMarker& marker(const size_t xMarker, const size_t yMarker) const;
284
285 /**
286 * Returns the number of horizontal markers of this calibration board.
287 * @return The calibration board's number of horizontal markers, with range [1, infinity)
288 */
289 inline size_t xMarkers() const;
290
291 /**
292 * Returns the number of vertical markers of this calibration board.
293 * @return The calibration board's number of vertical markers, with range [1, infinity)
294 */
295 inline size_t yMarkers() const;
296
297 /**
298 * Returns the number of markers of this calibration board.
299 * @return The calibration board's number of markers, which is xMarkers() * yMarkers(), with range [1, infinity)
300 */
301 inline size_t markers() const;
302
303 /**
304 * Returns the number of points of this calibration board.
305 * @return The calibration board's number of points, which is markers() * Marker::numberPoints(), with range [1, infinity)
306 */
307 inline size_t numberPoints() const;
308
309 /**
310 * Checks whether this calibration board contains a marker candidate with it's specified neighboring marker candidates.
311 * @param markerCandidates All marker candidates, at least one
312 * @param markerCandidateIndex The index of the marker candidate to check, with range [0, markerCandidates.size() - 1]
313 * @param markerCoordinate Optional resulting marker coordinate of the marker candidate, if the marker candidate is part of this calibration board; nullptr if not of interest
314 * @param neighborMarkerCoordinateMap Optional resulting neighbor map of the marker candidate; nullptr if not of interest
315 * @return True, if so
316 */
317 bool containsMarkerCandidateWithNeighborhood(const MarkerCandidates& markerCandidates, const size_t markerCandidateIndex, MarkerCoordinate* markerCoordinate = nullptr, NeighborMarkerCoordinateMap* neighborMarkerCoordinateMap = nullptr) const;
318
319 /**
320 * Returns whether this calibration board is valid.
321 * @return True, if so
322 */
323 inline bool isValid() const;
324
325 /**
326 * Default copy assignment operator.
327 * @param calibrationBoard The calibration board to assign
328 * @return Reference to this object
329 */
330 CalibrationBoard& operator=(const CalibrationBoard& calibrationBoard) = default;
331
332 /**
333 * Creates a unique calibration board based on a unique seed value and the number of markers the board has.
334 * In case the underlying random generator implementation is changing, the resulting calibration board may change as well.
335 * @param seed The seed value which is used for the random number generator to create a unique board, with range [0, infinity)
336 * @param xMarkers The number of horizontal markers the calibration board will have, with range [1, infinity)
337 * @param yMarkers The number of vertical markers the calibration board will have, with range [1, infinity)
338 * @param calibrationBoard The resulting calibration board
339 * @return True, if succeeded
340 */
341 static bool createCalibrationBoard(const unsigned int seed, const size_t xMarkers, const size_t yMarkers, CalibrationBoard& calibrationBoard);
342
343 /**
344 * Determines the optimal marker grid for a calibration board with specific aspect ratio and number of markers.
345 * @param aspectRatio The aspect ratio of the calibration board (width/height), with range (0, infinity)
346 * @param minimalNumberMarkers The minimal number of markers of the calibration board will have, with range [1, infinity)
347 * @param xMarkers The resulting number of horizontal markers, with range [1, infinity)
348 * @param yMarkers The resulting number of vertical markers, with range [1, infinity)
349 * @return True, if succeeded
350 */
351 static bool determineOptimalMarkerGrid(const double aspectRatio, const size_t minimalNumberMarkers, size_t& xMarkers, size_t& yMarkers);
352
353 /**
354 * Determines the optimal marker grid for a calibration board with specific aspect ratio and number of horizontal markers.
355 * @param aspectRatio The aspect ratio of the calibration board (width/height), with range (0, infinity)
356 * @param xMarkers The number of horizontal markers, with range [1, infinity)
357 * @param yMarkers The resulting number of vertical markers, with range [1, infinity)
358 * @return True, if succeeded
359 */
360 static bool determineOptimalMarkerGrid(const double aspectRatio, const size_t xMarkers, size_t& yMarkers);
361
362 /**
363 * Determines the uniqueness between two calibration board.
364 * @param calibrationBoardA The first calibration board, must be valid
365 * @param calibrationBoardB The second calibration board, must be valid
366 * @param oneIdenticalNeighborCounter The number of identical 1-neighbor pairs both calibration boards have in common, with range [0, infinity)
367 * @param twoIdenticalNeighborCounter The number of identical 2-neighbor pairs both calibration boards have in common, with range [0, infinity)
368 * @param threeIdenticalNeighborCounter The number of identical 3-neighbor pairs both calibration boards have in common, with range [0, infinity)
369 * @return True, if succeeded
370 */
371 static bool determineUniqueness(const CalibrationBoard& calibrationBoardA, const CalibrationBoard& calibrationBoardB, size_t& oneIdenticalNeighborCounter, size_t& twoIdenticalNeighborCounter, size_t& threeIdenticalNeighborCounter);
372
373 /**
374 * Returns a representative hash based on the properties of the calibration board.
375 * The hash is computed from the board dimensions and all marker properties (id, sign, orientation, coordinate).
376 * @param calibrationBoard The calibration board for which the hash will be computed, must be valid
377 * @return The resulting hash value
378 */
379 static uint64_t hash(const CalibrationBoard& calibrationBoard);
380
381 protected:
382
383 /**
384 * Checks whether this calibration board contains a board marker with specific marker type.
385 * @param markerCandidate The marker candidate to check, must have a valid marker id and sign
386 * @param markerCoordinates Optional resulting marker coordinates of all markers with same id and sign, at most four; nullptr if not of interest
387 * @return True, if so
388 */
389 bool containsMarkerTypeIgnoringNeighborhood(const MarkerCandidate& markerCandidate, MarkerCoordinates* markerCoordinates = nullptr) const;
390
391 /**
392 * Creates unique board markers for a calibration board with specific id and number of markers.
393 * The resulting markers are unique in the sense that the 4-neighborhood of each marker is unique in the board and cannot be found again in the same board.
394 * The provided id is used as a seed for the random number generator.
395 * @param id The unique id (the seed) of the calibration board, with range [0, infinity)
396 * @param xMarkers The number of horizontal markers the calibration board will have, with range [1, infinity)
397 * @param yMarkers The number of vertical markers the calibration board will have, with range [1, infinity)
398 * @param boardMarkers The resulting board markers of the calibration board
399 * @return True, if succeeded; False, if the provided id and number of markers does not allow to create a unique board
400 */
401 static bool createUniqueBoardMarkers(const unsigned int id, const size_t xMarkers, const size_t yMarkers, BoardMarkers& boardMarkers);
402
403 /**
404 * Returns a unique value for a pairs of neighboring board markers.
405 * The unique id contains the marker types, and the mutual orientation of the markers.
406 * @param boardMarker The first board marker, must be valid
407 * @param neighborBoardMarker The second (neighbor) board marker, must be valid
408 * @return The unique value for the pair of board markers
409 */
410 static uint64_t uniqueValueOrientedNeighborhood(const BoardMarker& boardMarker, const BoardMarker& neighborBoardMarker);
411
412 /**
413 * Combines two unique values to one unique value.
414 * @param valueA The first unique value, must be valid
415 * @param valueB The second unique value, must be valid
416 * @return The combined unique value
417 */
418 static uint64_t uniqueValue(const uint32_t valueA, const uint32_t valueB);
419
420 protected:
421
422 /// The number of horizontal markers of this calibration board, with range [1, infinity).
423 size_t xMarkers_ = 0;
424
425 /// The number of vertical markers of this calibration board, with range [1, infinity).
426 size_t yMarkers_ = 0;
427
428 /// The board markers of this calibration board, with xMarkers_ * yMarkers_ markers.
430
431 /// The map mapping marker types to marker coordinates (allows to determine the marker coordinates of all markers with specific id and sign).
433
434 /// The hash of this calibration board.
435 uint64_t hash_ = 0ull;
436};
437
438inline CalibrationBoard::BoardMarker::BoardMarker(const size_t markerId, const bool sign, const CV::PixelDirection orientation, const MarkerCoordinate& coordinate) :
439 Marker(markerId, sign),
440 orientation_(orientation),
441 board_R_marker_(Vector3(0, 1, 0), Numeric::deg2rad(Scalar(orientation))),
442 coordinate_(coordinate)
443{
444 ocean_assert(isValid());
445}
446
448{
449 return orientation_;
450}
451
453{
454 return coordinate_;
455}
456
457template <bool tOriented>
458inline bool CalibrationBoard::BoardMarker::pointSign(const size_t x, const size_t y) const
459{
460 ocean_assert(isValid());
461
462 if constexpr (tOriented)
463 {
464 // the defined point coordinates x and y are defined within the marker's orientation, so we don't need to rotate the coordinates
465
466 return LayoutManager::layoutPointSign(markerId(), sign(), CV::PD_NORTH, x, y);
467 }
468 else
469 {
470 // the defined point coordinates x and y are defined within the marker's unoriented layout
471
472 return LayoutManager::layoutPointSign(markerId(), sign(), orientation(), x, y);
473 }
474}
475
476template <bool tOriented>
477inline bool CalibrationBoard::BoardMarker::pointSign(const size_t indexInMarker) const
478{
479 ocean_assert(isValid());
480
481 if constexpr (tOriented)
482 {
483 // the defined point index is defined within the marker's orientation, so we don't need to rotate the index
484
485 return LayoutManager::layoutPointSign(markerId(), sign(), CV::PD_NORTH, indexInMarker);
486 }
487 else
488 {
489 // the defined point index is defined within the marker's unoriented layout
490
491 return LayoutManager::layoutPointSign(markerId(), sign(), orientation(), indexInMarker);
492 }
493}
494
496{
497 ocean_assert(orientation_ == CV::PD_INVALID || board_R_marker_.isValid());
498
499 return Marker::isValid() && orientation_ != CV::PD_INVALID && coordinate_.isValid();
500}
501
503{
504 size_t seed = std::hash<unsigned int>{}(objectPointId.markerCoordinate_.x());
505 seed ^= std::hash<unsigned int>{}(objectPointId.markerCoordinate_.y()) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
506 seed ^= std::hash<size_t>{}(objectPointId.indexInMarker_) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
507
508 return seed;
509}
510
511inline CalibrationBoard::ObjectPointId::ObjectPointId(const MarkerCoordinate& markerCoordinate, const size_t indexInMarker) :
512 markerCoordinate_(markerCoordinate),
513 indexInMarker_(indexInMarker)
514{
515 ocean_assert(isValid());
516}
517
519{
520 return markerCoordinate_;
521}
522
524{
525 return indexInMarker_;
526}
527
529{
530 return markerCoordinate_.isValid() && indexInMarker_ < 25;
531}
532
533inline bool CalibrationBoard::ObjectPointId::operator==(const ObjectPointId& objectPointId) const
534{
535 return objectPointId.markerCoordinate_ == markerCoordinate_ && objectPointId.indexInMarker_ == indexInMarker_;
536}
537
538inline uint64_t CalibrationBoard::hash() const
539{
540 return hash_;
541}
542
544{
545 ocean_assert(markerCoordinate.x() < xMarkers_);
546 ocean_assert(markerCoordinate.y() < yMarkers_);
547
548 return boardMarkers_[xMarkers_ * markerCoordinate.y() + markerCoordinate.x()];
549}
550
551inline const CalibrationBoard::BoardMarker& CalibrationBoard::marker(const size_t xMarker, const size_t yMarker) const
552{
553 return marker(MarkerCoordinate((unsigned int)(xMarker), (unsigned int)(yMarker)));
554}
555
556inline size_t CalibrationBoard::xMarkers() const
557{
558 return xMarkers_;
559}
560
561inline size_t CalibrationBoard::yMarkers() const
562{
563 return yMarkers_;
564}
565
566inline size_t CalibrationBoard::markers() const
567{
568 ocean_assert(isValid());
569 ocean_assert(boardMarkers_.size() == xMarkers_ * yMarkers_);
570
571 return boardMarkers_.size();
572}
573
575{
576 return markers() * Marker::numberPoints();
577}
578
579inline bool CalibrationBoard::isValid() const
580{
581 return xMarkers_ >= 1 && yMarkers_ >= 1;
582}
583
584}
585
586}
587
588}
589
590#endif // META_OCEAN_CV_CALIBRATION_CALIBRATION_BOARD_H
This class implements a marker in a calibration board.
Definition CalibrationBoard.h:50
bool isValid() const
Returns whether this board maker is valid.
Definition CalibrationBoard.h:495
bool pointSign(const size_t x, const size_t y) const
Returns the sign of point in this marker.
Definition CalibrationBoard.h:458
MarkerCoordinate boardMarkerNeighborCoordinate(const CV::PixelDirection &neighborDirection, const size_t xMarkers, const size_t yMarkers) const
Returns the marker coordinate for a neighbor marker.
MarkerCoordinate coordinate_
The coordinate of the marker in the calibration board, with range [0, CalibrationBoard::xMarkers() - ...
Definition CalibrationBoard.h:135
Vector3 objectPoint(const Vector3 &markerPosition, const Scalar xMarkerSize, const Scalar zMarkerSize, const size_t indexInMarker) const
Returns the 3D object point of a marker point of this board marker in the coordinate system of the ca...
BoardMarker(const size_t markerId, const bool sign, const CV::PixelDirection orientation, const MarkerCoordinate &coordinate)
Creates a new valid board marker.
Definition CalibrationBoard.h:438
CV::PixelDirection orientation() const
Returns the orientation of this marker in relation to the calibration board.
Definition CalibrationBoard.h:447
CV::PixelDirection neighborDirection(const BoardMarker &neighborBoardMarker) const
Returns the direction to a neighbor marker in relation to this marker's orientation.
const MarkerCoordinate & coordinate() const
Returns the coordinate of this marker within the calibration board.
Definition CalibrationBoard.h:452
Definition of an object point id composed of a marker coordinate and marker point index.
Definition CalibrationBoard.h:157
const MarkerCoordinate & markerCoordinate() const
Returns the coordinate of the marker to which the object point belongs.
Definition CalibrationBoard.h:518
MarkerCoordinate markerCoordinate_
The coordinate of the marker to which the object point belongs.
Definition CalibrationBoard.h:215
size_t indexInMarker() const
Returns the index of the marker point, with range [0, 24].
Definition CalibrationBoard.h:523
size_t indexInMarker_
The index of the marker point, with range [0, 24].
Definition CalibrationBoard.h:218
bool isValid() const
Returns whether this object point id is valid.
Definition CalibrationBoard.h:528
bool operator==(const ObjectPointId &objectPointId) const
Returns whether two object point ids are identical.
Definition CalibrationBoard.h:533
ObjectPointId()=default
Default constructor creating an invalid object point id.
This class implements a basic calibration board.
Definition CalibrationBoard.h:38
uint64_t hash() const
Returns the hash of this calibration board.
Definition CalibrationBoard.h:538
std::vector< BoardMarker > BoardMarkers
Definition of a vector holding board markers.
Definition CalibrationBoard.h:141
size_t xMarkers() const
Returns the number of horizontal markers of this calibration board.
Definition CalibrationBoard.h:556
static bool createUniqueBoardMarkers(const unsigned int id, const size_t xMarkers, const size_t yMarkers, BoardMarkers &boardMarkers)
Creates unique board markers for a calibration board with specific id and number of markers.
size_t numberPoints() const
Returns the number of points of this calibration board.
Definition CalibrationBoard.h:574
const BoardMarker & marker(const MarkerCoordinate &markerCoordinate) const
Returns the board marker at a specific position.
Definition CalibrationBoard.h:543
static bool determineUniqueness(const CalibrationBoard &calibrationBoardA, const CalibrationBoard &calibrationBoardB, size_t &oneIdenticalNeighborCounter, size_t &twoIdenticalNeighborCounter, size_t &threeIdenticalNeighborCounter)
Determines the uniqueness between two calibration board.
std::unordered_set< ObjectPointId, ObjectPointId::Hash > ObjectPointIdSet
Definition of an unordered set holding object point ids.
Definition CalibrationBoard.h:229
size_t xMarkers_
The number of horizontal markers of this calibration board, with range [1, infinity).
Definition CalibrationBoard.h:423
CV::PixelPosition MarkerCoordinate
Definition of a coordinate for markers.
Definition CalibrationBoard.h:44
size_t yMarkers() const
Returns the number of vertical markers of this calibration board.
Definition CalibrationBoard.h:561
std::vector< ObjectPointId > ObjectPointIds
Definition of a vector holding object point ids.
Definition CalibrationBoard.h:224
static bool createCalibrationBoard(const unsigned int seed, const size_t xMarkers, const size_t yMarkers, CalibrationBoard &calibrationBoard)
Creates a unique calibration board based on a unique seed value and the number of markers the board h...
static uint64_t uniqueValue(const uint32_t valueA, const uint32_t valueB)
Combines two unique values to one unique value.
MarkerIdMap markerIdMap_
The map mapping marker types to marker coordinates (allows to determine the marker coordinates of all...
Definition CalibrationBoard.h:432
BoardMarkers boardMarkers_
The board markers of this calibration board, with xMarkers_ * yMarkers_ markers.
Definition CalibrationBoard.h:429
bool isValid() const
Returns whether this calibration board is valid.
Definition CalibrationBoard.h:579
std::unordered_map< uint64_t, unsigned int > NeighborMap
Definition of an unordered map mapping unique values for pairs of markers to counters.
Definition CalibrationBoard.h:236
uint64_t hash_
The hash of this calibration board.
Definition CalibrationBoard.h:435
bool containsMarkerTypeIgnoringNeighborhood(const MarkerCandidate &markerCandidate, MarkerCoordinates *markerCoordinates=nullptr) const
Checks whether this calibration board contains a board marker with specific marker type.
CalibrationBoard(const size_t xMarkers, const size_t yMarkers, BoardMarkers &&boardMarkers)
Creates a new calibration board.
static bool determineOptimalMarkerGrid(const double aspectRatio, const size_t minimalNumberMarkers, size_t &xMarkers, size_t &yMarkers)
Determines the optimal marker grid for a calibration board with specific aspect ratio and number of m...
size_t markers() const
Returns the number of markers of this calibration board.
Definition CalibrationBoard.h:566
CalibrationBoard()=default
Default constructor creating an invalid calibration board.
CalibrationBoard(const CalibrationBoard &calibrationBoard)=default
Default copy constructor.
static bool determineOptimalMarkerGrid(const double aspectRatio, const size_t xMarkers, size_t &yMarkers)
Determines the optimal marker grid for a calibration board with specific aspect ratio and number of h...
std::unordered_map< CV::PixelDirection, MarkerCoordinate > NeighborMarkerCoordinateMap
Definition of a map mapping neighbor directions to (up to four) marker coordinates.
Definition CalibrationBoard.h:151
static uint64_t hash(const CalibrationBoard &calibrationBoard)
Returns a representative hash based on the properties of the calibration board.
size_t yMarkers_
The number of vertical markers of this calibration board, with range [1, infinity).
Definition CalibrationBoard.h:426
static uint64_t uniqueValueOrientedNeighborhood(const BoardMarker &boardMarker, const BoardMarker &neighborBoardMarker)
Returns a unique value for a pairs of neighboring board markers.
bool containsMarkerCandidateWithNeighborhood(const MarkerCandidates &markerCandidates, const size_t markerCandidateIndex, MarkerCoordinate *markerCoordinate=nullptr, NeighborMarkerCoordinateMap *neighborMarkerCoordinateMap=nullptr) const
Checks whether this calibration board contains a marker candidate with it's specified neighboring mar...
CalibrationBoard & operator=(const CalibrationBoard &calibrationBoard)=default
Default copy assignment operator.
std::unordered_map< BoardMarker::MarkerType, MarkerCoordinates > MarkerIdMap
Definition of an unordered map mapping marker types to marker coordinates.
Definition CalibrationBoard.h:241
This class implements a candidate of a marker.
Definition MarkerCandidate.h:48
This class implements the base class for a marker in a calibration board.
Definition Marker.h:27
bool isValid() const
Returns whether this marker is associated with a valid id and a valid sign.
Definition Marker.h:323
static constexpr size_t numberPoints()
Returns the number of points each marker has.
Definition Marker.h:333
T y() const
Returns the vertical coordinate position of this object.
Definition PixelPosition.h:468
T x() const
Returns the horizontal coordinate position of this object.
Definition PixelPosition.h:456
This class provides basic numeric functionalities.
Definition Numeric.h:57
This class implements a static vector that has a fixed capacity.
Definition StaticVector.h:25
PixelDirection
Definition of individual directions with pixel accuracy.
Definition CV.h:85
@ PD_INVALID
Definition CV.h:87
@ PD_NORTH
Definition CV.h:89
std::vector< MarkerCandidate > MarkerCandidates
Definition of a vector holding marker candidates.
Definition MarkerCandidate.h:33
float Scalar
Definition of a scalar type.
Definition Math.h:129
The namespace covering the entire Ocean framework.
Definition Accessor.h:15
Definition of a hash object for object point ids.
Definition CalibrationBoard.h:164
size_t operator()(const ObjectPointId &objectPointId) const
Hash function for object point ids.
Definition CalibrationBoard.h:502