15 #include <mrpt/otherlibs/do_opencv_includes.h> 30 bool append_to_list,
uint8_t octave,
31 std::vector<size_t>* out_feats_index_by_row)
34 const IplImage* IPL =
img.getAs<IplImage>();
36 if (!append_to_list) corners.
clear();
39 IPL, corners, threshold, octave, out_feats_index_by_row);
46 bool append_to_list,
uint8_t octave,
47 std::vector<size_t>* out_feats_index_by_row)
50 const IplImage* IPL =
img.getAs<IplImage>();
52 if (!append_to_list) corners.
clear();
55 IPL, corners, threshold, octave, out_feats_index_by_row);
62 bool append_to_list,
uint8_t octave,
63 std::vector<size_t>* out_feats_index_by_row)
66 const IplImage* IPL =
img.getAs<IplImage>();
68 if (!append_to_list) corners.
clear();
71 IPL, corners, threshold, octave, out_feats_index_by_row);
84 unsigned int init_ID,
unsigned int nDesiredFeatures,
94 const IplImage* IPL = inImg_gray.getAs<IplImage>();
103 IPL, corners, options.FASTOptions.threshold, 0,
nullptr);
108 IPL, corners, options.FASTOptions.threshold, 0,
nullptr);
113 IPL, corners, options.FASTOptions.threshold, 0,
nullptr);
118 "Only the 9,10,12 FASTER detectors are implemented.")
123 const size_t N = corners.size();
129 std::vector<size_t> sorted_indices(N);
130 for (
size_t i = 0; i < N; i++) sorted_indices[i] = i;
133 if (options.FASTOptions.use_KLT_response ||
134 nDesiredFeatures != 0
139 const int KLT_half_win = 4;
140 const int max_x = inImg_gray.getWidth() - 1 - KLT_half_win;
141 const int max_y = inImg_gray.getHeight() - 1 - KLT_half_win;
143 for (
size_t i = 0; i < N; i++)
145 const int x = corners[i].pt.x;
146 const int y = corners[i].pt.y;
147 if (
x > KLT_half_win &&
y > KLT_half_win &&
x <= max_x &&
149 corners[i].response =
150 inImg_gray.KLT_response(
x,
y, KLT_half_win);
152 corners[i].response = -100;
156 sorted_indices.begin(), sorted_indices.end(),
161 for (
size_t i = 0; i < N; i++) corners[i].response = 0;
176 const bool do_filter_min_dist = options.FASTOptions.min_distance > 1;
180 const unsigned int occupied_grid_cell_size =
181 options.FASTOptions.min_distance / 2.0;
182 const float occupied_grid_cell_size_inv = 1.0f / occupied_grid_cell_size;
184 unsigned int grid_lx =
187 : (
unsigned int)(1 + inImg.
getWidth() * occupied_grid_cell_size_inv);
188 unsigned int grid_ly =
191 : (
unsigned int)(1 + inImg.
getHeight() * occupied_grid_cell_size_inv);
195 occupied_sections.
fillAll(
false);
198 (nDesiredFeatures != 0 && N > nDesiredFeatures) ? nDesiredFeatures : N;
199 const int offset = (int)this->options.patchSize / 2 + 1;
200 const int size_2 = options.patchSize / 2;
202 const size_t imgW = inImg.
getWidth();
204 unsigned int cont = 0;
207 if (!options.addNewFeatures) feats.
clear();
209 while (cont != nMax && i != N)
216 const int xBorderInf = feat.
pt.x - size_2;
217 const int xBorderSup = feat.
pt.x + size_2;
218 const int yBorderInf = feat.
pt.y - size_2;
219 const int yBorderSup = feat.
pt.y + size_2;
221 if (!(xBorderSup < (
int)imgW && xBorderInf > 0 &&
222 yBorderSup < (
int)imgH && yBorderInf > 0))
225 if (do_filter_min_dist)
228 const size_t section_idx_x =
229 size_t(feat.
pt.x * occupied_grid_cell_size_inv);
230 const size_t section_idx_y =
231 size_t(feat.
pt.y * occupied_grid_cell_size_inv);
233 if (occupied_sections(section_idx_x, section_idx_y))
237 occupied_sections.
set_unsafe(section_idx_x, section_idx_y,
true);
238 if (section_idx_x > 0)
240 section_idx_x - 1, section_idx_y,
true);
241 if (section_idx_y > 0)
243 section_idx_x, section_idx_y - 1,
true);
244 if (section_idx_x < grid_lx - 1)
246 section_idx_x + 1, section_idx_y,
true);
247 if (section_idx_y < grid_ly - 1)
249 section_idx_x, section_idx_y + 1,
true);
254 ft->type = type_of_this_feature;
261 ft->patchSize = options.patchSize;
263 if (options.patchSize > 0)
std::shared_ptr< CFeature > Ptr
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
void fast_corner_detect_12(const IplImage *I, mrpt::vision::TSimpleFeatureList &corners, int barrier, uint8_t octave, std::vector< size_t > *out_feats_index_by_row)
Declares a matrix of booleans (non serializable).
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
FASTER-9 detector, Edward Rosten's libcvd implementation optimized for SSE2.
A class for storing images as grayscale or RGB bitmaps.
#define THROW_EXCEPTION(msg)
static void detectFeatures_SSE2_FASTER12(const mrpt::utils::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 fast_corner_detect_9(const IplImage *I, mrpt::vision::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.
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
static void detectFeatures_SSE2_FASTER10(const mrpt::utils::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.
FASTER-9 detector, Edward Rosten's libcvd implementation optimized for SSE2.
Classes for computer vision, detectors, features, etc.
FASTER-9 detector, Edward Rosten's libcvd implementation optimized for SSE2.
uint64_t TFeatureID
Definition of a feature ID.
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.
static void detectFeatures_SSE2_FASTER9(const mrpt::utils::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).
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.
#define ASSERTDEB_(f)
Defines an assertion mechanism - only when compiled in debug.
pixel_coords_t pt
Coordinates in the image.
float response
A measure of the "goodness" of the feature (typically, the KLT_response value)
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)...
A simple structure for representing one image feature (without descriptor nor patch) - This is the te...
int round(const T value)
Returns the closer integer (int) to x.
void fast_corner_detect_10(const IplImage *I, mrpt::vision::TSimpleFeatureList &corners, int barrier, uint8_t octave, std::vector< size_t > *out_feats_index_by_row)
void push_back(const CFeature::Ptr &f)
void fillAll(const T &val)