Ocean
Loading...
Searching...
No Matches
Bullseye.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 OCEAN_CV_DETECTOR_BULLSEYES_BULLSEYE_H
9#define OCEAN_CV_DETECTOR_BULLSEYES_BULLSEYE_H
10
12
13#include "ocean/math/Vector2.h"
14
15namespace Ocean
16{
17
18namespace CV
19{
20
21namespace Detector
22{
23
24namespace Bullseyes
25{
26
27/**
28 * Definition of a bullseye composed of a location and a radius.
29 * @ingroup cvdetectorbullseyes
30 */
31class OCEAN_CV_DETECTOR_BULLSEYES_EXPORT Bullseye
32{
33 public:
34
35 /**
36 * Creates an invalid bullseye object.
37 */
38 Bullseye() = default;
39
40 /**
41 * Creates a new bullseye object by a given position and radius.
42 * @param position The (center) position of the bullseye within the camera frame
43 * @param radius The radius of the bullseye in pixels, with range (0, infinity)
44 * @param grayThreshold Threshold that was used during the detection, range [1, 255]
45 * @param pyramidLayer The pyramid layer at which this bullseye was detected, with range [0, infinity)
46 */
47 Bullseye(const Vector2& position, const Scalar& radius, const unsigned int grayThreshold, const unsigned int pyramidLayer = 0u);
48
49 /**
50 * Returns whether this bullseye is valid.
51 * @return True, if so
52 */
53 bool isValid() const;
54
55 /**
56 * Returns the (center) position of the bullseye.
57 * @return The Bullseye's position within the camera frame
58 */
59 const Vector2& position() const;
60
61 /**
62 * Returns the radius of the bullseye.
63 * @return The Bullseye's radius, with range (0, infinity), 0 for an invalid object
64 */
65 Scalar radius() const;
66
67 /**
68 * Returns the threshold that was used for the detection of this bullseye
69 * @return The threshold value
70 */
71 unsigned int grayThreshold() const;
72
73 /**
74 * Returns the pyramid layer at which this bullseye was detected.
75 * @return The pyramid layer index, with range [0, infinity)
76 */
77 unsigned int pyramidLayer() const;
78
79 /**
80 * Returns an invalid bullseye position.
81 * @return Invalid bullseye position
82 */
84
85 /**
86 * Returns an invalid bullseye radius.
87 * @return Invalid bullseye radius
88 */
89 static constexpr Scalar invalidRadius();
90
91 /**
92 * Returns an invalid bullseye threshold.
93 * @return Invalid bullseye threshold
94 */
95 static constexpr unsigned int invalidGrayThreshold();
96
97 protected:
98
99 /// The (center) position of the bullseye within the camera frame.
100 Vector2 position_ = invalidPosition();
101
102 /// The radius of the bullseye in pixels, with range (0, infinity).
103 Scalar radius_ = invalidRadius();
104
105 /// The threshold that was used during the detection of this bullseye
106 unsigned int grayThreshold_ = invalidGrayThreshold();
107
108 /// The pyramid layer at which this bullseye was detected, with range [0, infinity).
109 unsigned int pyramidLayer_ = 0u;
110};
111
112/// Definition of a vector holding bullseyes.
113using Bullseyes = std::vector<Bullseye>;
114
116{
117 return Scalar(-1);
118}
119
120constexpr unsigned int Bullseye::invalidGrayThreshold()
121{
122 return (unsigned int)(-1);
123}
124
125} // namespace Bullseyes
126
127} // namespace Detector
128
129} // namespace CV
130
131} // namespace Ocean
132
133#endif // OCEAN_CV_DETECTOR_BULLSEYES_BULLSEYE_H
Definition of a bullseye composed of a location and a radius.
Definition Bullseye.h:32
bool isValid() const
Returns whether this bullseye is valid.
static constexpr Scalar invalidRadius()
Returns an invalid bullseye radius.
Definition Bullseye.h:115
Bullseye()=default
Creates an invalid bullseye object.
Bullseye(const Vector2 &position, const Scalar &radius, const unsigned int grayThreshold, const unsigned int pyramidLayer=0u)
Creates a new bullseye object by a given position and radius.
unsigned int pyramidLayer() const
Returns the pyramid layer at which this bullseye was detected.
static constexpr unsigned int invalidGrayThreshold()
Returns an invalid bullseye threshold.
Definition Bullseye.h:120
static Vector2 invalidPosition()
Returns an invalid bullseye position.
const Vector2 & position() const
Returns the (center) position of the bullseye.
Scalar radius() const
Returns the radius of the bullseye.
unsigned int grayThreshold() const
Returns the threshold that was used for the detection of this bullseye.
float Scalar
Definition of a scalar type.
Definition Math.h:129
std::vector< Bullseye > Bullseyes
Definition of a vector holding bullseyes.
Definition Bullseye.h:113
The namespace covering the entire Ocean framework.
Definition Accessor.h:15