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 */
46 Bullseye(const Vector2& position, const Scalar& radius, const unsigned int grayThreshold);
47
48 /**
49 * Returns whether this bullseye is valid.
50 * @return True, if so
51 */
52 bool isValid() const;
53
54 /**
55 * Returns the (center) position of the bullseye.
56 * @return The Bullseye's position within the camera frame
57 */
58 const Vector2& position() const;
59
60 /**
61 * Returns the radius of the bullseye.
62 * @return The Bullseye's radius, with range (0, infinity), 0 for an invalid object
63 */
64 Scalar radius() const;
65
66 /**
67 * Returns the threshold that was used for the detection of this bullseye
68 * @return The threshold value
69 */
70 unsigned int grayThreshold() const;
71
72 /**
73 * Returns an invalid bullseye position.
74 * @return Invalid bullseye position
75 */
77
78 /**
79 * Returns an invalid bullseye radius.
80 * @return Invalid bullseye radius
81 */
82 static constexpr Scalar invalidRadius();
83
84 /**
85 * Returns an invalid bullseye threshold.
86 * @return Invalid bullseye threshold
87 */
88 static constexpr unsigned int invalidGrayThreshold();
89
90 protected:
91
92 /// The (center) position of the bullseye within the camera frame.
93 Vector2 position_ = invalidPosition();
94
95 /// The radius of the bullseye in pixels, with range (0, infinity).
96 Scalar radius_ = invalidRadius();
97
98 /// The threshold that was used during the detection of this bullseye
99 unsigned int grayThreshold_ = invalidGrayThreshold();
100};
101
102/// Definition of a vector holding bullseyes.
103using Bullseyes = std::vector<Bullseye>;
104
106{
107 return Scalar(-1);
108}
109
110constexpr unsigned int Bullseye::invalidGrayThreshold()
111{
112 return (unsigned int)(-1);
113}
114
115} // namespace Bullseyes
116
117} // namespace Detector
118
119} // namespace CV
120
121} // namespace Ocean
122
123#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:105
Bullseye()=default
Creates an invalid bullseye object.
Bullseye(const Vector2 &position, const Scalar &radius, const unsigned int grayThreshold)
Creates a new bullseye object by a given position and radius.
static constexpr unsigned int invalidGrayThreshold()
Returns an invalid bullseye threshold.
Definition Bullseye.h:110
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:103
The namespace covering the entire Ocean framework.
Definition Accessor.h:15