15 #include <mrpt/otherlibs/do_opencv_includes.h> 31 bool append_to_list,
uint8_t octave,
32 std::vector<size_t>* out_feats_index_by_row)
35 const IplImage* IPL =
img.getAs<IplImage>();
37 if (!append_to_list) corners.
clear();
40 IPL, corners, threshold, octave, out_feats_index_by_row);
47 bool append_to_list,
uint8_t octave,
48 std::vector<size_t>* out_feats_index_by_row)
51 const IplImage* IPL =
img.getAs<IplImage>();
53 if (!append_to_list) corners.
clear();
56 IPL, corners, threshold, octave, out_feats_index_by_row);
63 bool append_to_list,
uint8_t octave,
64 std::vector<size_t>* out_feats_index_by_row)
67 const IplImage* IPL =
img.getAs<IplImage>();
69 if (!append_to_list) corners.
clear();
72 IPL, corners, threshold, octave, out_feats_index_by_row);
85 unsigned int init_ID,
unsigned int nDesiredFeatures,
95 const IplImage* IPL = inImg_gray.getAs<IplImage>();
104 IPL, corners, options.FASTOptions.threshold, 0,
nullptr);
109 IPL, corners, options.FASTOptions.threshold, 0,
nullptr);
114 IPL, corners, options.FASTOptions.threshold, 0,
nullptr);
119 "Only the 9,10,12 FASTER detectors are implemented.")
124 const size_t N = corners.size();
130 std::vector<size_t> sorted_indices(N);
131 for (
size_t i = 0; i < N; i++) sorted_indices[i] = i;
134 if (options.FASTOptions.use_KLT_response ||
135 nDesiredFeatures != 0
140 const int KLT_half_win = 4;
141 const int max_x = inImg_gray.getWidth() - 1 - KLT_half_win;
142 const int max_y = inImg_gray.getHeight() - 1 - KLT_half_win;
144 for (
size_t i = 0; i < N; i++)
146 const int x = corners[i].pt.x;
147 const int y = corners[i].pt.y;
148 if (
x > KLT_half_win &&
y > KLT_half_win &&
x <= max_x &&
150 corners[i].response =
151 inImg_gray.KLT_response(
x,
y, KLT_half_win);
153 corners[i].response = -100;
157 sorted_indices.begin(), sorted_indices.end(),
162 for (
size_t i = 0; i < N; i++) corners[i].response = 0;
177 const bool do_filter_min_dist = options.FASTOptions.min_distance > 1;
181 const unsigned int occupied_grid_cell_size =
182 options.FASTOptions.min_distance / 2.0;
183 const float occupied_grid_cell_size_inv = 1.0f / occupied_grid_cell_size;
185 unsigned int grid_lx =
188 : (
unsigned int)(1 + inImg.
getWidth() * occupied_grid_cell_size_inv);
189 unsigned int grid_ly =
192 : (
unsigned int)(1 + inImg.
getHeight() * occupied_grid_cell_size_inv);
196 occupied_sections.
fillAll(
false);
199 (nDesiredFeatures != 0 && N > nDesiredFeatures) ? nDesiredFeatures : N;
200 const int offset = (int)this->options.patchSize / 2 + 1;
201 const int size_2 = options.patchSize / 2;
203 const size_t imgW = inImg.
getWidth();
205 unsigned int cont = 0;
208 if (!options.addNewFeatures) feats.
clear();
210 while (cont != nMax && i != N)
217 const int xBorderInf = feat.
pt.x - size_2;
218 const int xBorderSup = feat.
pt.x + size_2;
219 const int yBorderInf = feat.
pt.y - size_2;
220 const int yBorderSup = feat.
pt.y + size_2;
222 if (!(xBorderSup < (
int)imgW && xBorderInf > 0 &&
223 yBorderSup < (
int)imgH && yBorderInf > 0))
226 if (do_filter_min_dist)
229 const size_t section_idx_x =
230 size_t(feat.
pt.x * occupied_grid_cell_size_inv);
231 const size_t section_idx_y =
232 size_t(feat.
pt.y * occupied_grid_cell_size_inv);
234 if (occupied_sections(section_idx_x, section_idx_y))
238 occupied_sections.
set_unsafe(section_idx_x, section_idx_y,
true);
239 if (section_idx_x > 0)
241 section_idx_x - 1, section_idx_y,
true);
242 if (section_idx_y > 0)
244 section_idx_x, section_idx_y - 1,
true);
245 if (section_idx_x < grid_lx - 1)
247 section_idx_x + 1, section_idx_y,
true);
248 if (section_idx_y < grid_ly - 1)
250 section_idx_x, section_idx_y + 1,
true);
255 ft->type = type_of_this_feature;
262 ft->patchSize = options.patchSize;
264 if (options.patchSize > 0)
uint64_t TFeatureID
Definition of a feature ID.
Declares a matrix of booleans (non serializable).
#define THROW_EXCEPTION(msg)
FASTER-9 detector, Edward Rosten's libcvd implementation optimized for SSE2.
static void detectFeatures_SSE2_FASTER10(const mrpt::img::CImage &img, TSimpleFeatureList &corners, const int threshold=20, bool append_to_list=false, uint8_t octave=0, std::vector< size_t > *out_feats_index_by_row=nullptr)
Just like detectFeatures_SSE2_FASTER9() for another version of the detector.
size_t getHeight() const override
Returns the height of the image in pixels.
void fast_corner_detect_12(const IplImage *I, TSimpleFeatureList &corners, int barrier, uint8_t octave, std::vector< size_t > *out_feats_index_by_row)
A helper struct to sort keypoints by their response: It can be used with these types: ...
A structure for defining a ROI within an image.
size_t getWidth() const override
Returns the width of the image in pixels.
void fast_corner_detect_9(const IplImage *I, TSimpleFeatureList &corners, int barrier, uint8_t octave, std::vector< size_t > *out_feats_index_by_row)
FASTER-9 detector, Edward Rosten's libcvd implementation optimized for SSE2.
static void detectFeatures_SSE2_FASTER9(const mrpt::img::CImage &img, TSimpleFeatureList &corners, const int threshold=20, bool append_to_list=false, uint8_t octave=0, std::vector< size_t > *out_feats_index_by_row=nullptr)
A SSE2-optimized implementation of FASTER-9 (requires img to be grayscale).
Classes for computer vision, detectors, features, etc.
FASTER-9 detector, Edward Rosten's libcvd implementation optimized for SSE2.
static void detectFeatures_SSE2_FASTER12(const mrpt::img::CImage &img, TSimpleFeatureList &corners, const int threshold=20, bool append_to_list=false, uint8_t octave=0, std::vector< size_t > *out_feats_index_by_row=nullptr)
Just like detectFeatures_SSE2_FASTER9() for another version of the detector.
void set_unsafe(size_t row, size_t col, const T &v)
Fast but unsafe method to write a value in the matrix.
A list of visual features, to be used as output by detectors, as input/output by trackers, etc.
TFeatureType
Types of features - This means that the point has been detected with this algorithm, which is independent of additional descriptors a feature may also have.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
pixel_coords_t pt
Coordinates in the image.
#define ASSERTDEB_(f)
Defines an assertion mechanism - only when compiled in debug.
float response
A measure of the "goodness" of the feature (typically, the KLT_response value)
A simple structure for representing one image feature (without descriptor nor patch) - This is the te...
void extract_patch(CImage &patch, const unsigned int col=0, const unsigned int row=0, const unsigned int width=1, const unsigned int height=1) const
Extract a patch from this image, saveing it into "patch" (its previous contents will be overwritten)...
void fast_corner_detect_10(const IplImage *I, TSimpleFeatureList &corners, int barrier, uint8_t octave, std::vector< size_t > *out_feats_index_by_row)
void push_back(const CFeature::Ptr &f)
A class for storing images as grayscale or RGB bitmaps.
void fillAll(const T &val)
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
int round(const T value)
Returns the closer integer (int) to x.