Python opencv 調用sift

安裝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)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章