Python opencv 调用sift

来源:互联网 发布:mac gradle 路径 编辑:程序博客网 时间:2024/06/05 11:45

安装python-opencv: apt-get install python-opencv
import cv2
im = cv2.imread(‘aaa.jpg’)
gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
#opencv 读取图片默认BGR
sift = cv2.SIFT()
keypoints,descriptors = sift.detectAndCompute(gray,None)
img = cv2.drawKeypoints(gray,keypoints)
cv2.imshow(‘keypoints’,img)
cv2.waitKey(0)
cv2.destroyAllWindows()

method 2

fea_det = cv2.Feature2D_create(“SIFT”)
des_ext = cv2.DescriptorExtrator_create(“SIFT”)
keypoints = fea_det.detect(gray)
kp, des = des_ext.compute(gray,keypoints)

0 0
原创粉丝点击