22 #include <mrpt/3rdparty/do_opencv_includes.h> 24 #ifdef HAVE_OPENCV_NONFREE // MRPT_HAS_OPENCV_NONFREE 25 #include <opencv2/nonfree/nonfree.hpp> 28 #ifdef HAVE_OPENCV_XFEATURES2D 29 #include <opencv2/xfeatures2d.hpp> 31 #ifdef HAVE_OPENCV_LINE_DESCRIPTOR 32 #include <opencv2/line_descriptor.hpp> 33 using namespace cv::line_descriptor;
43 #if defined(HAVE_OPENCV_XFEATURES2D) && defined(HAVE_OPENCV_LINE_DESCRIPTOR) 44 #define HAVE_OPENCV_WITH_LATCH 1 46 #define HAVE_OPENCV_WITH_LATCH 0 49 void CFeatureExtraction::internal_computeLATCHDescriptors(
55 profiler,
"internal_computeLATCHDescriptors");
57 #if (!HAVE_OPENCV_WITH_LATCH) 59 "This function requires OpenCV modules: xfeatures2d,line_descriptor");
63 if (in_features.
empty())
return;
65 const size_t n_feats = in_features.
size();
70 vector<KeyPoint> cv_feats(n_feats);
71 for (
size_t k = 0; k < n_feats; ++k)
73 KeyPoint& kp = cv_feats[k];
74 kp.pt.x = in_features[k].keypoint.pt.x;
75 kp.pt.y = in_features[k].keypoint.pt.y;
76 kp.angle = in_features[k].orientation;
77 kp.
size = in_features[k].keypoint.octave;
83 Ptr<xfeatures2d::LATCH> latch = xfeatures2d::LATCH::create(
84 options.LATCHOptions.bytes, options.LATCHOptions.rotationInvariance,
85 options.LATCHOptions.half_ssd_size);
86 latch->compute(cvImg, cv_feats, cv_descs);
92 for (
auto& ft : in_features)
95 ft.descriptors.LATCH.emplace();
96 ft.descriptors.LATCH->resize(cv_descs.cols);
97 for (
int m = 0; m < cv_descs.cols; ++m)
98 (*ft.descriptors.LATCH)[m] = cv_descs.at<
int>(i, m);
#define THROW_EXCEPTION(msg)
A safe way to call enter() and leave() of a mrpt::system::CTimeLogger upon construction and destructi...
cv::Mat & asCvMatRef()
Get a reference to the internal cv::Mat, which can be resized, etc.
This base provides a set of functions for maths stuff.
Classes for computer vision, detectors, features, etc.
A list of visual features, to be used as output by detectors, as input/output by trackers, etc.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A class for storing images as grayscale or RGB bitmaps.