Ocean
QuadDetector.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_TRACKING_OCULUSTAGS_QUADDETECTOR_H
9 #define META_OCEAN_TRACKING_OCULUSTAGS_QUADDETECTOR_H
10 
12 
13 #include "ocean/base/Frame.h"
14 
16 
17 #include "ocean/math/Vector2.h"
18 
19 #include <array>
20 #include <vector>
21 
22 namespace Ocean
23 {
24 
25 namespace Tracking
26 {
27 
28 namespace OculusTags
29 {
30 
31 /**
32  * This class implements a detector for quadrilaterals
33  * @ingroup trackingoculustags
34  */
35 class OCEAN_TRACKING_OCULUSTAGS_EXPORT QuadDetector
36 {
37  public:
38 
39  /// Definition of a quadrilateral
40  typedef std::array<Vector2, 4> Quad;
41 
42 
43  /// A vector of quadrilaterals
44  typedef std::vector<Quad> Quads;
45 
46  public:
47 
48  /**
49  * Detects boundary patterns (possible candidates) and filters them
50  * @param yFrame The image in which boundary patterns will be searched, must be valid
51  * @param frameBorder Defines a perimeter inside the image along the image border in which nothing will be processed (in pixels), range: [0, min(yFrame.width(), yFrame.height())/2)
52  * @return A vector of detected boundary patterns
53  */
54  static Quads detectQuads(const Frame& yFrame, const uint32_t frameBorder = 0u);
55 
56  protected:
57 
58  /**
59  * Determines quads from a set of L-shapes
60  * This function tries to find 4-tuples of L-shapes that form a quadrilateral (without self-intersection)
61  * @param yFrame The image in which boundary patterns will be searched, must be valid
62  * @param lShapes A list of L-shapes, must be valid
63  * @param finiteLines The list of finite lines from the list of L-shapes was constructed, must be valid
64  * @param angleThreshold The maximum deviation from a right angle when comparing adjacent and connected L-shapes, range: [0, deg2rad(90)) (in radian)
65  * @param frameBorder Defines a perimeter inside the image along the image border in which nothing will be processed (in pixels), range: [0, min(yFrame.width(), yFrame.height())/2)
66  * @return A vector of detected boundary patterns
67  */
68  static Quads extractQuads(const Frame& yFrame, const CV::Detector::ShapeDetector::LShapes& lShapes, const FiniteLines2& finiteLines, const Scalar angleThreshold, const uint32_t frameBorder);
69 
70  /**
71  * Applies subpixel refinement to the points of a boundary pattern
72  * @param yFrame The image in which the boundary pattern was detected, must be valid
73  * @param quad The boundary pattern of which the points will be refined, must be valid
74  * @return True if the refinement was successful, otherwise false
75  */
76  static bool refineQuad(const Frame& yFrame, Quad& quad);
77 };
78 
79 } // namespace OculusTags
80 
81 } // namespace Tracking
82 
83 } // namespace Ocean
84 
85 #endif // META_OCEAN_TRACKING_OCULUSTAGS_QUADDETECTOR_H
std::vector< LShape > LShapes
Definition of a vector holding L-shape objects.
Definition: ShapeDetector.h:369
This class implements Ocean's image class.
Definition: Frame.h:1792
This class implements a detector for quadrilaterals.
Definition: QuadDetector.h:36
std::vector< Quad > Quads
A vector of quadrilaterals.
Definition: QuadDetector.h:44
std::array< Vector2, 4 > Quad
Definition of a quadrilateral.
Definition: QuadDetector.h:40
static bool refineQuad(const Frame &yFrame, Quad &quad)
Applies subpixel refinement to the points of a boundary pattern.
static Quads detectQuads(const Frame &yFrame, const uint32_t frameBorder=0u)
Detects boundary patterns (possible candidates) and filters them.
static Quads extractQuads(const Frame &yFrame, const CV::Detector::ShapeDetector::LShapes &lShapes, const FiniteLines2 &finiteLines, const Scalar angleThreshold, const uint32_t frameBorder)
Determines quads from a set of L-shapes This function tries to find 4-tuples of L-shapes that form a ...
float Scalar
Definition of a scalar type.
Definition: Math.h:128
std::vector< FiniteLine2 > FiniteLines2
Definition of a vector holding FiniteLine2 objects.
Definition: FiniteLine2.h:57
std::vector< OculusTag > OculusTags
A vector of Oculus tags.
Definition: OculusTag.h:136
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15