24 CFeatureExtraction::~CFeatureExtraction() {}
28 const std::vector<unsigned int>& left,
29 const std::vector<unsigned int>& right)
31 return left[1] < right[1];
38 void CFeatureExtraction::detectFeatures(
40 const unsigned int nDesiredFeatures,
const TImageROI& ROI)
const 42 switch (options.featsType)
46 "Refactor: check if OpenCV's tile method can be directly " 47 "called to save space here?")
48 if (options.harrisOptions.tile_image)
54 std::cout <<
"Warning: Image ROI is not taken into " 55 "account, as harrisOptions.tile is set to YES" 60 unsigned int wd =
img.getWidth();
61 unsigned int hg =
img.getHeight();
65 std::vector<std::vector<unsigned int>> tam(8);
66 std::vector<CFeatureList> aux_feats(
69 for (
unsigned int k = 0; k < 4;
77 newROI.
xMin = k * wd / 4.f;
79 newROI.
xMax = wd / 4.f + k * wd / 4.f - 1;
80 newROI.
yMax = hg / 2.f - 1;
84 img, aux_feats[k], init_ID, nDesiredFeatures, newROI);
85 cout <<
"Tiempo en extraer una tile: " 86 << tictac.
Tac() * 1000.0f << endl;
89 tam[k][1] = aux_feats[k].size();
92 newROI.
xMin = k * wd / 4;
94 newROI.
xMax = wd / 4 + k * wd / 4 - 1;
99 img, aux_feats[k + 4], init_ID, nDesiredFeatures,
101 cout <<
"Tiempo en extraer una tile: " 102 << tictac.
Tac() * 1000.0f << endl;
104 tam[k + 4][0] = k + 4;
105 tam[k + 4][1] = aux_feats[k + 4].size();
107 tt += aux_feats[k].size() + aux_feats[k + 4].size();
111 unsigned int new_nDesiredFeatures =
112 nDesiredFeatures <= 0 ? 300 : nDesiredFeatures;
113 unsigned int o_n_per_tile = floor(new_nDesiredFeatures / 8.0f);
115 if (tt > new_nDesiredFeatures)
120 std::sort(tam.begin(), tam.end(),
sort_pred());
122 if (tam[0][1] > o_n_per_tile)
126 for (
unsigned int m = 0; m < 8; m++)
127 for (
unsigned int k = 0; k < o_n_per_tile; k++)
132 std::vector<std::vector<unsigned int>>
::iterator 134 unsigned int n_per_tile = o_n_per_tile;
136 for (itVector = tam.begin(); itVector != tam.end();
144 for (
unsigned int k = 0; k < (*itVector)[1];
148 aux_feats[(*itVector)[0]][k]);
149 n_per_tile += (n_per_tile - (*itVector)[1]);
154 for (
unsigned int k = 0; k < n_per_tile; k++)
157 aux_feats[(*itVector)[0]][k]);
158 n_per_tile = o_n_per_tile;
167 for (
unsigned int m = 0; m < 8; m++)
168 for (itList = aux_feats[m].
begin();
169 itList != aux_feats[m].end(); itList++)
177 extractFeaturesKLT(
img, feats, init_ID, nDesiredFeatures, ROI);
181 extractFeaturesKLT(
img, feats, init_ID, nDesiredFeatures, ROI);
185 extractFeaturesSIFT(
img, feats, init_ID, nDesiredFeatures, ROI);
189 extractFeaturesBCD(
img, feats, init_ID, nDesiredFeatures, ROI);
193 extractFeaturesSURF(
img, feats, init_ID, nDesiredFeatures, ROI);
197 extractFeaturesFAST(
img, feats, init_ID, nDesiredFeatures, ROI);
201 extractFeaturesFASTER_N(
202 9,
img, feats, init_ID, nDesiredFeatures, ROI);
205 extractFeaturesFASTER_N(
206 10,
img, feats, init_ID, nDesiredFeatures, ROI);
209 extractFeaturesFASTER_N(
210 12,
img, feats, init_ID, nDesiredFeatures, ROI);
214 extractFeaturesORB(
img, feats, init_ID, nDesiredFeatures, ROI);
219 extractFeaturesAKAZE(
img, feats, init_ID, nDesiredFeatures, ROI);
222 extractFeaturesLSD(
img, feats, init_ID, nDesiredFeatures, ROI);
234 void CFeatureExtraction::computeDescriptors(
240 int nDescComputed = 0;
242 if ((in_descriptor_list &
descSIFT) != 0)
244 this->internal_computeSiftDescriptors(in_img, inout_features);
247 if ((in_descriptor_list &
descSURF) != 0)
249 this->internal_computeSurfDescriptors(in_img, inout_features);
254 this->internal_computeSpinImageDescriptors(in_img, inout_features);
259 this->internal_computePolarImageDescriptors(in_img, inout_features);
264 this->internal_computeLogPolarImageDescriptors(in_img, inout_features);
267 if ((in_descriptor_list &
descORB) != 0)
269 this->internal_computeORBDescriptors(in_img, inout_features);
273 if ((in_descriptor_list &
descBLD) != 0)
275 this->internal_computeBLDLineDescriptors(in_img, inout_features);
278 if ((in_descriptor_list &
descLATCH) != 0)
280 this->internal_computeLATCHDescriptors(in_img, inout_features);
285 "No known descriptor value found in in_descriptor_list=%u",
286 (
unsigned)in_descriptor_list)
294 void CFeatureExtraction::extractFeaturesBCD(
296 unsigned int nDesiredFeatures,
const TImageROI& ROI)
const 311 : featsType(_featsType)
406 "\n----------- [CFeatureExtraction::TOptions] ------------ \n\n");
484 featsType =
iniFile.read_enum(section,
"featsType", featsType);
523 SpinImagesOptions.hist_size_distance,
int,
iniFile, section)
525 SpinImagesOptions.hist_size_intensity,
int,
iniFile, section)
529 SpinImagesOptions.std_intensity,
float,
iniFile, section)
533 PolarImagesOptions.bins_distance,
int,
iniFile, section)
538 LogPolarImagesOptions.num_angles,
int,
iniFile, section)
540 LogPolarImagesOptions.rho_scale,
double,
iniFile, section)
546 AKAZEOptions.descriptor_channels,
int,
iniFile, section)
562 LATCHOptions.rotationInvariance,
bool,
iniFile, section)
double Tac() noexcept
Stops the stopwatch.
TInternalFeatList::iterator iterator
LSD detector, OpenCV's implementation.
#define THROW_EXCEPTION(msg)
FASTER-9 detector, Edward Rosten's libcvd implementation optimized for SSE2.
A high-performance stopwatch, with typical resolution of nanoseconds.
EIGEN_STRONG_INLINE iterator begin()
bool operator()(const std::vector< unsigned int > &left, const std::vector< unsigned int > &right)
float yMin
Y coordinate limits [0,imageHeight)
FAST feature detector, OpenCV's implementation ("Faster and better: A machine learning approach to...
A structure for defining a ROI within an image.
This class allows loading and storing values and vectors of different types from a configuration text...
Harris border and corner detector [HARRIS].
Scale Invariant Feature Transform [LOWE'04].
string iniFile(myDataDir+string("benchmark-options.ini"))
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.
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)
#define LOADABLEOPTS_DUMP_VAR(variableName, variableType)
Macro for dumping a variable to a stream, within the method "dumpToTextStream(out)" (Variable types a...
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].
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Intensity-domain spin image descriptors.
AKAZE detector, OpenCV's implementation.
ORB detector and descriptor, OpenCV's implementation ("ORB: an efficient alternative to SIFT or SU...
void Tic() noexcept
Starts the stopwatch.
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
Kanade-Lucas-Tomasi feature [SHI'94].
#define MRPT_LOAD_CONFIG_VAR_CAST( variableName, variableType, variableTypeCast, configFileObject, sectionNameStr)
void push_back(const CFeature::Ptr &f)
A class for storing images as grayscale or RGB bitmaps.
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.