8#ifndef META_OCEAN_CV_CALIBRATION_POINT_DETECTOR_H
9#define META_OCEAN_CV_CALIBRATION_POINT_DETECTOR_H
55 template <
unsigned int tNumber>
91 bool update(
const unsigned int filterSize,
const BorderShape borderShape,
const unsigned int width,
const unsigned int paddingElements);
124 unsigned int filterSize_ = 0u;
130 unsigned int width_ = 0u;
133 unsigned int paddingElements_ = 0u;
197 inline const Points& points()
const;
216 static bool detectPoints(
const Frame& yFrame,
const unsigned int filterSize,
Points& points,
const BorderShape borderShape,
const int32_t minimalDifference = 25,
const int32_t maximalDifference = 25 * 4,
Worker* worker =
nullptr);
230 static bool detectPoints(
const Frame& yFrame,
Points& points,
const uint32_t* borderOffsets,
const size_t numberBorderOffsets,
const unsigned int filterSize,
const int32_t minimalDifference = 25,
const int32_t maximalDifference = 25 * 4,
Worker* worker =
nullptr);
278 template <
unsigned int tNumber,
bool tMatchSign>
309 static void detectPointCandidatesSubset(
const Frame* yFrame,
NonMaximumSuppressionVote* nonMaximumSuppression,
const uint32_t* borderOffsets,
const size_t numberBorderOffsets,
const unsigned int filterSize,
const int32_t minimalDifference,
const int32_t maximalDifference,
const unsigned int firstRow,
const unsigned int numberRows);
324 static void createFilterResponseFrameSubset(
const Frame* yFrame,
Frame* responseFrame,
const uint32_t* borderOffsets,
const size_t numberBorderOffsets,
const unsigned int filterSize,
const int32_t minimalDifference,
const int32_t maximalDifference,
const unsigned int firstRow,
const unsigned int numberRows);
337 static void determinePointCandidatesRow(
const unsigned int y,
const uint8_t* yRow,
NonMaximumSuppressionVote* nonMaximumSuppression,
const uint32_t* borderOffsets,
const size_t numberBorderOffsets,
const unsigned int filterSize,
const int32_t minimalDifference,
const int32_t maximalDifference);
351 static void determinePointCandidatesRowDual(
const unsigned int y,
const uint8_t* yRow,
NonMaximumSuppressionVote* nonMaximumSuppression,
const uint32_t* borderOffsets,
const size_t numberBorderOffsets,
const unsigned int filterSize,
const int32_t minimalDifference,
const int32_t maximalDifference);
364 static void createFilterResponseRow(
const uint8_t* yRow, int32_t* responseRow,
const unsigned int width,
const uint32_t* borderOffsets,
const size_t numberBorderOffsets,
const unsigned int filterSize,
const int32_t minimalDifference,
const int32_t maximalDifference);
378 static void createFilterResponseRowDual(
const uint8_t* yRow, int32_t* responseRow,
const unsigned int width,
const uint32_t* borderOffsets,
const size_t numberBorderOffsets,
const unsigned int filterSize,
const int32_t minimalDifference,
const int32_t maximalDifference);
380#if defined(OCEAN_HARDWARE_SSE_VERSION) && OCEAN_HARDWARE_SSE_VERSION >= 41
394 static void createFilterResponseRowSSE(
const uint8_t* yRow, int32_t* responseRow,
const unsigned int width,
const uint32_t* borderOffsets,
const size_t numberBorderOffsets,
const unsigned int filterSize,
const int32_t minimalDifference,
const int32_t maximalDifference);
409 static void createFilterResponseRowSSEDual(
const uint8_t* yRow, int32_t* responseRow,
const unsigned int width,
const uint32_t* borderOffsets,
const size_t numberBorderOffsets,
const unsigned int filterSize,
const int32_t minimalDifference,
const int32_t maximalDifference);
423 static void determinePointCandidatesRowSSE(
const unsigned int y,
const uint8_t* yRow,
NonMaximumSuppressionVote* nonMaximumSuppression,
const uint32_t* borderOffsets,
const size_t numberBorderOffsets,
const unsigned int filterSize,
const int32_t minimalDifference,
const int32_t maximalDifference);
441#if defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
455 static void createFilterResponseRowNEON(
const uint8_t* yRow, int32_t* responseRow,
const unsigned int width,
const uint32_t* borderOffsets,
const size_t numberBorderOffsets,
const unsigned int filterSize,
const int32_t minimalDifference,
const int32_t maximalDifference);
470 static void createFilterResponseRowNEONDual(
const uint8_t* yRow, int32_t* responseRow,
const unsigned int width,
const uint32_t* borderOffsets,
const size_t numberBorderOffsets,
const unsigned int filterSize,
const int32_t minimalDifference,
const int32_t maximalDifference);
484 static void determinePointCandidatesRowNEON(
const unsigned int y,
const uint8_t* yRow,
NonMaximumSuppressionVote* nonMaximumSuppression,
const uint32_t* borderOffsets,
const size_t numberBorderOffsets,
const unsigned int filterSize,
const int32_t minimalDifference,
const int32_t maximalDifference);
537 unsigned int filterSize_ = 7u;
540 int32_t minimalDifference_ = 25;
543 int32_t maximalDifference_ = 25 * 4;
563template <
unsigned int tNumber,
bool tMatchSign>
566 static_assert(tNumber >= 1u,
"Invalid number of points!");
568 ocean_assert(indexDistancePairs.
empty());
569 ocean_assert(queryPointIndex <
points.size());
571 const Vector2& point =
points[queryPointIndex].observation();
582 for (
const Index32& index : indices)
584 if (index ==
Index32(queryPointIndex))
589 if constexpr (tMatchSign)
591 if (
points[queryPointIndex].sign() !=
points[index].sign())
604 bool inserted =
false;
608 for (
size_t nCandidate = 0; nCandidate < indexDistancePairs.
size(); ++nCandidate)
610 if (
sqrDistance < indexDistancePairs[nCandidate].second)
612 if (indexDistancePairs.
size() != tNumber)
617 for (
size_t n = indexDistancePairs.
size() - 1; n > nCandidate; --n)
619 indexDistancePairs[n] = indexDistancePairs[n - 1];
631 if (!inserted && indexDistancePairs.
size() < tNumber)
This class implements debug elements for the calibration library.
Definition CalibrationDebugElements.h:43
This class manages the border pixel offsets used by the point detection filter.
Definition PointDetector.h:79
static bool determineBorderOffsets(const unsigned int strideElements, const unsigned int filterSize, const BorderShape borderShape, Indices32 &unsignedBorderOffsets)
Determines the 1D border offsets for a given filter size, border shape, and frame stride.
const Indices32 & offsets() const
Returns the 1D border offsets for the current filter configuration.
Definition PointDetector.h:558
static bool determineBorderOffsets(const unsigned int filterSize, const BorderShape borderShape, CV::PixelPositionsI &borderOffsets)
Determines the 2D border offsets for a given filter size and border shape.
Indices32 offsets_
The border offsets for the current filter configuration.
Definition PointDetector.h:136
bool update(const unsigned int filterSize, const BorderShape borderShape, const unsigned int width, const unsigned int paddingElements)
Updates the border offsets for a given filter configuration and frame layout.
This class implements a peak detector that refines the sub-pixel position of a detected point.
Definition PointDetector.h:144
bool determinePrecisePosition(const unsigned int x, const unsigned int y, const int32_t strength, Scalar &preciseX, Scalar &preciseY, int32_t &preciseStrength) const
Determines the precise sub-pixel position of a detected point.
PointPeakDetector(const Frame &yFrame)
Creates a new peak detector for a given grayscale frame.
const Frame & yFrame_
The grayscale frame used for peak refinement with pixel format FORMAT_Y8.
Definition PointDetector.h:168
This class implements a point detector for marker points.
Definition PointDetector.h:41
Points points_
The precise points detected in the latest frame.
Definition PointDetector.h:552
static bool createFilterResponseFrame(const Frame &yFrame, Frame &responseFrame, const unsigned int filterSize, const BorderShape borderShape, const int32_t minimalDifference=25, const int32_t maximalDifference=25 *4, Worker *worker=nullptr)
Creates a filter response frame for visualization or debugging.
static void removeDuplicatedPoints(const unsigned int width, const unsigned int height, Points &points, const Scalar maxDistance)
Removes duplicated points from a given set of points.
static bool detectPoints(const Frame &yFrame, const unsigned int filterSize, Points &points, const BorderShape borderShape, const int32_t minimalDifference=25, const int32_t maximalDifference=25 *4, Worker *worker=nullptr)
Detects points in a grayscale frame using a specified filter size and border shape.
static void createFilterResponseRowDual(const uint8_t *yRow, int32_t *responseRow, const unsigned int width, const uint32_t *borderOffsets, const size_t numberBorderOffsets, const unsigned int filterSize, const int32_t minimalDifference, const int32_t maximalDifference)
Creates a filter response row (dual-sign: both dark and bright points).
PointDetector()=default
Creates a new point detector.
static void determinePointCandidatesRowNEONDual(const unsigned int y, const uint8_t *yRow, NonMaximumSuppressionVote *nonMaximumSuppression, const uint32_t *borderOffsets, const size_t numberBorderOffsets, const unsigned int filterSize, const int32_t minimalDifference, const int32_t maximalDifference)
Determines point candidates for a single row using NEON SIMD instructions (dual-sign: both dark and b...
BorderShape
Definition of the border shape of the detection filter.
Definition PointDetector.h:62
@ BS_SQUARE
Square-shaped border (all pixels along the perimeter of a square).
Definition PointDetector.h:66
Geometry::SpatialDistribution::DistributionArray pointsDistributionArray_
The spatial distribution array of the points detected in the latest frame.
Definition PointDetector.h:555
std::pair< Index32, Scalar > IndexDistancePair
Definition of a pair combining an index with a distance.
Definition PointDetector.h:49
static bool closestPoints(const Vector2 &queryPoint, const Geometry::SpatialDistribution::DistributionArray &pointsDistributionArray, const Points &points, const Scalar maxSqrDistance, Indices32 &pointIndices)
Returns the closest points to a query point.
static bool hasClosePoint(const Vector2 &queryPoint, const Geometry::SpatialDistribution::DistributionArray &pointsDistributionArray, const Points &points, const Scalar maxSqrDistance)
Returns whether a query point is close to another point.
static void determinePointCandidatesRowSSEDual(const unsigned int y, const uint8_t *yRow, NonMaximumSuppressionVote *nonMaximumSuppression, const uint32_t *borderOffsets, const size_t numberBorderOffsets, const unsigned int filterSize, const int32_t minimalDifference, const int32_t maximalDifference)
Determines point candidates for a single row using SSE4.1 SIMD instructions (dual-sign: both dark and...
static bool refinePointPosition(const Frame &yFrame, const Vector2 &roughPosition, const bool positiveSign, Vector2 &refinedPosition)
Refines the sub-pixel position of a point by snapping it to the nearest peak in the image.
static bool detectPoints(const Frame &yFrame, Points &points, const uint32_t *borderOffsets, const size_t numberBorderOffsets, const unsigned int filterSize, const int32_t minimalDifference=25, const int32_t maximalDifference=25 *4, Worker *worker=nullptr)
Detects points in a grayscale frame using pre-computed border offsets.
static void createFilterResponseRow(const uint8_t *yRow, int32_t *responseRow, const unsigned int width, const uint32_t *borderOffsets, const size_t numberBorderOffsets, const unsigned int filterSize, const int32_t minimalDifference, const int32_t maximalDifference)
Creates a filter response row (single-sign: dark points only).
static void determinePointCandidatesRowSSE(const unsigned int y, const uint8_t *yRow, NonMaximumSuppressionVote *nonMaximumSuppression, const uint32_t *borderOffsets, const size_t numberBorderOffsets, const unsigned int filterSize, const int32_t minimalDifference, const int32_t maximalDifference)
Determines point candidates for a single row using SSE4.1 SIMD instructions (single-sign: dark points...
bool detectPoints(const Frame &yFrame, Worker *worker=nullptr)
Detects points in a new frame.
static void createFilterResponseRowNEON(const uint8_t *yRow, int32_t *responseRow, const unsigned int width, const uint32_t *borderOffsets, const size_t numberBorderOffsets, const unsigned int filterSize, const int32_t minimalDifference, const int32_t maximalDifference)
Creates a filter response row using NEON SIMD instructions (single-sign: dark points only).
static size_t closestPoint(const Vector2 &queryPoint, const bool sign, const Geometry::SpatialDistribution::DistributionArray &pointsDistributionArray, const Points &points, const Scalar maxSqrDistance)
Returns the closest point to a given point.
static void determinePointCandidatesRowNEON(const unsigned int y, const uint8_t *yRow, NonMaximumSuppressionVote *nonMaximumSuppression, const uint32_t *borderOffsets, const size_t numberBorderOffsets, const unsigned int filterSize, const int32_t minimalDifference, const int32_t maximalDifference)
Determines point candidates for a single row using NEON SIMD instructions (single-sign: dark points o...
static void determinePointCandidatesRowDual(const unsigned int y, const uint8_t *yRow, NonMaximumSuppressionVote *nonMaximumSuppression, const uint32_t *borderOffsets, const size_t numberBorderOffsets, const unsigned int filterSize, const int32_t minimalDifference, const int32_t maximalDifference)
Determines point candidates for a single row (dual-sign: both dark and bright points).
const Geometry::SpatialDistribution::DistributionArray & pointsDistributionArray() const
Returns the spatial distribution array of the points detected in the latest frame.
Definition PointDetector.h:645
static void createFilterResponseRowSSEDual(const uint8_t *yRow, int32_t *responseRow, const unsigned int width, const uint32_t *borderOffsets, const size_t numberBorderOffsets, const unsigned int filterSize, const int32_t minimalDifference, const int32_t maximalDifference)
Creates a filter response row using SSE4.1 SIMD instructions (dual-sign: both dark and bright points)...
PointBorderOffsets pointBorderOffsets_
The cached border offsets for the current filter configuration.
Definition PointDetector.h:546
static void createFilterResponseRowSSE(const uint8_t *yRow, int32_t *responseRow, const unsigned int width, const uint32_t *borderOffsets, const size_t numberBorderOffsets, const unsigned int filterSize, const int32_t minimalDifference, const int32_t maximalDifference)
Creates a filter response row using SSE4.1 SIMD instructions (single-sign: dark points only).
const Points & points() const
Returns the points detected in the latest frame.
Definition PointDetector.h:640
static void determinePointCandidatesRow(const unsigned int y, const uint8_t *yRow, NonMaximumSuppressionVote *nonMaximumSuppression, const uint32_t *borderOffsets, const size_t numberBorderOffsets, const unsigned int filterSize, const int32_t minimalDifference, const int32_t maximalDifference)
Determines point candidates for a single row (single-sign: dark points only).
static void createFilterResponseRowNEONDual(const uint8_t *yRow, int32_t *responseRow, const unsigned int width, const uint32_t *borderOffsets, const size_t numberBorderOffsets, const unsigned int filterSize, const int32_t minimalDifference, const int32_t maximalDifference)
Creates a filter response row using NEON SIMD instructions (dual-sign: both dark and bright points).
static bool closestPoints(const Vector2 &queryPoint, const Geometry::SpatialDistribution::DistributionArray &pointsDistributionArray, const Points &points, Index32 &closestPointIndex, Index32 &secondClosestPointIndex, Scalar &closestSqrDistance, Scalar &secondClosestSqrDistance)
Returns the two closest points to a given point.
static void detectPointCandidatesSubset(const Frame *yFrame, NonMaximumSuppressionVote *nonMaximumSuppression, const uint32_t *borderOffsets, const size_t numberBorderOffsets, const unsigned int filterSize, const int32_t minimalDifference, const int32_t maximalDifference, const unsigned int firstRow, const unsigned int numberRows)
Detects point candidates in a subset of rows and adds them to a non-maximum suppression object.
static void createFilterResponseFrameSubset(const Frame *yFrame, Frame *responseFrame, const uint32_t *borderOffsets, const size_t numberBorderOffsets, const unsigned int filterSize, const int32_t minimalDifference, const int32_t maximalDifference, const unsigned int firstRow, const unsigned int numberRows)
Creates filter responses for a subset of rows and writes them into the response frame.
static void closestPoints(const Geometry::SpatialDistribution::DistributionArray &pointsDistributionArray, const size_t queryPointIndex, const Points &points, IndexDistancePairs< tNumber > &indexDistancePairs, const Scalar maxSqrDistance)
Returns the closest points to a given point.
Definition PointDetector.h:564
This class implements the possibility to find local maximum in a 2D array by applying a non-maximum-s...
Definition NonMaximumSuppression.h:138
This class implements Ocean's image class.
Definition Frame.h:1879
int horizontalBin(const Scalar x) const
Returns the horizontal bin of a given horizontal position.
Definition SpatialDistribution.h:1148
int verticalBin(const Scalar y) const
Returns the vertical bin of a given vertical position.
Definition SpatialDistribution.h:1154
unsigned int endBinHorizontal(const unsigned int centerBinX) const
Returns the (exclusive) end bin in horizontal direction for a neighborhood search.
Definition SpatialDistribution.h:1183
unsigned int beginBinHorizontal(const unsigned int centerBinX) const
Returns the (inclusive) begin bin in horizontal direction for a neighborhood search.
Definition SpatialDistribution.h:1173
unsigned int beginBinVertical(const unsigned int centerBinY) const
Returns the (inclusive) begin bin in vertical direction for a neighborhood search.
Definition SpatialDistribution.h:1193
unsigned int endBinVertical(const unsigned int centerBinY) const
Returns the (exclusive) end bin in vertical direction for a neighborhood search.
Definition SpatialDistribution.h:1203
This class implements a distribution array.
Definition SpatialDistribution.h:272
This class implements a static vector that has a fixed capacity.
Definition StaticVector.h:25
size_t size() const
Returns the size of this vector.
Definition StaticVector.h:390
void weakResize(const size_t size)
Resizes this vector.
Definition StaticVector.h:645
bool empty() const
Returns whether this vector hold no element.
Definition StaticVector.h:584
void pushBack(const T &value)
Adds a new element to this vector.
Definition StaticVector.h:402
const T & back() const
Returns the last elements of this vector.
Definition StaticVector.h:544
const T & x() const noexcept
Returns the x value.
Definition Vector2.h:710
const T & y() const noexcept
Returns the y value.
Definition Vector2.h:722
T sqrDistance(const VectorT2< T > &right) const
Returns the square distance between this 2D position and a second 2D position.
Definition Vector2.h:645
This class implements a worker able to distribute function calls over different threads.
Definition Worker.h:33
unsigned int sqrDistance(const char first, const char second)
Returns the square distance between two values.
Definition base/Utilities.h:1159
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition Base.h:96
uint32_t Index32
Definition of a 32 bit index value.
Definition Base.h:84
std::vector< PixelPositionI > PixelPositionsI
Definition of a vector holding pixel positions (with positive and negative coordinate values).
Definition PixelPosition.h:53
std::vector< Point > Points
Definition of a vector holding points.
Definition cv/calibration/Point.h:31
float Scalar
Definition of a scalar type.
Definition Math.h:129
The namespace covering the entire Ocean framework.
Definition Accessor.h:15