38 bool operator()(
const std::vector<unsigned int> &left,
const std::vector<unsigned int> &right) {
39 return left[1] < right[1];
49 const unsigned int init_ID,
50 const unsigned int nDesiredFeatures,
53 switch( options.featsType )
56 MRPT_TODO(
"Refactor: check if OpenCV's tile method can be directly called to save space here?")
57 if( options.harrisOptions.tile_image )
62 std::cout <<
"Warning: Image ROI is not taken into account, as harrisOptions.tile is set to YES" << std::endl;
66 unsigned int wd =
img.getWidth();
67 unsigned int hg =
img.getHeight();
70 std::vector<std::vector<unsigned int> > tam( 8 );
71 std::vector<CFeatureList> aux_feats( 8 );
73 for(
unsigned int k = 0; k < 4; k++ )
80 newROI.
xMin = k*wd/4.f;
82 newROI.
xMax = wd/4.f + k*wd/4.f - 1;
83 newROI.
yMax = hg/2.f - 1;
86 extractFeaturesKLT(
img, aux_feats[k], init_ID, nDesiredFeatures, newROI );
87 cout <<
"Tiempo en extraer una tile: " << tictac.
Tac()*1000.0f << endl;
90 tam[k][1] = aux_feats[k].size();
95 newROI.
xMax = wd/4 + k*wd/4 - 1;
99 extractFeaturesKLT(
img, aux_feats[k+4], init_ID, nDesiredFeatures, newROI );
100 cout <<
"Tiempo en extraer una tile: " << tictac.
Tac()*1000.0f << endl;
103 tam[k+4][1] = aux_feats[k+4].size();
105 tt += aux_feats[k].size() + aux_feats[k+4].size();
109 unsigned int new_nDesiredFeatures = nDesiredFeatures <= 0 ? 300 : nDesiredFeatures;
110 unsigned int o_n_per_tile = floor( new_nDesiredFeatures/8.0f );
112 if( tt > new_nDesiredFeatures )
115 std::sort(tam.begin(), tam.end(),
sort_pred());
117 if( tam[0][1] > o_n_per_tile )
120 for(
unsigned int m = 0; m < 8; m++ )
121 for(
unsigned int k = 0; k < o_n_per_tile; k++ )
126 std::vector<std::vector<unsigned int> >
::iterator itVector;
127 unsigned int n_per_tile = o_n_per_tile;
129 for( itVector = tam.begin(); itVector != tam.end(); itVector++ )
131 if( (*itVector)[1] < n_per_tile )
134 for(
unsigned int k = 0; k < (*itVector)[1]; k++)
136 feats.
push_back( aux_feats[(*itVector)[0]][k] );
137 n_per_tile += (n_per_tile - (*itVector)[1]);
142 for(
unsigned int k = 0; k < n_per_tile; k++)
144 feats.
push_back( aux_feats[(*itVector)[0]][k] );
145 n_per_tile = o_n_per_tile;
154 for(
unsigned int m = 0; m < 8; m++ )
155 for( itList = aux_feats[m].
begin(); itList != aux_feats[m].end(); itList++ )
162 extractFeaturesKLT(
img, feats, init_ID, nDesiredFeatures, ROI);
166 extractFeaturesKLT(
img, feats, init_ID, nDesiredFeatures, ROI);
170 extractFeaturesSIFT(
img, feats, init_ID, nDesiredFeatures, ROI);
174 extractFeaturesBCD(
img, feats, init_ID, nDesiredFeatures, ROI);
178 extractFeaturesSURF(
img, feats, init_ID, nDesiredFeatures, ROI);
182 extractFeaturesFAST(
img, feats, init_ID, nDesiredFeatures, ROI);
186 extractFeaturesFASTER_N(9,
img, feats, init_ID, nDesiredFeatures, ROI);
189 extractFeaturesFASTER_N(10,
img, feats, init_ID, nDesiredFeatures, ROI);
192 extractFeaturesFASTER_N(12,
img, feats, init_ID, nDesiredFeatures, ROI);
196 extractFeaturesORB(
img, feats, init_ID, nDesiredFeatures, ROI );
215 int nDescComputed = 0;
217 if ((in_descriptor_list &
descSIFT) != 0)
219 this->internal_computeSiftDescriptors(in_img,inout_features);
222 if ((in_descriptor_list &
descSURF) != 0)
224 this->internal_computeSurfDescriptors(in_img,inout_features);
229 this->internal_computeSpinImageDescriptors(in_img,inout_features);
234 this->internal_computePolarImageDescriptors(in_img,inout_features);
239 this->internal_computeLogPolarImageDescriptors(in_img,inout_features);
242 if ((in_descriptor_list &
descORB) != 0)
244 this->internal_computeORBDescriptors(in_img,inout_features);
249 THROW_EXCEPTION_FMT(
"No known descriptor value found in in_descriptor_list=%u",(
unsigned)in_descriptor_list)
260 unsigned int init_ID,
261 unsigned int nDesiredFeatures,
279 featsType ( _featsType)
344 out.
printf(
"\n----------- [CFeatureExtraction::TOptions] ------------ \n\n");
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
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)
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
#define LOADABLEOPTS_DUMP_VAR(variableName, variableType)
Macro for dumping a variable to a stream, within the method "dumpToTextStream(out)" (Variable types a...
EIGEN_STRONG_INLINE iterator begin()
void Tic()
Starts the stopwatch.
bool operator()(const std::vector< unsigned int > &left, const std::vector< unsigned int > &right)
This class allows loading and storing values and vectors of different types from a configuration text...
float yMin
Y coordinate limits [0,imageHeight)
FAST feature detector, OpenCV's implementation ("Faster and better: A machine learning approach to co...
A structure for defining a ROI within an image.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
Harris border and corner detector [HARRIS].
#define MRPT_LOAD_CONFIG_VAR_CAST(variableName, variableType, variableTypeCast, configFileObject, sectionNameStr)
Scale Invariant Feature Transform [LOWE'04].
This class implements a high-performance stopwatch.
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.
Bit-based feature descriptor.
GLsizei const GLchar ** string
A list of visual features, to be used as output by detectors, as input/output by trackers, etc.
TDescriptorType
The bitwise OR combination of values of TDescriptorType are used in CFeatureExtraction::computeDescri...
float xMin
X coordinate limits [0,imageWidth)
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.
#define MRPT_LOAD_CONFIG_VAR(variableName, variableType, configFileObject, sectionNameStr)
An useful macro for loading variables stored in a INI-like file under a key with the same name that t...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Log-Polar image descriptor.
Speeded Up Robust Feature [BAY'06].
double Tac()
Stops the stopwatch.
TInternalFeatList::iterator iterator
Intensity-domain spin image descriptors.
ORB detector and descriptor, OpenCV's implementation ("ORB: an efficient alternative to SIFT or SURF"...
Kanade-Lucas-Tomasi feature [SHI'94].
virtual int printf(const char *fmt,...) MRPT_printf_format_check(2
Writes a string to the stream in a textual form.