Ocean
Loading...
Searching...
No Matches
RMVFeatureDetector.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_RMV_RMV_FEATURE_DETECTOR_H
9#define META_OCEAN_TRACKING_RMV_RMV_FEATURE_DETECTOR_H
10
12
13#include "ocean/base/Frame.h"
14#include "ocean/base/Worker.h"
15
17
18#include "ocean/math/Box2.h"
19
20namespace Ocean
21{
22
23namespace Tracking
24{
25
26namespace RMV
27{
28
29/**
30 * This class implements an abstraction layer for individual feature detectors.
31 * @ingroup trackingrmv
32 */
33class OCEAN_TRACKING_RMV_EXPORT RMVFeatureDetector
34{
35 public:
36
37 /**
38 * Definition of individual feature detectors.
39 */
41 {
42 /// Invalid feature detector.
44 /// FAST feature detector.
46 /// Harris corner detector.
48 };
49
50 public:
51
52 /**
53 * Returns whether the specified detector prefers a smoothed image for tracking.
54 * A smoothed image can improve the feature robustness e.g., for corner detectors.
55 * @param detectorType Type of the detector to check for
56 * @return True, if so
57 */
58 static inline bool needSmoothedFrame(const DetectorType detectorType);
59
60 /**
61 * Returns whether the specified detector prefers a pyramid initialization.
62 * @param detectorType Type fo the detector to check for
63 * @return True, if so
64 */
65 static inline bool needPyramidInitialization(const DetectorType detectorType);
66
67 /**
68 * Detects features in a given frame and sort them according to their strength.
69 * @param frame The frame to detect features in
70 * @param detectorType Type of the detector to by used
71 * @param threshold Minimal strength threshold all features must exceed
72 * @param frameIsUndistorted True, if the original input frame is undistorted and thus the 2D feature position will be undistorted too
73 * @param worker Optional worker object to distribution the computation
74 * @return Resulting feature positions
75 */
76 static Vectors2 detectFeatures(const Frame& frame, const DetectorType detectorType, const Scalar threshold, const bool frameIsUndistorted, Worker* worker = nullptr);
77
78 /**
79 * Detects features in a subregion of a given frame and sort them according to their strength.
80 * @param yFrame Frame to detect features in, must be valid
81 * @param boundingBox Bounding box defining the subregion for feature detection, the area is clamped to the image boundaries, an invalid bounding box to detect feature points in the entire frame
82 * @param detectorType Type of the detector to by used
83 * @param threshold Minimal strength threshold all features must exceed, with range [0, infinity)
84 * @param frameIsUndistorted True, if the original input frame is undistorted and thus the 2D feature position will be undistorted too
85 * @param worker Optional worker object to distribution the computation
86 * @return Resulting feature positions
87 */
88 static Vectors2 detectFeatures(const Frame& yFrame, const Box2& boundingBox, const DetectorType detectorType, const Scalar threshold, const bool frameIsUndistorted, Worker* worker = nullptr);
89
90 /**
91 * Detects features in a given frame and sort them according to their strength.
92 * Further, this functions tries to exactly detect a certain number of features.
93 * @param frame The frame to detect features in
94 * @param detectorType Type of the detector to by used
95 * @param approximatedThreshold Approximated minimal strength threshold all features should exceed, however, this threshold will be changed to reach the specified number of feature points
96 * @param numberFeatures Number of feature points to be detected
97 * @param frameIsUndistorted True, if the original input frame is undistorted and thus the 2D feature position will be undistorted too
98 * @param worker Optional worker object to distribution the computation
99 * @return Resulting feature positions
100 */
101 static Vectors2 detectFeatures(const Frame& frame, const DetectorType detectorType, const Scalar approximatedThreshold, const size_t numberFeatures, const bool frameIsUndistorted, Worker* worker = nullptr);
102
103 /**
104 * Detects features in a subregion of a given frame and sort them according to their strength.
105 * Further, this functions tries to exactly detect a certain number of features.
106 * @param frame The frame to detect features in
107 * @param boundingBox Bounding box defining the subregion for feature detection, the area is clamped to the image boundaries if extending them
108 * @param detectorType Type of the detector to by used
109 * @param approximatedThreshold Approximated minimal strength threshold all features should exceed, however, this threshold will be changed to reach the specified number of feature points
110 * @param numberFeatures Number of feature points to be detected
111 * @param frameIsUndistorted True, if the original input frame is undistorted and thus the 2D feature position will be undistorted too
112 * @param worker Optional worker object to distribution the computation
113 * @return Resulting feature positions
114 */
115 static Vectors2 detectFeatures(const Frame& frame, const Box2& boundingBox, const DetectorType detectorType, const Scalar approximatedThreshold, const size_t numberFeatures, const bool frameIsUndistorted, Worker* worker = nullptr);
116};
117
119{
120 switch (detectorType)
121 {
122 case DT_FAST_FEATURE:
124 return true;
125
126 default:
127 break;
128 };
129
130 ocean_assert(false && "Invalid detector type!");
131 return false;
132}
133
135{
136 switch (detectorType)
137 {
138 case DT_FAST_FEATURE:
140 return true;
141
142 default:
143 break;
144 };
145
146 ocean_assert(false && "Invalid detector type!");
147 return needSmoothedFrame(detectorType);
148}
149
150}
151
152}
153
154}
155
156#endif // META_OCEAN_TRACKING_RMV_RMV_FEATURE_DETECTOR_H
This class implements Ocean's image class.
Definition Frame.h:1808
This class implements an abstraction layer for individual feature detectors.
Definition RMVFeatureDetector.h:34
static Vectors2 detectFeatures(const Frame &frame, const DetectorType detectorType, const Scalar approximatedThreshold, const size_t numberFeatures, const bool frameIsUndistorted, Worker *worker=nullptr)
Detects features in a given frame and sort them according to their strength.
static Vectors2 detectFeatures(const Frame &frame, const DetectorType detectorType, const Scalar threshold, const bool frameIsUndistorted, Worker *worker=nullptr)
Detects features in a given frame and sort them according to their strength.
static bool needPyramidInitialization(const DetectorType detectorType)
Returns whether the specified detector prefers a pyramid initialization.
Definition RMVFeatureDetector.h:134
static Vectors2 detectFeatures(const Frame &yFrame, const Box2 &boundingBox, const DetectorType detectorType, const Scalar threshold, const bool frameIsUndistorted, Worker *worker=nullptr)
Detects features in a subregion of a given frame and sort them according to their strength.
static Vectors2 detectFeatures(const Frame &frame, const Box2 &boundingBox, const DetectorType detectorType, const Scalar approximatedThreshold, const size_t numberFeatures, const bool frameIsUndistorted, Worker *worker=nullptr)
Detects features in a subregion of a given frame and sort them according to their strength.
DetectorType
Definition of individual feature detectors.
Definition RMVFeatureDetector.h:41
@ DT_HARRIS_FEATURE
Harris corner detector.
Definition RMVFeatureDetector.h:47
@ DT_INVALID
Invalid feature detector.
Definition RMVFeatureDetector.h:43
@ DT_FAST_FEATURE
FAST feature detector.
Definition RMVFeatureDetector.h:45
static bool needSmoothedFrame(const DetectorType detectorType)
Returns whether the specified detector prefers a smoothed image for tracking.
Definition RMVFeatureDetector.h:118
This class implements a worker able to distribute function calls over different threads.
Definition Worker.h:33
float Scalar
Definition of a scalar type.
Definition Math.h:129
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition Vector2.h:64
The namespace covering the entire Ocean framework.
Definition Accessor.h:15