Using openCV to implement SIFT in image

家住魔仙堡 提交于 2019-12-25 01:46:52

问题


I have tried to implement SIFT with openCV and I have refer to these links link1 and link2. Besides, I have also read the paper about SIFT written by Lowe. I have some problems about the code in link1 and link2.

  1. cv::SiftFeatureDetector detector( 0.05, 5.0 ); cv::SiftDescriptorExtractor extractor( 3.0 );

    I can't totally understand the parameter in the above function. If I modify the first function to cv::SiftFeatureDetector detector( 0.05, 10.0 ); , there is a running time OpenCV Error:Assertion failed < firstOctave>=-1 %% actualNLayers<=nOctaveLayers >.

    In addition, I don't realize the parameter in the SiftDescriptorExtractor extractor( ). I know there is a distances ratio in keypoints matching, but the range is [0,1].

  2. I want to modify the method which I use to match to picture, so I need to extract the descriptor and the dominant orientation of each keypoint. How do I extract extract each keypoint's descriptor and dominant orientation?

Thank you very much for your reply.


回答1:


My advice is that you should use the default parameters of the SIFT at the beginning. Then, if you're not satisfied with the results you can try to refine these parameters.

Ptr<FeatureDetector> detector = new SIFT();;
Ptr<DescriptorExtractor> extractor = new SIFT();

U can find useful information about SIFT parameters in the OpenCV implementation here: http://docs.opencv.org/modules/nonfree/doc/feature_detection.html

To compute the keypoints:

vector<KeyPoint> keypoints;
detector->detect(yourImage, keypoints);

When you compute the keypoints its orientation is automatically calculated and is associated with the parameter 'angle' of each keypoint. Please find more info here: http://docs.opencv.org/modules/features2d/doc/common_interfaces_of_feature_detectors.html

To compute the descriptors of the keypoints:

Mat descriptors;
extractor->compute(yourImage, keypoints, descriptors);

being each row of the Mat descriptors one descriptor.

Please let me know if you have questions! Hope this helps.




回答2:


  • cv::SiftFeatureDetector detector( 0.05, 5.0 ), the first param is the constrast threshold. This is the minimum amount of contrast to accept a keypoint. The second param is the edge rejection threshold. If you want to get more features, you should increase the 1st param and/or decrease the 2nd param.
  • cv::SiftDescriptorExtractor extractor( 3.0 ), the param is the magnificaiton value, the descriptor size is determined by multiplying the keypoint scale by this value. Using the prefixed param is ok.

For more info: http://docs.opencv.org/2.3/modules/features2d/doc/common_interfaces_of_descriptor_extractors.html



来源:https://stackoverflow.com/questions/27297706/using-opencv-to-implement-sift-in-image

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