9

I'm trying to get started working with sift feature extraction using (C++) OpenCv. I need to extract features using SIFT, match them between the original image (e.g. a book) and a scene, and after that calculate the camera pose.

So far I have found this algorithm using SURF. Does anyone know a base code from which I can get started, or maybe a way to convert the algorithm in the link from SURF to SIFT?

Thanks in advance.

EDIT: Ok, I worked out a solution for the sift problem. Now I'm trying to figure the camera pose. I'm trying to use: solvePnP, can anyone help me with an example?

Filipe
  • 3,398
  • 5
  • 21
  • 35

3 Answers3

6

Check out the feature2d tutorial section of the new OpenCV docs website. There tutorials with code showing:

  1. Feature detection with e.g. SURF
  2. Feature Description
  3. Feature Matching
Adi Shavit
  • 16,743
  • 5
  • 67
  • 137
  • Thanks, but this examples are for SURF. I need SIFT, or someway to convert a algorithm from SURF to SIFT. – Filipe Jul 07 '12 at 20:07
4

If you have managed to find matches between the image and the scene, then I suggest you apply cv::findHomography(). It will calculate the homography matrix using 4 matches as input.

You can convert to camera pose from the homography matrix directly.

Jav_Rock
  • 22,059
  • 20
  • 123
  • 164
0

For using SIFT instead of SURF, I changed SurfFeatureDetector to SiftFeatureDetector and SurfDescriptorExtractor to SiftDescriptorExtractor. For some images, I found that the combination SURF detector <--> SIFT descriptor yields relatively accurate results, but you should experiment with other combinations (FAST detector - FREAK descriptor or ORB detector - BRISK descriptor), depending on your requirements.

Please follow this tutorial for solving the homography part of your question: Feature Matching and Homography

Also, maybe this will help: Pose Estimation

Community
  • 1
  • 1
Dragos Stanciu
  • 320
  • 1
  • 7