# -*- coding: utf-8 -*-
import sysimport cv2
import numpy as np# 加载数据
input_file = 'table.jpg' #sys.argv[1]
img = cv2.imread(input_file)
img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# 提取关键点
sift = cv2.xfeatures2d.SIFT_create()
keypoints = sift.detect(img_gray, None)
# 画出特征点
img_sift = np.copy(img)
cv2.drawKeypoints(img, keypoints, img_sift, flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
# 展示
cv2.imshow('Input image', img)
cv2.imshow('SIFT features', img_sift)
cv2.waitKey()