Ocean
Loading...
Searching...
No Matches
FASTFeature.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_DETECTOR_FAST_FEATURE_H
9#define META_OCEAN_CV_DETECTOR_FAST_FEATURE_H
10
13
14namespace Ocean
15{
16
17namespace CV
18{
19
20namespace Detector
21{
22
23// Forward declaration.
24class FASTFeature;
25
26/**
27 * Definition of a vector holding FAST features.
28 * @ingroup cvdetector
29 */
30typedef std::vector<FASTFeature> FASTFeatures;
31
32/**
33 * This class implements a FAST feature.
34 * @ingroup cvdetector
35 */
36class OCEAN_CV_DETECTOR_EXPORT FASTFeature : public PointFeature
37{
38 public:
39
40 /**
41 * Creates a new empty FAST feature object.
42 */
43 inline FASTFeature();
44
45 /**
46 * Creates a new feature object by a given 2D observation position in e.g. an image.
47 * @param observation 2D feature observation
48 * @param distortionState Distortion state of the 2D feature position
49 * @param strength Feature strength
50 */
51 inline FASTFeature(const Vector2& observation, const DistortionState distortionState, const Scalar strength);
52
53 /**
54 * Converts FAST features to simple 2D image positions.
55 * Thus, the 2D positions are preserved only.
56 * @param features FAST features to convert
57 * @return Resulting image points
58 */
59 static inline Geometry::ImagePoints features2imagePoints(const FASTFeatures& features);
60
61 /**
62 * Converts FAST features to simple 2D image positions.
63 * Thus, the 2D positions are preserved only.
64 * @param features FAST feature to convert
65 * @param number Number of features to be converted
66 * @return Resulting image points
67 */
68 static inline Geometry::ImagePoints features2imagePoints(const FASTFeatures& features, const unsigned int number);
69
70 /**
71 * Converts FAST features to point features.
72 * @param features FAST features to convert
73 * @return Resulting point features
74 */
75 static inline PointFeatures features2pointFeatures(const FASTFeatures& features);
76
77 /**
78 * Converts FAST features to point features.
79 * @param features FAST features to convert
80 * @param number Number of features to be converted
81 * @return Resulting point features
82 */
83 static inline PointFeatures features2pointFeatures(const FASTFeatures& features, const unsigned int number);
84};
85
88{
89 // nothing to do here
90}
91
92inline FASTFeature::FASTFeature(const Vector2& observation, const DistortionState distortionState, const Scalar strength) :
93 PointFeature(observation, distortionState, strength)
94{
95 // nothing to do here
96}
97
99{
101 result.reserve(features.size());
102
103 for (FASTFeatures::const_iterator i = features.begin(); i != features.end(); ++i)
104 result.push_back(i->observation());
105
106 return result;
107}
108
109inline Geometry::ImagePoints FASTFeature::features2imagePoints(const FASTFeatures& features, const unsigned int number)
110{
111 const unsigned int realNumber = min(number, (unsigned int)features.size());
112
114 result.reserve(realNumber);
115
116 for (unsigned int n = 0; n < realNumber; ++n)
117 result.push_back(features[n].observation());
118
119 return result;
120}
121
123{
124 PointFeatures result;
125 result.reserve(features.size());
126
127 for (FASTFeatures::const_iterator i = features.begin(); i != features.end(); ++i)
128 result.push_back(*i);
129
130 return result;
131}
132
133inline PointFeatures FASTFeature::features2pointFeatures(const FASTFeatures& features, const unsigned int number)
134{
135 const unsigned int realNumber = min(number, (unsigned int)features.size());
136
137 PointFeatures result;
138 result.reserve(realNumber);
139
140 for (unsigned int n = 0; n < realNumber; ++n)
141 result.push_back(features[n]);
142
143 return result;
144}
145
146}
147
148}
149
150}
151
152#endif // META_OCEAN_CV_DETECTOR_FAST_FEATURE_H
This class implements a FAST feature.
Definition FASTFeature.h:37
static PointFeatures features2pointFeatures(const FASTFeatures &features)
Converts FAST features to point features.
Definition FASTFeature.h:122
FASTFeature()
Creates a new empty FAST feature object.
Definition FASTFeature.h:86
static Geometry::ImagePoints features2imagePoints(const FASTFeatures &features)
Converts FAST features to simple 2D image positions.
Definition FASTFeature.h:98
This class implements the base class for all computer vision features mainly basing on points.
Definition PointFeature.h:44
DistortionState
Definition of individual distortion states.
Definition PointFeature.h:51
std::vector< PointFeature > PointFeatures
Definition of a vector holding point features.
Definition PointFeature.h:35
std::vector< FASTFeature > FASTFeatures
Definition of a vector holding FAST features.
Definition FASTFeature.h:30
std::vector< ImagePoint > ImagePoints
Definition of a vector holding 2D image points.
Definition geometry/Geometry.h:123
float Scalar
Definition of a scalar type.
Definition Math.h:129
The namespace covering the entire Ocean framework.
Definition Accessor.h:15