18 #include <mrpt/otherlibs/do_opencv_includes.h>
33 unsigned int nDesiredFeatures,
const TImageROI& ROI)
const
38 #if MRPT_OPENCV_VERSION_NUM < 0x300
43 vector<KeyPoint> cv_feats;
47 #if MRPT_OPENCV_VERSION_NUM >= 0x300
49 const Mat theImg = cvarrToMat(inImg_gray.
getAs<IplImage>());
50 Ptr<AKAZE> akaze = AKAZE::create(
51 options.AKAZEOptions.descriptor_type,
52 options.AKAZEOptions.descriptor_size,
53 options.AKAZEOptions.descriptor_channels,
54 options.AKAZEOptions.threshold, options.AKAZEOptions.nOctaves,
55 options.AKAZEOptions.nOctaveLayers, options.AKAZEOptions.diffusivity);
57 akaze->detect(theImg, cv_feats);
60 const size_t N = cv_feats.size();
64 for (
size_t i = 0; i < N; i++)
66 for (
size_t j = i + 1; j < N; j++)
68 if (cv_feats.at(j).response > cv_feats.at(i).response)
70 KeyPoint temp_point = cv_feats.at(i);
71 cv_feats.at(i) = cv_feats.at(j);
72 cv_feats.at(j) = temp_point;
78 (nDesiredFeatures != 0 && N > nDesiredFeatures) ? nDesiredFeatures : N;
79 const int offset = (int)this->options.patchSize / 2 + 1;
80 const size_t size_2 = options.patchSize / 2;
82 const size_t imgW = inImg.
getWidth();
84 unsigned int cont = 0;
87 if (!options.addNewFeatures) feats.
clear();
89 while (cont != nMax && i != N)
92 const KeyPoint& kp = cv_feats[i];
96 const int xBorderInf = (int)floor(kp.pt.x - size_2);
97 const int xBorderSup = (int)floor(kp.pt.x + size_2);
98 const int yBorderInf = (int)floor(kp.pt.y - size_2);
99 const int yBorderSup = (int)floor(kp.pt.y + size_2);
101 if (!(xBorderSup < (
int)imgW && xBorderInf > 0 &&
102 yBorderSup < (int)imgH && yBorderInf > 0))
111 ft->response = kp.response;
112 ft->orientation = kp.angle;
113 ft->scale = kp.octave;
114 ft->patchSize = options.patchSize;
116 if (options.patchSize > 0)