赞
踩
Harris:https://blog.csdn.net/Keep_Trying_Go/article/details/125384144
Shi-Tomasi:https://blog.csdn.net/Keep_Trying_Go/article/details/125384218
SIFT:https://blog.csdn.net/Keep_Trying_Go/article/details/125384278
(1)提出理由:SIFT最大的问题是检测速度慢,所以提出SURF;
(1)创建surf对象;cv2.xfeatures2d.SURF_create()
(2)关键点检测和特征匹配:kp,des=surf.detectAndCompute(gray,mask);
使用cv2.xfeatures2d.SURF_create()
pip install opencv-contrib-python==3.4.2.16 -i https://pypi.tuna.tsinghua.edu.cn/simple/
import os import cv2 import numpy as np img=cv2.imread('images/HaLiSi.jpg') img=cv2.resize(src=img,dsize=(450,450)) gray=cv2.cvtColor(src=img,code=cv2.COLOR_BGR2GRAY) #SIFT对象创建 surf=cv2.xfeatures2d.SURF_create() #进行检测,其中第二个参数为None,表示对整张图进行检测 kp=surf.detect(gray,None) #进行特征匹配 # kp,des=surf.compute(gray,kp) kp,des=surf.detectAndCompute(gray,None) print(des) #绘制角点 cv2.drawKeypoints(image=gray,keypoints=kp,outImage=img,color=(0,255,0)) cv2.imshow('img',img) cv2.waitKey(0) cv2.destroyAllWindows() if __name__ == '__main__': print('Pycharm')
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。