8#ifndef META_OCEAN_CV_CALIBRATION_CALIBRATION_BOARD_H
9#define META_OCEAN_CV_CALIBRATION_CALIBRATION_BOARD_H
81 template <
bool tOriented>
82 inline bool pointSign(
const size_t x,
const size_t y)
const;
90 template <
bool tOriented>
91 inline bool pointSign(
const size_t indexInMarker)
const;
124 inline bool isValid()
const;
165 inline size_t operator()(
const ObjectPointId& objectPointId)
const;
192 inline size_t indexInMarker()
const;
198 inline bool isValid()
const;
205 inline bool operator==(
const ObjectPointId& objectPointId)
const;
241 using MarkerIdMap = std::unordered_map<BoardMarker::MarkerType, MarkerCoordinates>;
269 inline unsigned int id()
const;
284 inline const BoardMarker& marker(
const size_t xMarker,
const size_t yMarker)
const;
290 inline size_t xMarkers()
const;
296 inline size_t yMarkers()
const;
302 inline size_t markers()
const;
308 inline size_t numberPoints()
const;
324 inline bool isValid()
const;
403 static uint64_t
uniqueValue(
const uint32_t valueA,
const uint32_t valueB);
408 unsigned int id_ = (
unsigned int)(-1);
411 size_t xMarkers_ = 0;
414 size_t yMarkers_ = 0;
425 orientation_(orientation),
427 coordinate_(coordinate)
442template <
bool tOriented>
447 if constexpr (tOriented)
451 return LayoutManager::layoutPointSign(markerId(), sign(),
CV::PD_NORTH, x, y);
457 return LayoutManager::layoutPointSign(markerId(), sign(), orientation(), x, y);
461template <
bool tOriented>
466 if constexpr (tOriented)
470 return LayoutManager::layoutPointSign(markerId(), sign(),
CV::PD_NORTH, indexInMarker);
476 return LayoutManager::layoutPointSign(markerId(), sign(), orientation(), indexInMarker);
482 ocean_assert(orientation_ ==
CV::PD_INVALID || board_R_marker_.isValid());
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);
497 markerCoordinate_(markerCoordinate),
498 indexInMarker_(indexInMarker)
505 return markerCoordinate_;
510 return indexInMarker_;
515 return markerCoordinate_.isValid() && indexInMarker_ < 25;
530 ocean_assert(markerCoordinate.
x() <
xMarkers_);
531 ocean_assert(markerCoordinate.
y() <
yMarkers_);
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