Number of SIFT openCV keypoints?

I am using the following code to extract and draw SIFT keypoints in an image. But in my code, I have not specified how many keypoints I want to extract? so it totally depends on the image, how many key points it has.

What I want: I want to indicate that I need a maximum of 20 key points in the image. If 20 key points are not present, you do not need to go further or if there are more than 20 key points, then just consider the most important 20 key points.

My current code:

//To store the keypoints that will be extracted by SIFT
vector<KeyPoint> keypoints;

//The SIFT feature extractor and descriptor
SiftDescriptorExtractor detector;    


Mat input;    

//open the file
input = imread("image.jpg", 0); 

//detect feature points
detector.detect(input, keypoints);

///Draw Keypoints
Mat keypointImage;
keypointImage.create( input.rows, input.cols, CV_8UC3 );
drawKeypoints(input, keypoints, keypointImage, Scalar(255,0,0));
imshow("Keypoints Found", keypointImage);
waitKey(0);

      

+2


source to share


2 answers


This can be done using the following line:



//The SIFT feature extractor and descriptor
SiftDescriptorExtractor detector(20); 

      

+6


source


download this book http://www.ebooks-it.net/ebook/opencv-2-computer-vision-application-programming-cookbook It explains in detail how SIFT and other function detectors AND work with C ++ codes



+1


source







All Articles