赞
踩
import cv2 as cv
import numpy as np
# 读取图片
img = cv.imread(r'C:\Users\Administrator\Desktop\chess.png')
# 灰度化
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
# 检测特征点
sift = cv.xfeatures2d.SIFT_create() # 创建SIFT对象
kp = sift.detect(gray, None) # 对整个图像进行检测,掩码设为None
cv.drawKeypoints(gray, kp, img) # 绘制特征点
# 显示图像
cv.imshow('img', img)
cv.waitKey(0)
import cv2 as cv import numpy as np # 读取图片 img = cv.imread(r'C:\Users\Administrator\Desktop\chess.png') # 灰度化 gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY) # 检测特征点+描述子 sift = cv.xfeatures2d.SIFT_create() # 创建SIFT对象 kp, des = sift.detectAndCompute(gray, None) # 对整个图像进行检测,掩码设为None print(des) cv.drawKeypoints(gray, kp, img) # 绘制特征点 # 显示图像 cv.imshow('img', img) cv.waitKey(0)
C:\ProgramData\Anaconda3\envs\tensorflow\python.exe H:/python_study/opencv/BILILI/sift.py
[[ 0. 0. 6. ... 0. 0. 2.]
[ 0. 64. 129. ... 0. 0. 9.]
[ 0. 0. 1. ... 0. 0. 2.]
...
[ 0. 0. 20. ... 13. 0. 0.]
[ 8. 5. 4. ... 0. 0. 1.]
[ 0. 42. 111. ... 0. 0. 4.]]
进程已结束,退出代码0
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。