本篇博客主要介绍cv2模块中的surf,即加速版的SIFT。
示例代码:
# encoding:utf-8
import cv2
import matplotlib.pyplot as plt
img = cv2.imread('../data/butterfly.jpg', 0)
surf = cv2.xfeatures2d.SURF_create(400)
kp, des = surf.detectAndCompute(img, None)
print(surf.getHessianThreshold())
surf.setHessianThreshold(50000)
kp, des = surf.detectAndCompute(img, None)
img2 = cv2.drawKeypoints(img, kp, None, (255, 0, 0), 4)
plt.imshow(img2)
plt.show()
print(surf.descriptorSize())
print(surf.getExtended())
surf.setExtended(True)
kp, des = surf.detectAndCompute(img, None)
print(surf.descriptorSize())
print(des.shape)
测试图像:

这篇博客探讨了如何在Python中利用cv2模块实现SURF算法,它是一个加速版的SIFT。通过示例代码展示了SURF的运用,并提供了测试图像及结果。
订阅专栏 解锁全文
2049

被折叠的 条评论
为什么被折叠?



