import cv2
import numpy as np
img = cv2.imread('./image/dog.png')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
#创建sift对象
#注意: xfeatures2d是opencv的扩展包中的内容,需要安装opencv-contrib-python
sift = cv2.xfeatures2d.SIFT_create()
#进行检测
kp = sift.detect(gray)
print( kp)
#绘制关键点
cv2.drawKeypoints(gray,kp, img)
cv2.imshow('img', img)
cv2.waitKey(0)
cv2.destroyAllWindows()