我就废话不多说,直接上代码吧! # -*- coding: utf-8 -*-
import cv2
import numpy as np
from find_obj import filter_matches,explore_match
from matplotlib import pyplot as plt
def getSift():
'''
得到并查看sift特征
'''
img_path1 = '../../data/home.jpg'
#读取图像
img = cv2.imread(img_path1)
#转换为灰度图
gray= cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
#创建sift的类
sift = cv2.SIFT()
#在图像中找到关键点 也可以一步计算#kp, des = sift.detectAndCompute
kp = sift.detect(gray,None)
print type(kp),type(kp[0])
#Keypoint数据类型分析 http://www.cnblogs.com/cj695/p/4041399.html
print kp[0].pt
#计算每个点的sift
des = sift.compute(gray,kp)
print type(kp),type(des)
#des[0]为关键点的list,des[1]为特征向量的矩阵
print type(des[0]), type(des[1])