0

I am trying to retrieve descriptors for key points that I have already found. I am using the following lines of code:

sift = cv2.SIFT()
self.features,des = sift.compute(self.gray,self.features)

However, I am receiving the error:

'cv2.SIFT' object has no attribute 'compute'

I don't understand why, because according to this link (http://docs.opencv.org/trunk/modules/nonfree/doc/feature_detection.html), this should be possible.

Would anyone know what is going on here?

I also noticed that:

cv2.SIFT.detectAndCompute(image, mask[, descriptors[, useProvidedKeypoints]]) → keypoints, descriptors¶

allows you to use already detected keypoints... would someone be able to tell me how to input the arguments correctly for this function to work? I don't need to use the mask argument by the way.

Thank you for your help.

  • which version do you use? – Abid Rahman K Oct 25 '13 at 06:33
  • Open CV version: 2.4.6.0 –  Oct 25 '13 at 06:49
  • Those tutorials are meant for opencv 3.x version. Not for 2.x. There are differences between them. – Abid Rahman K Oct 25 '13 at 06:53
  • check if this works, ``keypoints, descriptors = surf.detect(img,None,useProvidedKeypoints = True)`` – Abid Rahman K Oct 25 '13 at 06:56
  • sorry, try this, ``keypoints, descriptors = surf.detect(img,None,useProvidedKeypoints = False)`` – Abid Rahman K Oct 25 '13 at 07:02
  • Thanks Abid. However, I would like to use my own keypoints. Could you please tell me how I might use what you stated above to achieve this? Also, in what format should my keypoints be? –  Oct 25 '13 at 07:12
  • Btw, the `SIFT.detectAndCompute` function seems to work with my version of OpenCV so alternatively would there be a way to use my own keypoints with this function? –  Oct 25 '13 at 07:16
  • Try the flag ``keypoints, descriptors = surf.detect(img,None,yourkeypoints,useProvidedKeypoints = True)``, I am not sure though. – Abid Rahman K Oct 25 '13 at 12:46
  • Unfortunately, didn't work.. =/ too many arguments... –  Oct 25 '13 at 13:40
  • you can try ``help(sift.detect)`` to check the correct use of the function. I don't have a 2.x in my system. And it is not documented too. – Abid Rahman K Oct 25 '13 at 15:12

1 Answers1

0

The link you just gave, is for OpenCV version 3, not for version 2, that you are using. Thus, any differences in functions or library structure is adequately explained as you are not using the same version (sift = cv2.SIFT()).

Games Brainiac
  • 80,178
  • 33
  • 141
  • 199