简体   繁体   English

SIFT或SURF - 提供关键点和检索描述符

[英]SIFT or SURF - Provide key points and retrieve descriptors

I am trying to use OpenCV(2.4.6.0) to retrieve descriptors from key points that I have provided. 我正在尝试使用OpenCV(2.4.6.0)从我提供的关键点检索描述符。

So far, I have not been successful... 到目前为止,我还没有成功......

l, des = surf.detectAndCompute(self.gray,None,useProvidedKeypoints = True)

where l is an array of feature points. 其中l是一个特征点数组。 I am not sure where to input the key points I already have... 我不知道在哪里输入我已经拥有的关键点...

Would anyone know how I can go about doing this with either SIFT or SURF? 有谁知道如何使用SIFT或SURF进行此操作?

Thank you for your help! 谢谢您的帮助!

This looks like a problem with the Python bindings for detectAndCompute() , since the C++ equivalent does allow inputting of keypoints. 这看起来像是detectAndCompute()的Python绑定问题,因为C ++等价物允许输入关键点。 Fortunately, there is a workaround. 幸运的是,有一种解决方法。 If you already have detected keypoints and stored them in l , then you can create a DescriptorExtractor object and compute descriptors for the provided keypoints. 如果您已经检测到关键点并将它们存储在l ,那么您可以为所提供的关键点创建DescriptorExtractor对象并计算描述符。

An example generating FAST keypoints and then computing SURF descriptors follows: 生成FAST关键点然后计算SURF描述符的示例如下:

im = cv2.imread(path_to_image)
fast = cv2.FeatureDetector_create('FAST')
l = fast.detect(im)
surf = cv2.DescriptorExtractor_create('SURF')
l, des = surf.compute(im, l)

This works equally well for SIFT features. 这同样适用于SIFT功能。 Just pass 'SIFT' as an argument to cv2.DescriptorExtractor_create() instead. 只需将'SIFT'作为参数传递给cv2.DescriptorExtractor_create()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM