0

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.

Kuo
  • 29
  • 1
  • 11

2 Answers2

3

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.

zedv
  • 1,459
  • 12
  • 23
  • I have searched other article and implement the SIFT by openCV. And I use cv::SIFT siftDetectorExtractor = cv::SIFT(0, 3, 0.04, 10, 1.6); and siftDetectorExtractor(tmp,cv::Mat(), keypoints1, sifts1);. However, when I want to know the coordination of the keypoint, I use keypoints1[0].pt and the result isn't integer. Why? The image is digital, so the coordination of keypoint need to be integer. – Kuo Dec 05 '14 at 15:21
  • In addition, I have accessed the descriptor of first keypoint by sifts1.at(0,0) to sifts1.at(0,127). Could I need to rotate the order of sifts1.at(0,0) to sifts1.at(0,127) and other keypoints' descriptor before matching? Or its order is begin from the dominant orientation and end at the dominant orientation automatically? So I can directly use the result to match. – Kuo Dec 05 '14 at 15:25
  • Besides, I still can't find the meaning of the parameter in the cv::SiftDescriptorExtractor extractor( ); You answer help me a lot in my study. Thank you very much for your reply. – Kuo Dec 05 '14 at 15:27
  • 1. what do you mean with "coordination"? When u use keypoints1[0].pt u get the coordinates of the keypoint (in a Point2f structure), not a integer. 2. After you detect keypoints (using SiftFeatureDetector), you must calculate the descriptors for them (using SiftDescriptorExtractor). After that you should use a matcher for connecting the closest keypoints in each image (if is that's the case). – zedv Dec 05 '14 at 23:08
  • 1. But the coordinate or the location of keypoint in a digital image should be integer. Why is it a integer? 2. I don't understand how to use SiftDescriptorExtractor, the [link](http://fahmifahim.com/2012/12/11/opencv-sift-implementation-in-opencv-2-4/) use 3.0 as the parameter. What is the meaning of this parameter? I can't find this parameter in the paper written by Lowe. – Kuo Dec 05 '14 at 23:40
1
  • 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

thunderY
  • 59
  • 4