15 #include <mrpt/otherlibs/do_opencv_includes.h> 33 const IplImage *IPL =
img.getAs<IplImage>();
35 if (!append_to_list) corners.
clear();
45 const IplImage *IPL =
img.getAs<IplImage>();
47 if (!append_to_list) corners.
clear();
57 const IplImage *IPL =
img.getAs<IplImage>();
59 if (!append_to_list) corners.
clear();
76 unsigned int nDesiredFeatures,
86 const IplImage *IPL = inImg_gray.getAs<IplImage>();
102 const size_t N = corners.size();
107 std::vector<size_t> sorted_indices(N);
108 for (
size_t i=0;i<N;i++) sorted_indices[i]=i;
111 if (options.FASTOptions.use_KLT_response ||
115 const int KLT_half_win = 4;
116 const int max_x = inImg_gray.getWidth() - 1 - KLT_half_win;
117 const int max_y = inImg_gray.getHeight() - 1 - KLT_half_win;
119 for (
size_t i=0;i<N;i++)
121 const int x = corners[i].pt.x;
122 const int y = corners[i].pt.y;
123 if (
x>KLT_half_win &&
y>KLT_half_win &&
x<=max_x &&
y<=max_y)
124 corners[i].response = inImg_gray.KLT_response(
x,
y,KLT_half_win);
125 else corners[i].response = -100;
132 for (
size_t i=0;i<N;i++)
133 corners[i].response = 0;
144 const bool do_filter_min_dist = options.FASTOptions.min_distance>1;
147 const unsigned int occupied_grid_cell_size = options.FASTOptions.min_distance/2.0;
148 const float occupied_grid_cell_size_inv = 1.0f/occupied_grid_cell_size;
150 unsigned int grid_lx = !do_filter_min_dist ? 1 : (
unsigned int)(1 + inImg.
getWidth() * occupied_grid_cell_size_inv);
151 unsigned int grid_ly = !do_filter_min_dist ? 1 : (
unsigned int)(1 + inImg.
getHeight() * occupied_grid_cell_size_inv );
154 occupied_sections.
fillAll(
false);
157 unsigned int nMax = (nDesiredFeatures!=0 && N > nDesiredFeatures) ? nDesiredFeatures : N;
158 const int offset = (int)this->options.patchSize/2 + 1;
159 const int size_2 = options.patchSize/2;
161 const size_t imgW = inImg.
getWidth();
163 unsigned int cont = 0;
166 if( !options.addNewFeatures )
169 while( cont != nMax && i!=N )
176 const int xBorderInf = feat.
pt.x - size_2;
177 const int xBorderSup = feat.
pt.x + size_2;
178 const int yBorderInf = feat.
pt.y - size_2;
179 const int yBorderSup = feat.
pt.y + size_2;
181 if (!( xBorderSup < (
int)imgW && xBorderInf > 0 && yBorderSup < (
int)imgH && yBorderInf > 0 ))
184 if (do_filter_min_dist)
187 const size_t section_idx_x = size_t(feat.
pt.x * occupied_grid_cell_size_inv);
188 const size_t section_idx_y = size_t(feat.
pt.y * occupied_grid_cell_size_inv);
190 if (occupied_sections(section_idx_x,section_idx_y))
194 occupied_sections.
set_unsafe(section_idx_x,section_idx_y,
true);
195 if (section_idx_x>0) occupied_sections.
set_unsafe(section_idx_x-1,section_idx_y,
true);
196 if (section_idx_y>0) occupied_sections.
set_unsafe(section_idx_x,section_idx_y-1,
true);
197 if (section_idx_x<grid_lx-1) occupied_sections.
set_unsafe(section_idx_x+1,section_idx_y,
true);
198 if (section_idx_y<grid_ly-1) occupied_sections.
set_unsafe(section_idx_x,section_idx_y+1,
true);
203 ft->type = type_of_this_feature;
210 ft->patchSize = options.patchSize;
212 if( options.patchSize > 0 )
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.
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=NULL)
Just like detectFeatures_SSE2_FASTER9() for another version of the detector.
#define THROW_EXCEPTION(msg)
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.
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=NULL)
Just like detectFeatures_SSE2_FASTER9() for another version of the detector.
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
FASTER-9 detector, Edward Rosten's libcvd implementation optimized for SSE2.
Classes for computer vision, detectors, features, etc.
void push_back(const CFeaturePtr &f)
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.
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.
static CFeaturePtr Create()
size_t getWidth() const MRPT_OVERRIDE
Returns the width of the image in pixels.
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)
size_t getHeight() const MRPT_OVERRIDE
Returns the height of the image in pixels.
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=NULL)
A SSE2-optimized implementation of FASTER-9 (requires img to be grayscale).
void fillAll(const T &val)