import cv2
import numpy as np
img = cv2.imread('./image/dog.png')
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
#创建SURF对象
surf = cv2.xfeatures2d.SURF_create( )
#进行检测
kp = surf.detect(gray)
#检测关键点,并计算描述子
kp, des = surf.compute(img,kp)
#或者一步到位,把关键点和描述子一起检测出来.
kp, des = surf.detectAndCompute(img,None)
# print(kp)
print(des)
print(des.shape)
#绘制关键点
cv2.drawKeypoints(gray,kp, img)
cv2.imshow('img', img)
cv2.waitKey(0)
cv2.destroyAllWindows()