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() - 1]
114 * @param yMarkers The number of vertical markers in the calibration board, with range [1, CalibrationBoard::yMarkers() - 1]
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 * Creates a unique calibration board based on a unique seed value and the number of markers the board has.
327 * In case the underlying random generator implementation is changing, the resulting calibration board may change as well.
328 * @param seed The seed value which is used for the random number generator to create a unique board, with range [0, infinity)
329 * @param xMarkers The number of horizontal markers the calibration board will have, with range [1, infinity)
330 * @param yMarkers The number of vertical markers the calibration board will have, with range [1, infinity)
331 * @param calibrationBoard The resulting calibration board
332 * @return True, if succeeded
333 */
334 static bool createCalibrationBoard(const unsigned int seed, const size_t xMarkers, const size_t yMarkers, CalibrationBoard& calibrationBoard);
335
336 /**
337 * Determines the optimal marker grid for a calibration board with specific aspect ratio and number of markers.
338 * @param aspectRatio The aspect ratio of the calibration board (width/height), with range (0, infinity)
339 * @param minimalNumberMarkers The minimal number of markers of the calibration board will have, with range [1, infinity)
340 * @param xMarkers The resulting number of horizontal markers, with range [1, infinity)
341 * @param yMarkers The resulting number of vertical markers, with range [1, infinity)
342 * @return True, if succeeded
343 */
344 static bool determineOptimalMarkerGrid(const double aspectRatio, const size_t minimalNumberMarkers, size_t& xMarkers, size_t& yMarkers);
345
346 /**
347 * Determines the optimal marker grid for a calibration board with specific aspect ratio and number of horizontal markers.
348 * @param aspectRatio The aspect ratio of the calibration board (width/height), with range (0, infinity)
349 * @param xMarkers The number of horizontal markers, with range [1, infinity)
350 * @param yMarkers The resulting number of vertical markers, with range [1, infinity)
351 * @return True, if succeeded
352 */
353 static bool determineOptimalMarkerGrid(const double aspectRatio, const size_t xMarkers, size_t& yMarkers);
354
355 /**
356 * Determines the uniqueness between two calibration board.
357 * @param calibrationBoardA The first calibration board, must be valid
358 * @param calibrationBoardB The second calibration board, must be valid
359 * @param oneIdenticalNeighborCounter The number of identical 1-neighbor pairs both calibration boards have in common, with range [0, infinity)
360 * @param twoIdenticalNeighborCounter The number of identical 2-neighbor pairs both calibration boards have in common, with range [0, infinity)
361 * @param threeIdenticalNeighborCounter The number of identical 3-neighbor pairs both calibration boards have in common, with range [0, infinity)
362 * @return True, if succeeded
363 */
364 static bool determineUniqueness(const CalibrationBoard& calibrationBoardA, const CalibrationBoard& calibrationBoardB, size_t& oneIdenticalNeighborCounter, size_t& twoIdenticalNeighborCounter, size_t& threeIdenticalNeighborCounter);
365
366 /**
367 * Returns a representative hash based on the properties of the calibration board.
368 * The hash is computed from the board dimensions and all marker properties (id, sign, orientation, coordinate).
369 * @param calibrationBoard The calibration board for which the hash will be computed, must be valid
370 * @return The resulting hash value
371 */
372 static uint64_t hash(const CalibrationBoard& calibrationBoard);
373
374 protected:
375
376 /**
377 * Checks whether this calibration board contains a board marker with specific marker type.
378 * @param markerCandidate The marker candidate to check, must have a valid marker id and sign
379 * @param markerCoordinates Optional resulting marker coordinates of all markers with same id and sign, at most four; nullptr if not of interest
380 * @return True, if so
381 */
382 bool containsMarkerTypeIgnoringNeighborhood(const MarkerCandidate& markerCandidate, MarkerCoordinates* markerCoordinates = nullptr) const;
383
384 /**
385 * Creates unique board markers for a calibration board with specific id and number of markers.
386 * 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.
387 * The provided id is used as a seed for the random number generator.
388 * @param id The unique id (the seed) of the calibration board, with range [0, infinity)
389 * @param xMarkers The number of horizontal markers the calibration board will have, with range [1, infinity)
390 * @param yMarkers The number of vertical markers the calibration board will have, with range [1, infinity)
391 * @param boardMarkers The resulting board markers of the calibration board
392 * @return True, if succeeded; False, if the provided id and number of markers does not allow to create a unique board
393 */
394 static bool createUniqueBoardMarkers(const unsigned int id, const size_t xMarkers, const size_t yMarkers, BoardMarkers& boardMarkers);
395
396 /**
397 * Returns a unique value for a pairs of neighboring board markers.
398 * The unique id contains the marker types, and the mutual orientation of the markers.
399 * @param boardMarker The first board marker, must be valid
400 * @param neighborBoardMarker The second (neighbor) board marker, must be valid
401 * @return The unique value for the pair of board markers
402 */
403 static uint64_t uniqueValueOrientedNeighborhood(const BoardMarker& boardMarker, const BoardMarker& neighborBoardMarker);
404
405 /**
406 * Combines two unique values to one unique value.
407 * @param valueA The first unique value, must be valid
408 * @param valueB The second unique value, must be valid
409 * @return The combined unique value
410 */
411 static uint64_t uniqueValue(const uint32_t valueA, const uint32_t valueB);
412
413 protected:
414
415 /// The number of horizontal markers of this calibration board, with range [1, infinity).
416 size_t xMarkers_ = 0;
417
418 /// The number of vertical markers of this calibration board, with range [1, infinity).
419 size_t yMarkers_ = 0;
420
421 /// The board markers of this calibration board, with xMarkers_ * yMarkers_ markers.
423
424 /// The map mapping marker types to marker coordinates (allows to determine the marker coordinates of all markers with specific id and sign).
426
427 /// The hash of this calibration board.
428 uint64_t hash_ = 0ull;
429};
430
431inline CalibrationBoard::BoardMarker::BoardMarker(const size_t markerId, const bool sign, const CV::PixelDirection orientation, const MarkerCoordinate& coordinate) :
432 Marker(markerId, sign),
433 orientation_(orientation),
434 board_R_marker_(Vector3(0, 1, 0), Numeric::deg2rad(Scalar(orientation))),
435 coordinate_(coordinate)
436{
437 ocean_assert(isValid());
438}
439
441{
442 return orientation_;
443}
444
446{
447 return coordinate_;
448}
449
450template <bool tOriented>
451inline bool CalibrationBoard::BoardMarker::pointSign(const size_t x, const size_t y) const
452{
453 ocean_assert(isValid());
454
455 if constexpr (tOriented)
456 {
457 // the defined point coordinates x and y are defined within the marker's orientation, so we don't need to rotate the coordinates
458
459 return LayoutManager::layoutPointSign(markerId(), sign(), CV::PD_NORTH, x, y);
460 }
461 else
462 {
463 // the defined point coordinates x and y are defined within the marker's unoriented layout
464
465 return LayoutManager::layoutPointSign(markerId(), sign(), orientation(), x, y);
466 }
467}
468
469template <bool tOriented>
470inline bool CalibrationBoard::BoardMarker::pointSign(const size_t indexInMarker) const
471{
472 ocean_assert(isValid());
473
474 if constexpr (tOriented)
475 {
476 // the defined point index is defined within the marker's orientation, so we don't need to rotate the index
477
478 return LayoutManager::layoutPointSign(markerId(), sign(), CV::PD_NORTH, indexInMarker);
479 }
480 else
481 {
482 // the defined point index is defined within the marker's unoriented layout
483
484 return LayoutManager::layoutPointSign(markerId(), sign(), orientation(), indexInMarker);
485 }
486}
487
489{
490 ocean_assert(orientation_ == CV::PD_INVALID || board_R_marker_.isValid());
491
492 return Marker::isValid() && orientation_ != CV::PD_INVALID && coordinate_.isValid();
493}
494
496{
497 size_t seed = std::hash<unsigned int>{}(objectPointId.markerCoordinate_.x());
498 seed ^= std::hash<unsigned int>{}(objectPointId.markerCoordinate_.y()) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
499 seed ^= std::hash<size_t>{}(objectPointId.indexInMarker_) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
500
501 return seed;
502}
503
504inline CalibrationBoard::ObjectPointId::ObjectPointId(const MarkerCoordinate& markerCoordinate, const size_t indexInMarker) :
505 markerCoordinate_(markerCoordinate),
506 indexInMarker_(indexInMarker)
507{
508 ocean_assert(isValid());
509}
510
512{
513 return markerCoordinate_;
514}
515
517{
518 return indexInMarker_;
519}
520
522{
523 return markerCoordinate_.isValid() && indexInMarker_ < 25;
524}
525
526inline bool CalibrationBoard::ObjectPointId::operator==(const ObjectPointId& objectPointId) const
527{
528 return objectPointId.markerCoordinate_ == markerCoordinate_ && objectPointId.indexInMarker_ == indexInMarker_;
529}
530
531inline uint64_t CalibrationBoard::hash() const
532{
533 return hash_;
534}
535
537{
538 ocean_assert(markerCoordinate.x() < xMarkers_);
539 ocean_assert(markerCoordinate.y() < yMarkers_);
540
541 return boardMarkers_[xMarkers_ * markerCoordinate.y() + markerCoordinate.x()];
542}
543
544inline const CalibrationBoard::BoardMarker& CalibrationBoard::marker(const size_t xMarker, const size_t yMarker) const
545{
546 return marker(MarkerCoordinate((unsigned int)(xMarker), (unsigned int)(yMarker)));
547}
548
549inline size_t CalibrationBoard::xMarkers() const
550{
551 return xMarkers_;
552}
553
554inline size_t CalibrationBoard::yMarkers() const
555{
556 return yMarkers_;
557}
558
559inline size_t CalibrationBoard::markers() const
560{
561 ocean_assert(isValid());
562 ocean_assert(boardMarkers_.size() == xMarkers_ * yMarkers_);
563
564 return boardMarkers_.size();
565}
566
568{
569 return markers() * Marker::numberPoints();
570}
571
573{
574 return xMarkers_ >= 1 && yMarkers_ >= 1;
575}
576
577}
578
579}
580
581}
582
583#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:488
bool pointSign(const size_t x, const size_t y) const
Returns the sign of point in this marker.
Definition CalibrationBoard.h:451
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:431
CV::PixelDirection orientation() const
Returns the orientation of this marker in relation to the calibration board.
Definition CalibrationBoard.h:440
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:445
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:511
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:516
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:521
bool operator==(const ObjectPointId &objectPointId) const
Returns whether two object point ids are identical.
Definition CalibrationBoard.h:526
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:531
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:549
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:567
const BoardMarker & marker(const MarkerCoordinate &markerCoordinate) const
Returns the board marker at a specific position.
Definition CalibrationBoard.h:536
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:416
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:554
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:425
BoardMarkers boardMarkers_
The board markers of this calibration board, with xMarkers_ * yMarkers_ markers.
Definition CalibrationBoard.h:422
bool isValid() const
Returns whether this calibration board is valid.
Definition CalibrationBoard.h:572
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:428
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:559
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:419
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...
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:495