How to do it...

The cv::Feature2D abstract class defines a number of member functions that are used to compute the descriptors of a list of keypoints. As most feature-based methods include both a detector and a descriptor component, the associated classes include both a detect function (to detect the interest points) and a compute function (to compute their descriptors). This is the case of the cv::xfeatures2d::SURF and cv::xfeature2d::SIFT classes.

To create a SURF feature detector, we have to follow the next steps:

  1. Create the SURF descriptor, as shown in the following code:
// Define feature detector 
// Construct the SURF feature detector object 
cv::Ptr<cv::Feature2D> ptrFeature2D = cv::xfeatures2d::SURF::create(2000.0); 
  1. For each image, ...

Get OpenCV 4 Computer Vision Application Programming Cookbook - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.