18 #include <mrpt/3rdparty/do_opencv_includes.h>
33 unsigned int nDesiredFeatures, [[maybe_unused]]
const TImageROI& ROI)
39 #if MRPT_OPENCV_VERSION_NUM < 0x300
44 vector<KeyPoint> cv_feats;
48 #if MRPT_OPENCV_VERSION_NUM >= 0x300
51 Ptr<AKAZE> akaze = AKAZE::create(
52 #
if MRPT_OPENCV_VERSION_NUM >= 0x400
53 static_cast<cv::AKAZE::DescriptorType
>(
54 options.AKAZEOptions.descriptor_type),
56 options.AKAZEOptions.descriptor_type,
58 options.AKAZEOptions.descriptor_size,
59 options.AKAZEOptions.descriptor_channels,
60 options.AKAZEOptions.threshold, options.AKAZEOptions.nOctaves,
61 options.AKAZEOptions.nOctaveLayers,
62 #
if MRPT_OPENCV_VERSION_NUM >= 0x400
63 static_cast<cv::KAZE::DiffusivityType
>(options.AKAZEOptions.diffusivity)
65 options.AKAZEOptions.diffusivity
69 akaze->detect(theImg, cv_feats);
72 const size_t N = cv_feats.size();
76 for (
size_t i = 0; i < N; i++)
78 for (
size_t j = i + 1; j < N; j++)
80 if (cv_feats.at(j).response > cv_feats.at(i).response)
82 KeyPoint temp_point = cv_feats.at(i);
83 cv_feats.at(i) = cv_feats.at(j);
84 cv_feats.at(j) = temp_point;
90 (nDesiredFeatures != 0 && N > nDesiredFeatures) ? nDesiredFeatures : N;
91 const int offset = (int)this->options.patchSize / 2 + 1;
92 const size_t size_2 = options.patchSize / 2;
94 const size_t imgW = inImg.
getWidth();
96 unsigned int cont = 0;
99 if (!options.addNewFeatures) feats.
clear();
101 while (cont != nMax && i != N)
104 const KeyPoint& kp = cv_feats[i];
108 const int xBorderInf = (int)floor(kp.pt.x - size_2);
109 const int xBorderSup = (int)floor(kp.pt.x + size_2);
110 const int yBorderInf = (int)floor(kp.pt.y - size_2);
111 const int yBorderSup = (int)floor(kp.pt.y + size_2);
113 if (!(xBorderSup < (
int)imgW && xBorderInf > 0 &&
114 yBorderSup < (int)imgH && yBorderInf > 0))
128 if (options.patchSize > 0)