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;
170 inline size_t operator()(
const ObjectPointId& objectPointId)
const;
197 inline size_t indexInMarker()
const;
203 inline bool isValid()
const;
210 inline bool operator==(
const ObjectPointId& objectPointId)
const;
241 using MarkerIdMap = std::unordered_map<BoardMarker::MarkerType, MarkerCoordinates>;
268 inline uint64_t hash()
const;
283 inline const BoardMarker& marker(
const size_t xMarker,
const size_t yMarker)
const;
289 inline size_t xMarkers()
const;
295 inline size_t yMarkers()
const;
301 inline size_t markers()
const;
307 inline size_t numberPoints()
const;
323 inline bool isValid()
const;
411 static uint64_t
uniqueValue(
const uint32_t valueA,
const uint32_t valueB);
416 size_t xMarkers_ = 0;
419 size_t yMarkers_ = 0;
428 uint64_t hash_ = 0ull;
433 orientation_(orientation),
435 coordinate_(coordinate)
450template <
bool tOriented>
455 if constexpr (tOriented)
459 return LayoutManager::layoutPointSign(markerId(), sign(),
CV::PD_NORTH, x, y);
465 return LayoutManager::layoutPointSign(markerId(), sign(), orientation(), x, y);
469template <
bool tOriented>
474 if constexpr (tOriented)
478 return LayoutManager::layoutPointSign(markerId(), sign(),
CV::PD_NORTH, indexInMarker);
484 return LayoutManager::layoutPointSign(markerId(), sign(), orientation(), indexInMarker);
490 ocean_assert(orientation_ ==
CV::PD_INVALID || board_R_marker_.isValid());
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);
505 markerCoordinate_(markerCoordinate),
506 indexInMarker_(indexInMarker)
513 return markerCoordinate_;
518 return indexInMarker_;
523 return markerCoordinate_.isValid() && indexInMarker_ < 25;
538 ocean_assert(markerCoordinate.
x() <
xMarkers_);
539 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: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