21 #include <mrpt/otherlibs/do_opencv_includes.h> 23 #ifdef HAVE_OPENCV_NONFREE // MRPT_HAS_OPENCV_NONFREE 24 #include <opencv2/nonfree/nonfree.hpp> 27 #ifdef HAVE_OPENCV_XFEATURES2D 28 #include <opencv2/xfeatures2d.hpp> 30 #ifdef HAVE_OPENCV_LINE_DESCRIPTOR 31 #include <opencv2/line_descriptor.hpp> 32 using namespace cv::line_descriptor;
42 #if defined(HAVE_OPENCV_XFEATURES2D) && defined(HAVE_OPENCV_LINE_DESCRIPTOR) 43 #define HAVE_OPENCV_WITH_LATCH 1 45 #define HAVE_OPENCV_WITH_LATCH 0 51 void CFeatureExtraction::internal_computeLATCHDescriptors(
55 #if (!HAVE_OPENCV_WITH_LATCH) 57 "This function requires OpenCV modules: xfeatures2d,line_descriptor");
61 if (in_features.
empty())
return;
63 const size_t n_feats = in_features.
size();
68 vector<KeyPoint> cv_feats(n_feats);
69 for (
size_t k = 0; k < n_feats; ++k)
71 KeyPoint& kp = cv_feats[k];
72 kp.pt.x = in_features[k]->x;
73 kp.pt.y = in_features[k]->y;
74 kp.angle = in_features[k]->orientation;
75 kp.
size = in_features[k]->scale;
78 Mat cvImg(cv::cvarrToMat(inImg_gray.
getAs<IplImage>()));
81 Ptr<xfeatures2d::LATCH> latch = xfeatures2d::LATCH::create(
82 options.LATCHOptions.bytes, options.LATCHOptions.rotationInvariance,
83 options.LATCHOptions.half_ssd_size);
84 latch->compute(cvImg, cv_feats, cv_descs);
91 for (i = 0, itList = in_features.
begin(); itList != in_features.
end();
97 ft->descriptors.LATCH.resize(cv_descs.cols);
98 for (
int m = 0; m < cv_descs.cols; ++m)
99 ft->descriptors.LATCH[m] =
100 cv_descs.at<
int>(i, m);
const T * getAs() const
Returns a pointer to a const T* containing the image - the idea is to call like "img.getAs<IplImage>()" so we can avoid here including OpenCV's headers.
TInternalFeatList::iterator iterator
#define THROW_EXCEPTION(msg)
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.