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)