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 static vector allowing to store up to four marker coordinates.
140 */
142
143 /**
144 * Definition of a map mapping neighbor directions to (up to four) marker coordinates.
145 */
146 using NeighborMarkerCoordinateMap = std::unordered_map<CV::PixelDirection, MarkerCoordinate>;
147
148 /**
149 * Definition of an object point id composed of a marker coordinate and marker point index.
150 */
152 {
153 public:
154
155 /**
156 * Definition of a hash object for object point ids.
157 */
158 struct Hash
159 {
160 /**
161 * Hash function for object point ids.
162 * @param objectPointId The object point id to be hashed
163 * @return The hash value
164 */
165 inline size_t operator()(const ObjectPointId& objectPointId) const;
166 };
167
168 public:
169
170 /**
171 * Default constructor creating an invalid object point id.
172 */
173 ObjectPointId() = default;
174
175 /**
176 * Creates a new object point id.
177 * @param markerCoordinate The coordinate of the marker to which the object point belongs
178 * @param indexInMarker The index of the marker point, with range [0, 24]
179 */
180 inline ObjectPointId(const MarkerCoordinate& markerCoordinate, const size_t indexInMarker);
181
182 /**
183 * Returns the coordinate of the marker to which the object point belongs.
184 * @return The marker coordinate
185 */
186 inline const MarkerCoordinate& markerCoordinate() const;
187
188 /**
189 * Returns the index of the marker point, with range [0, 24].
190 * @return The index of the marker point
191 */
192 inline size_t indexInMarker() const;
193
194 /**
195 * Returns whether this object point id is valid.
196 * @return True, if so
197 */
198 inline bool isValid() const;
199
200 /**
201 * Returns whether two object point ids are identical.
202 * @param objectPointId The second object point id to compare
203 * @return True, if so
204 */
205 inline bool operator==(const ObjectPointId& objectPointId) const;
206
207 protected:
208
209 /// The coordinate of the marker to which the object point belongs.
211
212 /// The index of the marker point, with range [0, 24].
213 size_t indexInMarker_ = size_t(-1);
214 };
215
216 /**
217 * Definition of a vector holding object point ids.
218 */
219 using ObjectPointIds = std::vector<ObjectPointId>;
220
221 /**
222 * Definition of an unordered set holding object point ids.
223 */
224 using ObjectPointIdSet = std::unordered_set<ObjectPointId, ObjectPointId::Hash>;
225
226 protected:
227
228 /**
229 * Definition of a vector holding board markers.
230 */
231 using BoardMarkers = std::vector<BoardMarker>;
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 id The unique id of the calibration board, with range [0, infinity)
259 * @param xMarkers The number of horizontal markers the calibration board will have, with range [1, infinity)
260 * @param yMarkers The number of vertical markers the calibration board will have, with range [1, infinity)
261 * @param boardMarkers The board markers of the calibration board, must be xMarkers * yMarkers markers
262 */
263 CalibrationBoard(const unsigned int id, const size_t xMarkers, const size_t yMarkers, BoardMarkers&& boardMarkers);
264
265 /**
266 * Returns the id of this calibration board.
267 * @return The calibration board's id, with range [0, infinity)
268 */
269 inline unsigned int id() const;
270
271 /**
272 * Returns the board marker at a specific position.
273 * @param markerCoordinate The coordinate of the marker to return, with range [0, xMarkers() - 1]x[0, yMarkers() - 1]
274 * @return The board marker at the specified position
275 */
276 inline const BoardMarker& marker(const MarkerCoordinate& markerCoordinate) const;
277
278 /**
279 * Returns the board marker at a specific position.
280 * @param xMarker The horizontal position of the marker, with range [0, xMarkers() - 1]
281 * @param yMarker The vertical position of the marker, with range [0, yMarkers() - 1]
282 * @return The board marker at the specified position
283 */
284 inline const BoardMarker& marker(const size_t xMarker, const size_t yMarker) const;
285
286 /**
287 * Returns the number of horizontal markers of this calibration board.
288 * @return The calibration board's number of horizontal markers, with range [1, infinity)
289 */
290 inline size_t xMarkers() const;
291
292 /**
293 * Returns the number of vertical markers of this calibration board.
294 * @return The calibration board's number of vertical markers, with range [1, infinity)
295 */
296 inline size_t yMarkers() const;
297
298 /**
299 * Returns the number of markers of this calibration board.
300 * @return The calibration board's number of markers, which is xMarkers() * yMarkers(), with range [1, infinity)
301 */
302 inline size_t markers() const;
303
304 /**
305 * Returns the number of points of this calibration board.
306 * @return The calibration board's number of points, which is markers() * Marker::numberPoints(), with range [1, infinity)
307 */
308 inline size_t numberPoints() const;
309
310 /**
311 * Checks whether this calibration board contains a marker candidate with it's specified neighboring marker candidates.
312 * @param markerCandidates All marker candidates, at least one
313 * @param markerCandidateIndex The index of the marker candidate to check, with range [0, markerCandidates.size() - 1]
314 * @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
315 * @param neighborMarkerCoordinateMap Optional resulting neighbor map of the marker candidate; nullptr if not of interest
316 * @return True, if so
317 */
318 bool containsMarkerCandidateWithNeighborhood(const MarkerCandidates& markerCandidates, const size_t markerCandidateIndex, MarkerCoordinate* markerCoordinate = nullptr, NeighborMarkerCoordinateMap* neighborMarkerCoordinateMap = nullptr) const;
319
320 /**
321 * Returns whether this calibration board is valid.
322 * @return True, if so
323 */
324 inline bool isValid() const;
325
326 /**
327 * Creates a unique calibration board based on a unique board id (the seed) and the number of markers the board has.
328 * @param id The unique board id defining the seed for the random number generator, 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 id, 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 protected:
367
368 /**
369 * Checks whether this calibration board contains a board marker with specific marker type.
370 * @param markerCandidate The marker candidate to check, must have a valid marker id and sign
371 * @param markerCoordinates Optional resulting marker coordinates of all markers with same id and sign, at most four; nullptr if not of interest
372 * @return True, if so
373 */
374 bool containsMarkerTypeIgnoringNeighborhood(const MarkerCandidate& markerCandidate, MarkerCoordinates* markerCoordinates = nullptr) const;
375
376 /**
377 * Creates unique board markers for a calibration board with specific id and number of markers.
378 * 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.
379 * The provided id is used as a seed for the random number generator.
380 * @param id The unique id (the seed) of the calibration board, with range [0, infinity)
381 * @param xMarkers The number of horizontal markers the calibration board will have, with range [1, infinity)
382 * @param yMarkers The number of vertical markers the calibration board will have, with range [1, infinity)
383 * @param boardMarkers The resulting board markers of the calibration board
384 * @return True, if succeeded; False, if the provided id and number of markers does not allow to create a unique board
385 */
386 static bool createUniqueBoardMarkers(const unsigned int id, const size_t xMarkers, const size_t yMarkers, BoardMarkers& boardMarkers);
387
388 /**
389 * Returns a unique value for a pairs of neighboring board markers.
390 * The unique id contains the marker types, and the mutual orientation of the markers.
391 * @param boardMarker The first board marker, must be valid
392 * @param neighborBoardMarker The second (neighbor) board marker, must be valid
393 * @return The unique value for the pair of board markers
394 */
395 static uint64_t uniqueValueOrientedNeighborhood(const BoardMarker& boardMarker, const BoardMarker& neighborBoardMarker);
396
397 /**
398 * Combines two unique values to one unique value.
399 * @param valueA The first unique value, must be valid
400 * @param valueB The second unique value, must be valid
401 * @return The combined unique value
402 */
403 static uint64_t uniqueValue(const uint32_t valueA, const uint32_t valueB);
404
405 protected:
406
407 /// The id of this calibration board, with range [0, infinity)
408 unsigned int id_ = (unsigned int)(-1);
409
410 /// The number of horizontal markers of this calibration board, with range [1, infinity).
411 size_t xMarkers_ = 0;
412
413 /// The number of vertical markers of this calibration board, with range [1, infinity).
414 size_t yMarkers_ = 0;
415
416 /// The board markers of this calibration board, with xMarkers_ * yMarkers_ markers.
418
419 /// The map mapping marker types to marker coordinates (allows to determine the marker coordinates of all markers with specific id and sign).
421};
422
423inline CalibrationBoard::BoardMarker::BoardMarker(const size_t markerId, const bool sign, const CV::PixelDirection orientation, const MarkerCoordinate& coordinate) :
424 Marker(markerId, sign),
425 orientation_(orientation),
426 board_R_marker_(Vector3(0, 1, 0), Numeric::deg2rad(Scalar(orientation))),
427 coordinate_(coordinate)
428{
429 ocean_assert(isValid());
430}
431
433{
434 return orientation_;
435}
436
438{
439 return coordinate_;
440}
441
442template <bool tOriented>
443inline bool CalibrationBoard::BoardMarker::pointSign(const size_t x, const size_t y) const
444{
445 ocean_assert(isValid());
446
447 if constexpr (tOriented)
448 {
449 // the defined point coordinates x and y are defined within the marker's orientation, so we don't need to rotate the coordinates
450
451 return LayoutManager::layoutPointSign(markerId(), sign(), CV::PD_NORTH, x, y);
452 }
453 else
454 {
455 // the defined point coordinates x and y are defined within the marker's unoriented layout
456
457 return LayoutManager::layoutPointSign(markerId(), sign(), orientation(), x, y);
458 }
459}
460
461template <bool tOriented>
462inline bool CalibrationBoard::BoardMarker::pointSign(const size_t indexInMarker) const
463{
464 ocean_assert(isValid());
465
466 if constexpr (tOriented)
467 {
468 // the defined point index is defined within the marker's orientation, so we don't need to rotate the index
469
470 return LayoutManager::layoutPointSign(markerId(), sign(), CV::PD_NORTH, indexInMarker);
471 }
472 else
473 {
474 // the defined point index is defined within the marker's unoriented layout
475
476 return LayoutManager::layoutPointSign(markerId(), sign(), orientation(), indexInMarker);
477 }
478}
479
481{
482 ocean_assert(orientation_ == CV::PD_INVALID || board_R_marker_.isValid());
483
484 return Marker::isValid() && orientation_ != CV::PD_INVALID && coordinate_.isValid();
485}
486
488{
489 size_t seed = std::hash<unsigned int>{}(objectPointId.markerCoordinate_.x());
490 seed ^= std::hash<unsigned int>{}(objectPointId.markerCoordinate_.y()) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
491 seed ^= std::hash<size_t>{}(objectPointId.indexInMarker_) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
492
493 return seed;
494}
495
496inline CalibrationBoard::ObjectPointId::ObjectPointId(const MarkerCoordinate& markerCoordinate, const size_t indexInMarker) :
497 markerCoordinate_(markerCoordinate),
498 indexInMarker_(indexInMarker)
499{
500 ocean_assert(isValid());
501}
502
504{
505 return markerCoordinate_;
506}
507
509{
510 return indexInMarker_;
511}
512
514{
515 return markerCoordinate_.isValid() && indexInMarker_ < 25;
516}
517
518inline bool CalibrationBoard::ObjectPointId::operator==(const ObjectPointId& objectPointId) const
519{
520 return objectPointId.markerCoordinate_ == markerCoordinate_ && objectPointId.indexInMarker_ == indexInMarker_;
521}
522
523inline unsigned int CalibrationBoard::id() const
524{
525 return id_;
526}
527
529{
530 ocean_assert(markerCoordinate.x() < xMarkers_);
531 ocean_assert(markerCoordinate.y() < yMarkers_);
532
533 return boardMarkers_[xMarkers_ * markerCoordinate.y() + markerCoordinate.x()];
534}
535
536inline const CalibrationBoard::BoardMarker& CalibrationBoard::marker(const size_t xMarker, const size_t yMarker) const
537{
538 return marker(MarkerCoordinate((unsigned int)(xMarker), (unsigned int)(yMarker)));
539}
540
541inline size_t CalibrationBoard::xMarkers() const
542{
543 return xMarkers_;
544}
545
546inline size_t CalibrationBoard::yMarkers() const
547{
548 return yMarkers_;
549}
550
551inline size_t CalibrationBoard::markers() const
552{
553 ocean_assert(isValid());
554 ocean_assert(boardMarkers_.size() == xMarkers_ * yMarkers_);
555
556 return boardMarkers_.size();
557}
558
560{
561 return markers() * Marker::numberPoints();
562}
563
565{
566 return id_ != (unsigned int)(-1) && xMarkers_ >= 1 && yMarkers_ >= 1;
567}
568
569}
570
571}
572
573}
574
575#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:480
bool pointSign(const size_t x, const size_t y) const
Returns the sign of point in this marker.
Definition CalibrationBoard.h:443
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:423
CV::PixelDirection orientation() const
Returns the orientation of this marker in relation to the calibration board.
Definition CalibrationBoard.h:432
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:437
Definition of an object point id composed of a marker coordinate and marker point index.
Definition CalibrationBoard.h:152
const MarkerCoordinate & markerCoordinate() const
Returns the coordinate of the marker to which the object point belongs.
Definition CalibrationBoard.h:503
MarkerCoordinate markerCoordinate_
The coordinate of the marker to which the object point belongs.
Definition CalibrationBoard.h:210
size_t indexInMarker() const
Returns the index of the marker point, with range [0, 24].
Definition CalibrationBoard.h:508
size_t indexInMarker_
The index of the marker point, with range [0, 24].
Definition CalibrationBoard.h:213
bool isValid() const
Returns whether this object point id is valid.
Definition CalibrationBoard.h:513
bool operator==(const ObjectPointId &objectPointId) const
Returns whether two object point ids are identical.
Definition CalibrationBoard.h:518
ObjectPointId()=default
Default constructor creating an invalid object point id.
This class implements a basic calibration board.
Definition CalibrationBoard.h:38
std::vector< BoardMarker > BoardMarkers
Definition of a vector holding board markers.
Definition CalibrationBoard.h:231
size_t xMarkers() const
Returns the number of horizontal markers of this calibration board.
Definition CalibrationBoard.h:541
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:559
const BoardMarker & marker(const MarkerCoordinate &markerCoordinate) const
Returns the board marker at a specific position.
Definition CalibrationBoard.h:528
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:224
size_t xMarkers_
The number of horizontal markers of this calibration board, with range [1, infinity).
Definition CalibrationBoard.h:411
CV::PixelPosition MarkerCoordinate
Definition of a coordinate for markers.
Definition CalibrationBoard.h:44
CalibrationBoard(const unsigned int id, const size_t xMarkers, const size_t yMarkers, BoardMarkers &&boardMarkers)
Creates a new calibration board.
size_t yMarkers() const
Returns the number of vertical markers of this calibration board.
Definition CalibrationBoard.h:546
std::vector< ObjectPointId > ObjectPointIds
Definition of a vector holding object point ids.
Definition CalibrationBoard.h:219
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:420
BoardMarkers boardMarkers_
The board markers of this calibration board, with xMarkers_ * yMarkers_ markers.
Definition CalibrationBoard.h:417
bool isValid() const
Returns whether this calibration board is valid.
Definition CalibrationBoard.h:564
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
bool containsMarkerTypeIgnoringNeighborhood(const MarkerCandidate &markerCandidate, MarkerCoordinates *markerCoordinates=nullptr) const
Checks whether this calibration board contains a board marker with specific marker type.
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...
static bool createCalibrationBoard(const unsigned int id, const size_t xMarkers, const size_t yMarkers, CalibrationBoard &calibrationBoard)
Creates a unique calibration board based on a unique board id (the seed) and the number of markers th...
unsigned int id() const
Returns the id of this calibration board.
Definition CalibrationBoard.h:523
size_t markers() const
Returns the number of markers of this calibration board.
Definition CalibrationBoard.h:551
CalibrationBoard()=default
Default constructor creating an invalid calibration board.
CalibrationBoard(const CalibrationBoard &calibrationBoard)=default
Default copy constructor.
unsigned int id_
The id of this calibration board, with range [0, infinity)
Definition CalibrationBoard.h:408
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:146
size_t yMarkers_
The number of vertical markers of this calibration board, with range [1, infinity).
Definition CalibrationBoard.h:414
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:159
size_t operator()(const ObjectPointId &objectPointId) const
Hash function for object point ids.
Definition CalibrationBoard.h:487