8#ifndef META_OCEAN_CV_DETECTOR_SHAPE_DETECTOR_H
9#define META_OCEAN_CV_DETECTOR_SHAPE_DETECTOR_H
68 inline ShapeType type()
const;
74 inline unsigned int finiteLineIndex0()
const;
80 inline unsigned int finiteLineIndex1()
const;
87 inline unsigned int finiteLineIndex(
const unsigned int index)
const;
93 inline const Vector2& position()
const;
99 inline void setPosition(
const Vector2& position);
105 inline Scalar score()
const;
130 inline TwoLineShape(
const ShapeType shapeType,
const unsigned int finiteLineIndex0,
const unsigned int finiteLineIndex1,
const Vector2& position,
const Scalar score);
153 using TwoLineShapes = std::vector<const CV::Detector::ShapeDetector::TwoLineShape*>;
343 bool verifyShape(
const uint8_t* yFrame,
const unsigned int width,
const unsigned int height,
const bool darkShape,
const unsigned int minimalValueRange,
const unsigned int sampleOffset = 2u,
const unsigned int samples = 4u,
const unsigned int yFramePaddingElements = 0u)
const;
426 static void detectShapes(
const uint8_t*
const yFrame,
const unsigned int width,
const unsigned int height,
LShapes& lShapes,
TShapes& tShapes,
XShapes& xShapes,
const int sign,
const double minimalThreshold = 5.0,
const unsigned int shapeWidth = 15u,
const unsigned int shapeHeight = 15u,
const unsigned int stepSize = 3u,
const unsigned int topBand = 4u,
const unsigned int bottomBand = 4u,
const unsigned int minimalDelta = 5u,
const unsigned int framePaddingElements = 0u);
451 static double tShapeResponse(
const int32_t* linedIntegralHorizontalSignedGradient,
const uint32_t* linedIntegralHorizontalAbsoluteGradient,
const int32_t* linedIntegralVerticalSignedGradient,
const uint32_t* linedIntegralVerticalAbsoluteGradient,
const unsigned int imageWidth,
const unsigned int imageHeight,
const unsigned int x,
const unsigned int y,
const int sign,
const unsigned int shapeWidth,
const unsigned int shapeHeight,
const unsigned int stepSize,
const unsigned int topBand,
const unsigned int bottomBand,
const unsigned int minimalDelta = 5u,
const unsigned int horizontalSignedGradientPaddingElements = 0u,
const unsigned int horizontalAbsoluteGradientPaddingElements = 0u,
const unsigned int verticalSignedGradientPaddingElements = 0u,
const unsigned int verticalAbsoluteGradientPaddingElements = 0u);
477 static void detectShapes(
const uint8_t*
const yFrame,
const unsigned int width,
const unsigned int height,
LShapes& lShapes,
TShapes& tShapes,
XShapes& xShapes,
const float minimalThreshold = 5.421f,
const unsigned int shapeWidth = 15u,
const unsigned int shapeHeight = 15u,
const unsigned int stepSize = 3u,
const unsigned int topBand = 4u,
const unsigned int bottomBand = 4u,
const unsigned int framePaddingElements = 0u);
496 static float tShapeResponse(
const uint32_t* linedIntegral,
const uint64_t* linedIntegralSquare,
const unsigned int width,
const unsigned int height,
const unsigned int x,
const unsigned int y,
const unsigned int shapeWidth,
const unsigned int shapeHeight,
const unsigned int stepSize,
const unsigned int topBand,
const unsigned int bottomBand,
const unsigned int linedIntegralPaddingElements = 0u,
const unsigned int linedIntegralSquaredPaddingElements = 0u);
548 static void detectShapesF(
const uint8_t*
const yFrame,
const unsigned int width,
const unsigned int height,
LShapes& lShapes,
TShapes& tShapes,
XShapes& xShapes,
const int sign,
const float minimalThreshold = 6.0f,
const unsigned int framePaddingElements = 0u,
Frame* topDownResponseFrame =
nullptr,
Frame* bottomUpResponseFrame =
nullptr);
564 static void detectShapesI(
const uint8_t*
const yFrame,
const unsigned int width,
const unsigned int height,
LShapes& lShapes,
TShapes& tShapes,
XShapes& xShapes,
const int sign,
const float minimalThreshold = 6.0f,
const unsigned int framePaddingElements = 0u,
Frame* topDownResponseFrame =
nullptr,
Frame* bottomUpResponseFrame =
nullptr);
682 template <
bool tUseSIMD>
683 static void determineHorizontalResponsesI(
const uint32_t* linedIntegralAndSquared,
const unsigned int width,
const unsigned int height, int32_t* horizontalResponses,
const unsigned int linedIntegralAndSquaredPaddingElements = 0u,
const unsigned int horizontalResponsesPaddingElements = 0u);
701 template <
bool tUseSIMD>
702 static void determineHorizontalResponsesI(
const uint32_t* linedIntegral,
const uint64_t* linedIntegralSquared,
const unsigned int width,
const unsigned int height, int32_t* horizontalResponses,
const unsigned int linedIntegralPaddingElements = 0u,
const unsigned int linedIntegralSquaredPaddingElements = 0u,
const unsigned int horizontalResponsesPaddingElements = 0u);
717 template <
bool tSquaredResponse>
718 static void determineHorizontalResponsesF(
const uint32_t* linedIntegralAndSquared,
const unsigned int width,
const unsigned int height,
float* horizontalResponses,
const unsigned int linedIntegralAndSquaredPaddingElements = 0u,
const unsigned int horizontalResponsesPaddingElements = 0u);
733 template <
bool tUseSIMD>
734 static void determineVerticalResponsesI(
const uint32_t* linedIntegralAndSquared,
const unsigned int width,
const unsigned int height, int32_t* verticalResponses,
const unsigned int linedIntegralAndSquaredPaddingElements = 0u,
const unsigned int verticalResponsesPaddingElements = 0u);
751 template <
bool tUseSIMD>
752 static void determineVerticalResponsesI(
const uint32_t* linedIntegral,
const uint64_t* linedIntegralSquared,
const unsigned int width,
const unsigned int height, int32_t* verticalResponses,
const unsigned int linedIntegralPaddingElements = 0u,
const unsigned int linedIntegralSquaredPaddingElements = 0u,
const unsigned int verticalResponsesPaddingElements = 0u);
767 template <
bool tSquaredResponse>
768 static void determineVerticalResponsesF(
const uint32_t* linedIntegralAndSquared,
const unsigned int width,
const unsigned int height,
float* verticalResponses,
const unsigned int linedIntegralAndSquaredPaddingElements = 0u,
const unsigned int verticalResponsesPaddingElements = 0u);
783 template <
bool tSquaredResponse,
bool tCreateResponseFrame = false>
799 template <
bool tSquaredResponse,
bool tCreateResponseFrame = false>
816 template <
bool tCreateResponseFrame = false>
826 static inline bool haveCorrectSign(
const int32_t sign,
const float horizontalResponse,
const float verticalResponse);
835 static inline bool haveCorrectSign(
const int32_t sign,
const int32_t horizontalResponse,
const int32_t verticalResponse);
880 static void determineShapes(
const FiniteLines2& horizontalFiniteLines,
const FiniteLines2& verticalFiniteLines,
const unsigned int width,
const unsigned int height,
LShapes& lShapes,
TShapes& tShapes,
XShapes& xShapes,
const Scalar thresholdShortDistance =
Scalar(2),
const Scalar thresholdLongDistance =
Scalar(5),
const Scalar thresholdShapeAngle =
Numeric::deg2rad(20),
const Scalar thresholdAngleXShape =
Numeric::deg2rad(5));
901 template <
bool tAllowPerpendicularDirections>
962 static Rectangles guessShapedRectanglesFromUpperCorners(
const LShapes& lShapes,
const Vector2& topLeftCornerDirection,
const Scalar aspectRatio,
const unsigned int imageHeight,
const unsigned int maxNumberOfCandidates,
const Scalar thresholdCornerDirectionAngle =
Numeric::deg2rad(15),
const Scalar thresholdConnectedShapesAngle =
Numeric::deg2rad(5),
const Scalar minimalRectangleWidth = 90,
const Scalar maximalRectangleWidth = 250,
const unsigned int numCandidatePairsToGeneratePerEdge = 1u,
const Scalar sideEdgeRatioMultiplier = 1.0);
1006 static bool optimizeLineAlongEdge(
const Frame& yFrame,
const FiniteLine2& line,
Line2& optimizedLine,
const unsigned int perpendicularSampleDistance = 5u,
const unsigned int sampleLocations = 30u,
const unsigned int minimalValidSampleLocations = 5u,
const Scalars& sampleLocationsPercent =
Scalars());
1064 ocean_assert(index <= 1u);
1291 return horizontalResponse < 0.0f && verticalResponse < 0.0f;
1295 return horizontalResponse > 0.0f && verticalResponse > 0.0f;
1299 ocean_assert(sign == 0);
1300 return (horizontalResponse < 0.0f && verticalResponse < 0.0f) || (horizontalResponse > 0.0f && verticalResponse > 0.0f);
1308 return horizontalResponse < 0 && verticalResponse < 0;
1312 return horizontalResponse > 0 && verticalResponse > 0;
1316 ocean_assert(sign == 0);
1317 return (horizontalResponse < 0 && verticalResponse < 0) || (horizontalResponse > 0 && verticalResponse > 0);
1321template <
bool tAllowPerpendicularDirections>
1324 ocean_assert(alignmentDirection.
isUnit());
1325 ocean_assert(alignmentAngleThreshold >= 0 && alignmentAngleThreshold <=
Numeric::pi_2());
1328 ocean_assert(perpendicularAlignmentDirection.
isUnit());
1333 filteredLShapes.reserve(lShapes.size());
1335 for (
const LShape& lShape : lShapes)
1337 if (
Numeric::abs(lShape.direction() * alignmentDirection) >= alginmentAngleThresholdCos
1338 || (tAllowPerpendicularDirections &&
Numeric::abs(lShape.direction() * perpendicularAlignmentDirection) >= alginmentAngleThresholdCos))
1340 filteredLShapes.push_back(lShape);
1344 return filteredLShapes;
1350 ocean_assert(directionA.
isUnit() && directionB.
isUnit());
1354 if (directionA * direction < thresholdAngleCos)
1360 if (-(directionB * direction) < thresholdAngleCos)
1371 ocean_assert(
Triangle2(firstRectangle[0], firstRectangle[1], firstRectangle[2]).isValid() &&
Triangle2(firstRectangle[2], firstRectangle[3], firstRectangle[0]).isValid());
1372 ocean_assert(
Triangle2(secondRectangle[0], secondRectangle[1], secondRectangle[2]).isValid() &&
Triangle2(secondRectangle[2], secondRectangle[3], secondRectangle[0]).isValid());
1374 const Scalar areaFirstRectangle =
Triangle2(firstRectangle[0], firstRectangle[1], firstRectangle[2]).
area2() +
Triangle2(firstRectangle[2], firstRectangle[3], firstRectangle[0]).
area2();
1375 const Scalar areaSecondRectangle =
Triangle2(secondRectangle[0], secondRectangle[1], secondRectangle[2]).
area2() +
Triangle2(secondRectangle[2], secondRectangle[3], secondRectangle[0]).
area2();
1377 return areaFirstRectangle > areaSecondRectangle;
This class implements an L-shape element like a corner of a rectangle.
Definition ShapeDetector.h:175
const Vector2 & edgeLeft() const
Returns the left edge of this L-shape.
Definition ShapeDetector.h:1119
Vector2 edgeLeft_
The left edge of this L-shape.
Definition ShapeDetector.h:226
Vector2 edgeRight_
The right edge of this L-shape.
Definition ShapeDetector.h:229
LShape()
Creates an invalid L-shape object.
Definition ShapeDetector.h:1083
Vector2 direction_
The direction of this L-shape.
Definition ShapeDetector.h:232
const Vector2 & direction() const
Returns the direction of this L-shape.
Definition ShapeDetector.h:1129
const Vector2 & edgeRight() const
Returns the right edge of this L-shape.
Definition ShapeDetector.h:1124
This class implements a shape detector mainly based on gradients.
Definition ShapeDetector.h:405
static double tShapeResponse(const int32_t *linedIntegralHorizontalSignedGradient, const uint32_t *linedIntegralHorizontalAbsoluteGradient, const int32_t *linedIntegralVerticalSignedGradient, const uint32_t *linedIntegralVerticalAbsoluteGradient, const unsigned int imageWidth, const unsigned int imageHeight, const unsigned int x, const unsigned int y, const int sign, const unsigned int shapeWidth, const unsigned int shapeHeight, const unsigned int stepSize, const unsigned int topBand, const unsigned int bottomBand, const unsigned int minimalDelta=5u, const unsigned int horizontalSignedGradientPaddingElements=0u, const unsigned int horizontalAbsoluteGradientPaddingElements=0u, const unsigned int verticalSignedGradientPaddingElements=0u, const unsigned int verticalAbsoluteGradientPaddingElements=0u)
Determines the detector response for an gradient-based T-shape detector which is axis aligned.
static void detectShapes(const uint8_t *const yFrame, const unsigned int width, const unsigned int height, LShapes &lShapes, TShapes &tShapes, XShapes &xShapes, const int sign, const double minimalThreshold=5.0, const unsigned int shapeWidth=15u, const unsigned int shapeHeight=15u, const unsigned int stepSize=3u, const unsigned int topBand=4u, const unsigned int bottomBand=4u, const unsigned int minimalDelta=5u, const unsigned int framePaddingElements=0u)
Detects shapes in a given image.
This class implements a shape detector based on gradients and variance.
Definition ShapeDetector.h:503
static constexpr unsigned int shapeStepSize_
The step size of the T-shape in pixel, with range [1, infinity), must be odd.
Definition ShapeDetector.h:513
static void determineResponsesI(const int32_t *horizontalResponses, const int32_t *verticalResponses, const unsigned int width, const unsigned int height, const int32_t sign, const uint32_t minimalSqrThreshold, CV::NonMaximumSuppressionT< uint32_t > &nonMaximumSuppressionTopDown, CV::NonMaximumSuppressionT< uint32_t > &nonMaximumSuppressionBottomUp, Frame *responseFrameTopDown=nullptr, Frame *responseFrameBottomUp=nullptr)
Determines the integer T-shape responses for the top-down and bottom-up direction.
static void determineTopDownResponsesF(const float *horizontalResponses, const float *verticalResponses, const unsigned int width, const unsigned int height, const int32_t sign, const float minimalThreshold, CV::NonMaximumSuppressionT< float > &nonMaximumSuppression, Frame *responseFrame=nullptr)
Determines the floating-point T-shape responses for the top-down direction.
static constexpr unsigned int shapeWidth_2_
The width of the T-shape divided by 2, in pixel, beware: shapeWidth_2 * 2 + 1 == shapeWidth.
Definition ShapeDetector.h:519
static void determineVerticalResponsesI(const uint32_t *linedIntegral, const uint64_t *linedIntegralSquared, const unsigned int width, const unsigned int height, int32_t *verticalResponses, const unsigned int linedIntegralPaddingElements=0u, const unsigned int linedIntegralSquaredPaddingElements=0u, const unsigned int verticalResponsesPaddingElements=0u)
Determines the integer vertical responses for the T-shape and stores the results in a given response ...
static constexpr int frameY_T_topDownResponseY()
Returns the translation offset in y-direction between the top-down response location and the frame.
Definition ShapeDetector.h:1246
static constexpr unsigned int shapeHeight_
The height of the T-shape in pixel, with range [shapeStepSize_ + 1, infinity).
Definition ShapeDetector.h:510
static constexpr int frameX_T_bottomUpVerticalResponseX()
Returns the translation offset in x-direction between the vertical bottom-up response location and th...
Definition ShapeDetector.h:1263
static void detectShapesI(const uint8_t *const yFrame, const unsigned int width, const unsigned int height, LShapes &lShapes, TShapes &tShapes, XShapes &xShapes, const int sign, const float minimalThreshold=6.0f, const unsigned int framePaddingElements=0u, Frame *topDownResponseFrame=nullptr, Frame *bottomUpResponseFrame=nullptr)
Detects shapes in a given image while applying integer precision.
static constexpr int frameX_T_topDownVerticalResponseX()
Returns the translation offset in x-direction between the vertical top-down response location and the...
Definition ShapeDetector.h:1229
static constexpr unsigned int shapeWidth_
The width of the T-shape in pixel, with range [shapeStepSize_ + 2, infinity), must be odd.
Definition ShapeDetector.h:507
static void determineVerticalResponsesI(const uint32_t *linedIntegralAndSquared, const unsigned int width, const unsigned int height, int32_t *verticalResponses, const unsigned int linedIntegralAndSquaredPaddingElements=0u, const unsigned int verticalResponsesPaddingElements=0u)
Determines the integer vertical responses for the T-shape and stores the results in a given response ...
static void determineVerticalResponsesF(const uint32_t *linedIntegralAndSquared, const unsigned int width, const unsigned int height, float *verticalResponses, const unsigned int linedIntegralAndSquaredPaddingElements=0u, const unsigned int verticalResponsesPaddingElements=0u)
Determines the floating-point vertical responses for the T-shape and stores the results in a given re...
static constexpr int frameX_T_topDownHorizontalResponseX()
Returns the translation offset in x-direction between the horizontal top-down response location and t...
Definition ShapeDetector.h:1219
static constexpr int frameY_T_bottomUpVerticalResponseY()
Returns the translation offset in y-direction between the vertical bottom-up response location and th...
Definition ShapeDetector.h:1268
static constexpr unsigned int shapeStepSize_2_
The step size of the T-shape divided by 2, in pixel, beware: shapeStepSize_2 * 2 + 1 == shapeStepSize...
Definition ShapeDetector.h:522
static constexpr int frameY_T_bottomUpHorizontalResponseY()
Returns the translation offset in y-direction between the horizontal bottom-up response location and ...
Definition ShapeDetector.h:1258
static void determineHorizontalResponsesF(const uint32_t *linedIntegralAndSquared, const unsigned int width, const unsigned int height, float *horizontalResponses, const unsigned int linedIntegralAndSquaredPaddingElements=0u, const unsigned int horizontalResponsesPaddingElements=0u)
Determines the floating-point horizontal responses for the T-shape and stores the results in a given ...
static bool haveCorrectSign(const int32_t sign, const float horizontalResponse, const float verticalResponse)
Returns whether the sign of two responses matches the expected sign.
Definition ShapeDetector.h:1287
static constexpr int frameY_T_topDownVerticalResponseY()
Returns the translation offset in y-direction between the vertical top-down response location and the...
Definition ShapeDetector.h:1234
static unsigned int determineVerticalResponseWidth(const unsigned int width)
Returns the width of the vertical response frame.
Definition ShapeDetector.h:1207
static unsigned int determineHorizontalResponseHeight(const unsigned int height)
Returns the height of the horizontal response frame.
Definition ShapeDetector.h:1201
static void determineBottomUpResponsesF(const float *horizontalResponses, const float *verticalResponses, const unsigned int width, const unsigned int height, const int32_t sign, const float minimalThreshold, CV::NonMaximumSuppressionT< float > &nonMaximumSuppression, Frame *responseFrame=nullptr)
Determines the floating-point T-shape responses for the bottom-up direction.
static constexpr unsigned int shapeBandSize_
The band size of the T-shape in pixel, with range [1, infinity).
Definition ShapeDetector.h:516
static constexpr int frameY_T_bottomUpResponseY()
Returns the translation offset in y-direction between the bottom-up response location and the frame.
Definition ShapeDetector.h:1280
static void determineHorizontalResponsesI(const uint32_t *linedIntegralAndSquared, const unsigned int width, const unsigned int height, int32_t *horizontalResponses, const unsigned int linedIntegralAndSquaredPaddingElements=0u, const unsigned int horizontalResponsesPaddingElements=0u)
Determines the integer horizontal responses for the T-shape and stores the results in a given respons...
static void determineHorizontalResponsesI(const uint32_t *linedIntegral, const uint64_t *linedIntegralSquared, const unsigned int width, const unsigned int height, int32_t *horizontalResponses, const unsigned int linedIntegralPaddingElements=0u, const unsigned int linedIntegralSquaredPaddingElements=0u, const unsigned int horizontalResponsesPaddingElements=0u)
Determines the integer horizontal responses for the T-shape and stores the results in a given respons...
static constexpr int frameX_T_bottomUpResponseX()
Returns the translation offset in x-direction between the bottom-up response location and the frame.
Definition ShapeDetector.h:1273
static unsigned int determineVerticalResponseHeight(const unsigned int height)
Returns the height of the vertical response frame.
Definition ShapeDetector.h:1213
static unsigned int determineHorizontalResponseWidth(const unsigned int width)
Returns the width of the horizontal response frame.
Definition ShapeDetector.h:1195
static constexpr int frameY_T_topDownHorizontalResponseY()
Returns the translation offset in y-direction between the horizontal top-down response location and t...
Definition ShapeDetector.h:1224
static constexpr int frameX_T_bottomUpHorizontalResponseX()
Returns the translation offset in x-direction between the horizontal bottom-up response location and ...
Definition ShapeDetector.h:1253
static constexpr int frameX_T_topDownResponseX()
Returns the translation offset in x-direction between the top-down response location and the frame.
Definition ShapeDetector.h:1239
static void detectShapesF(const uint8_t *const yFrame, const unsigned int width, const unsigned int height, LShapes &lShapes, TShapes &tShapes, XShapes &xShapes, const int sign, const float minimalThreshold=6.0f, const unsigned int framePaddingElements=0u, Frame *topDownResponseFrame=nullptr, Frame *bottomUpResponseFrame=nullptr)
Detects shapes in a given image while applying floating-point precision.
This class implements a shape detector mainly based on variance.
Definition ShapeDetector.h:458
static void detectShapes(const uint8_t *const yFrame, const unsigned int width, const unsigned int height, LShapes &lShapes, TShapes &tShapes, XShapes &xShapes, const float minimalThreshold=5.421f, const unsigned int shapeWidth=15u, const unsigned int shapeHeight=15u, const unsigned int stepSize=3u, const unsigned int topBand=4u, const unsigned int bottomBand=4u, const unsigned int framePaddingElements=0u)
Detects shapes in a given image.
static float tShapeResponse(const uint32_t *linedIntegral, const uint64_t *linedIntegralSquare, const unsigned int width, const unsigned int height, const unsigned int x, const unsigned int y, const unsigned int shapeWidth, const unsigned int shapeHeight, const unsigned int stepSize, const unsigned int topBand, const unsigned int bottomBand, const unsigned int linedIntegralPaddingElements=0u, const unsigned int linedIntegralSquaredPaddingElements=0u)
Determines the detector response for an variance-based T-shape detector which is axis aligned.
Vector2 direction_
The direction of this T-shape.
Definition ShapeDetector.h:284
const Vector2 & direction() const
Returns the direction of this T-shape.
Definition ShapeDetector.h:1154
TShape()
Creates an invalid T-shape object.
Definition ShapeDetector.h:1134
This class implements the base class for all shapes based on two lines.
Definition ShapeDetector.h:44
void setPosition(const Vector2 &position)
Sets or changes the position of this shape.
Definition ShapeDetector.h:1073
TwoLineShape()
Creates an invalid shape.
Definition ShapeDetector.h:1017
ShapeType type() const
Returns the type of the shape.
Definition ShapeDetector.h:1047
Scalar score_
The score of this L-shape.
Definition ShapeDetector.h:147
Vector2 position_
The position of this shape.
Definition ShapeDetector.h:144
unsigned int finiteLineIndex(const unsigned int index) const
Returns the index of the first or second finite line.
Definition ShapeDetector.h:1062
unsigned int finiteLineIndex1() const
Returns the index of the second finite line.
Definition ShapeDetector.h:1057
ShapeType shapeType_
The shape's type.
Definition ShapeDetector.h:135
unsigned int finiteLineIndex0_
The index of the first finite line.
Definition ShapeDetector.h:138
ShapeType
Definition of individual shape types.
Definition ShapeDetector.h:51
@ ST_SHAPE_X
An X-shape.
Definition ShapeDetector.h:59
@ ST_SHAPE_L
An L-shape.
Definition ShapeDetector.h:55
@ ST_INVALID
An invalid shape type.
Definition ShapeDetector.h:53
@ ST_SHAPE_T
A T-shape.
Definition ShapeDetector.h:57
unsigned int finiteLineIndex1_
The index of the second finite line.
Definition ShapeDetector.h:141
Scalar score() const
Returns the sore of this shape.
Definition ShapeDetector.h:1078
unsigned int finiteLineIndex0() const
Returns the index of the first finite line.
Definition ShapeDetector.h:1052
const Vector2 & position() const
Returns the position of this shape.
Definition ShapeDetector.h:1068
XShape()
Creates an invalid X-shape object.
Definition ShapeDetector.h:1159
const Vector2 & direction1() const
Return the second direction of this X-shape.
Definition ShapeDetector.h:1190
Vector2 direction1_
The direction of the second line of this X-shape.
Definition ShapeDetector.h:363
bool verifyShape(const uint8_t *yFrame, const unsigned int width, const unsigned int height, const bool darkShape, const unsigned int minimalValueRange, const unsigned int sampleOffset=2u, const unsigned int samples=4u, const unsigned int yFramePaddingElements=0u) const
Verifies whether this X-shape is valid based on underlying image content.
Vector2 direction0_
The direction of the first line of this X-shape.
Definition ShapeDetector.h:360
const Vector2 & direction0() const
Returns the first direction of this X-shape.
Definition ShapeDetector.h:1185
This class is a collection of detectors for geometric shapes.
Definition ShapeDetector.h:37
static bool optimizeRectangleAlongEdges(const Frame &yFrame, Rectangle &rectangle, const unsigned int perpendicularSampleDistance=5u)
Optimize the location of a rectangle to its corresponding image edges Fits the line segments of a rec...
std::vector< const CV::Detector::ShapeDetector::TwoLineShape * > TwoLineShapes
Definition of a vector holding pointers to TwoLineShapes.
Definition ShapeDetector.h:153
static bool hasGreaterArea(const Rectangle &firstRectangle, const Rectangle &secondRectangle)
Returns true if the area of the first rectangle is larger than that of the second rectangle.
Definition ShapeDetector.h:1369
static LShapes filterLShapesBasedOnDirection(const LShapes &lShapes, const Vector2 alignmentDirection, const Scalar alignmentAngleThreshold=Numeric::deg2rad(15))
Filters L-shape objects based on their direction.
Definition ShapeDetector.h:1322
std::vector< TShape > TShapes
Definition of a vector holding T-shape objects.
Definition ShapeDetector.h:374
static bool areLShapesConnected(const LShape &lShapeA, const LShape &lShapeB, const Vector2 &directionA, const Vector2 &directionB, const Scalar thresholdAngleCos=Numeric::cos(Numeric::deg2rad(5)))
Checks whether two L-shapes are connected based on their orientation and edge alignment.
Definition ShapeDetector.h:1347
static Rectangles guessShapedRectanglesFromUpperCorners(const LShapes &lShapes, const Vector2 &topLeftCornerDirection, const Scalar aspectRatio, const unsigned int imageHeight, const unsigned int maxNumberOfCandidates, const Scalar thresholdCornerDirectionAngle=Numeric::deg2rad(15), const Scalar thresholdConnectedShapesAngle=Numeric::deg2rad(5), const Scalar minimalRectangleWidth=90, const Scalar maximalRectangleWidth=250, const unsigned int numCandidatePairsToGeneratePerEdge=1u, const Scalar sideEdgeRatioMultiplier=1.0)
Guesses rectangles of a specific aspect ratio from a set of upper left & right corners (provided as l...
static void determineShapes(const FiniteLines2 &horizontalFiniteLines, const FiniteLines2 &verticalFiniteLines, const unsigned int width, const unsigned int height, LShapes &lShapes, TShapes &tShapes, XShapes &xShapes, const Scalar thresholdShortDistance=Scalar(2), const Scalar thresholdLongDistance=Scalar(5), const Scalar thresholdShapeAngle=Numeric::deg2rad(20), const Scalar thresholdAngleXShape=Numeric::deg2rad(5))
Determines all possible L-shapes, T-shapes, and X-shapes which can be extracted from two sets of fini...
static void removeLinesTooCloseToBorder(FiniteLines2 &finiteLines, const unsigned int width, const unsigned int height, const Scalar thresholdDistance=Scalar(10))
Removes finite lines with end points too close to the frame border.
std::vector< LShape > LShapes
Definition of a vector holding L-shape objects.
Definition ShapeDetector.h:369
static LShapes determineLShapes(const FiniteLines2 &finiteLines, const unsigned int width, const unsigned int height, const Scalar thresholdDistance=Scalar(15), const Scalar thresholdAngle=Numeric::deg2rad(15))
Determines all possible L-shape elements which can be extracted from a set of finite lines.
std::array< Vector2, 4 > Rectangle
A rectangle defined by its four corners (counter-clockwise direction).
Definition ShapeDetector.h:394
std::array< Index32, 4 > IndexedRectangle
Definition of an array holding four indices e.g., of L-shape objects.
Definition ShapeDetector.h:384
static bool optimizeLineAlongEdge(const Frame &yFrame, const FiniteLine2 &line, Line2 &optimizedLine, const unsigned int perpendicularSampleDistance=5u, const unsigned int sampleLocations=30u, const unsigned int minimalValidSampleLocations=5u, const Scalars &sampleLocationsPercent=Scalars())
Optimize the location of a line to that of a corresponding image edge For line segments extracted fro...
std::vector< Rectangle > Rectangles
A vector of rectangles.
Definition ShapeDetector.h:399
static Rectangles detectAlignedRectangles(const Frame &yFrame, const unsigned int rectangleWidth, const Scalar aspectRatio, const Scalar aspectRatioTolerance=Scalar(0.10), const Scalar alignmentAngleTolerance=Numeric::deg2rad(35), const bool sortRectangles=true, const unsigned int lineImageBorderDistanceThreshold=5u, const unsigned int perpendicularSampleDistance=5u)
Detect approximately axis-aligned rectangles in images.
static void postAdjustShapes(const unsigned int width, const unsigned int height, LShapes &lShapes, TShapes &tShapes, XShapes &xShapes, const Scalar similarPointDistance=Scalar(1.5), const Scalar similarAngle=Numeric::deg2rad(15))
Post-processes determined shapes and merges similar shapes.
static LShapes nonMaximumSuppressionLShapes(const LShapes &lShapes, const unsigned int width, const unsigned int height, const Scalar thresholdDistance=Scalar(10), const Scalar thresholdAngle=Numeric::deg2rad(25))
Applies a non-maximum suppression of L-shapes.
static IndexedRectangles determineShapedRectangles(const FiniteLines2 &finiteLines, const LShapes &lShapes, const IndexedRectangles &rectangles, const Scalar aspectRatio, const Scalar minimalWidth=90, const Scalar maximalWidth=250, const Scalar aspectRatioTolerance=Scalar(0.1), const Scalar orthogonalAngleTolerance=Numeric::deg2rad(10))
Determines rectangles of specific size and with certain aspect ratios.
std::vector< XShape > XShapes
Definition of a vector holding X-shape objects.
Definition ShapeDetector.h:379
std::vector< IndexedRectangle > IndexedRectangles
Definition of a vector holding rectangles.
Definition ShapeDetector.h:389
static IndexedRectangles determineAlignedRectangles(const FiniteLines2 &finiteLines, const LShapes &lShapes, const Vector2 &topLeftCornerDirection, const Scalar minDistanceBetweenCorners=10, const Scalar thresholdCornerDirectionAngle=Numeric::deg2rad(15), const Scalar thresholdConnectedShapesAngle=Numeric::deg2rad(5))
Determines rectangles aligned with a specified direction.
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:1969
static constexpr Scalar deg2rad(const Scalar deg)
static constexpr Scalar pi_2()
static Scalar abs(const Scalar value)
static Scalar cos(const Scalar value)
T area2() const
Returns the square area of this triangle.
Definition Triangle2.h:474
bool isUnit(const T eps=NumericT< T >::eps()) const
Returns whether this vector is a unit vector (whether the vector has the length 1).
Definition Vector2.h:745
VectorT2< T > perpendicular() const
Returns a vector perpendicular to this vectors.
Definition Vector2.h:555
LineT2< Scalar > Line2
Definition of the Line2 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with single o...
Definition Line2.h:28
VectorT2< Scalar > Vector2
Definition of a 2D vector.
Definition Vector2.h:28
FiniteLineT2< Scalar > FiniteLine2
Definition of the FiniteLine2 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with si...
Definition FiniteLine2.h:28
std::vector< FiniteLine2 > FiniteLines2
Definition of a vector holding FiniteLine2 objects.
Definition FiniteLine2.h:57
std::vector< Scalar > Scalars
Definition of a vector holding Scalar objects.
Definition Math.h:145
TriangleT2< Scalar > Triangle2
Definition of the Triangle2 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with sing...
Definition Triangle2.h:28
float Scalar
Definition of a scalar type.
Definition Math.h:129
Namespace of the CV Detector library.
Definition Barcode.h:19
Namespace of the CV library.
Definition Advanced.h:17
The namespace covering the entire Ocean framework.
Definition Accessor.h:15