Ocean
Loading...
Searching...
No Matches
cv/calibration/Point.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_CV_CALIBRATION_POINT_H
9#define META_OCEAN_CV_CALIBRATION_POINT_H
10
12
13#include "ocean/math/Vector2.h"
14
15namespace Ocean
16{
17
18namespace CV
19{
20
21namespace Calibration
22{
23
24/// Forward declaration.
25class Point;
26
27/**
28 * Definition of a vector holding points.
29 * @ingroup cvcalibration
30 */
31using Points = std::vector<Point>;
32
33/**
34 * This class holds the relevant information of a detected marker point.
35 * A point is defined by an 2D observation location in the camera image, an approximated radius of the point, a sign (black vs. white), and a strength value.
36 * @ingroup cvcalibration
37 */
38class Point
39{
40 public:
41
42 /**
43 * Creates a new invalid point.
44 */
45 Point() = default;
46
47 /**
48 * Creates a new point.
49 * @param observation The 2D observation location in the camera image, must be valid
50 * @param radius The approximated radius of the point, in pixel, with range [1, infinity)
51 * @param strength The strength of the point, with range [0, infinity)
52 */
53 inline Point(const Vector2& observation, const unsigned int radius, const float strength);
54
55 /**
56 * Returns the 2D observation location in the camera image.
57 * @return The point's observation
58 */
59 inline const Vector2& observation() const;
60
61 /**
62 * Returns th strength of the point, positive for black points on white background, negative for white points on black background.
63 * @return The point's strength
64 */
65 inline float strength() const;
66
67 /**
68 * Returns the sign of the point, true for black points on white background, false for white points on black background.
69 * @return The point's sign
70 */
71 inline bool sign() const;
72
73 /**
74 * Returns the radius of this point (the scale of the point).
75 * @return The point's radius, in pixel
76 */
77 inline unsigned int radius() const;
78
79 /**
80 * Returns whether this point is valid.
81 * @return True, if so
82 */
83 inline bool isValid() const;
84
85 protected:
86
87 /// The 2D observation of the point within the camera image.
89
90 /// The radius of the point (the scale of the point), in pixel, with range [1, infinity)
91 unsigned int radius_ = 0u;
92
93 /// The strength of the point, positive for black points on white background, negative for white points on black background, with range (-infinity, infinity)
94 float strength_ = 0.0f;
95};
96
97inline Point::Point(const Vector2& observation, const unsigned int radius, const float strength) :
98 observation_(observation),
99 radius_(radius),
100 strength_(strength)
101{
102 // nothing to do here
103}
104
105inline const Vector2& Point::observation() const
106{
107 return observation_;
108}
109
110inline float Point::strength() const
111{
112 return strength_;
113}
114
115inline bool Point::sign() const
116{
117 return strength_ >= 0.0f;
118}
119
120inline unsigned int Point::radius() const
121{
122 return radius_;
123}
124
125inline bool Point::isValid() const
126{
127 ocean_assert((radius_ == 0u && observation_ == Vector2::minValue()) || (radius_ != 0u && observation_ != Vector2::minValue()));
128
129 return radius_ != 0u;
130}
131
132}
133
134}
135
136}
137
138#endif // META_OCEAN_CV_CALIBRATION_POINT_H
This class holds the relevant information of a detected marker point.
Definition cv/calibration/Point.h:39
unsigned int radius_
The radius of the point (the scale of the point), in pixel, with range [1, infinity)
Definition cv/calibration/Point.h:91
unsigned int radius() const
Returns the radius of this point (the scale of the point).
Definition cv/calibration/Point.h:120
Point()=default
Creates a new invalid point.
bool isValid() const
Returns whether this point is valid.
Definition cv/calibration/Point.h:125
float strength_
The strength of the point, positive for black points on white background, negative for white points o...
Definition cv/calibration/Point.h:94
bool sign() const
Returns the sign of the point, true for black points on white background, false for white points on b...
Definition cv/calibration/Point.h:115
Vector2 observation_
The 2D observation of the point within the camera image.
Definition cv/calibration/Point.h:88
float strength() const
Returns th strength of the point, positive for black points on white background, negative for white p...
Definition cv/calibration/Point.h:110
const Vector2 & observation() const
Returns the 2D observation location in the camera image.
Definition cv/calibration/Point.h:105
static VectorT2< Scalar > minValue()
Returns a 2D vector with all elements set to NumericT::minValue().
Definition Vector2.h:926
std::vector< Point > Points
Definition of a vector holding points.
Definition cv/calibration/Point.h:31
The namespace covering the entire Ocean framework.
Definition Accessor.h:15