【opencv】sift特征点算法

 需要注意的是sift算法需要使用此教程下载相关库:

【解决问题】AttributeError:module cv2.cv2 has no attribute xfeatures2d - 灰信网(软件开发博客聚合)icon-default.png?t=M0H8https://www.freesion.com/article/7729770941/

from email.mime import image
import imghdr
from turtle import title
import cv2
import matplotlib.pyplot as plt
import numpy as np

def cv_show(img,name):
    cv2.imshow(name,img)
    cv2.waitKey(0)
    cv2.destroyAllWindows()

gray=cv2.imread('lena.jpg')
sift=cv2.xfeatures2d.SIFT_create()
kp=sift.detect(gray,None)
img=cv2.drawKeypoints(gray,kp,None,flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
cv_show(img,'sift')
#save
cv2.imwrite('sift.jpg',img)
kp,des=sift.compute(gray,kp)
print(kp)
print(des)

【opencv】sift特征点算法_第1张图片

【opencv】sift特征点算法_第2张图片

你可能感兴趣的:(opencv,opencv,算法,计算机视觉)