opencv-python 获取 sift 特征值

送分小仙女□ 提交于 2019-12-17 01:43:11
# -*- coding: utf-8 -*-
import cv2
import numpy as np
from matplotlib import pyplot as plt
img = cv2.imread("./img/person.jpg")
img1 = img.copy()
img1 = cv2.cvtColor(img1,cv2.COLOR_BGR2RGB)
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

sift = cv2.xfeatures2d.SIFT_create(nfeatures=10)

kp = sift.detect(gray,None)
des = sift.compute(gray,kp)# 计算所有特征点的特征值
feature_value = des[1]  # 拿到所有特征点的特征值

cv2.drawKeypoints(img1,kp,img)
cv2.drawKeypoints(img1,kp,img1,flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)

plt.subplot(121), plt.imshow(img),
plt.title('Destination'), plt.axis('off')
plt.subplot(122), plt.imshow(img1),
plt.title('Destination'), plt.axis('off')
plt.show()
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!