number of keypoints by SIFT openCV?

匿名 (未验证) 提交于 2019-12-03 02:29:01

问题:

I am using the following code to extract and draw the SIFT keypoints in an image. But in my code, i haven't specified that how many keypoints i want to extract? so, it completely depends upon the image how many keypoints it have.

What i want: I want to specify that i need maximum 20 keypoints in an image. If 20 keypoints are not present then no need to proceed further or if keypoints are more than 20 then just consider the most important 20 keypoints.

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); 

回答1:

It can be done by using the following line:

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


回答2:

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



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!