OpenCV-Python Feature2D 特征点检测 (SIFT,SURF)
生活随笔
收集整理的这篇文章主要介绍了
OpenCV-Python Feature2D 特征点检测 (SIFT,SURF)
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
git
LINK
下面介绍属于nonfree的特征检测方法,如SIFT和SURF。
这些方法在opencv-contrib中,所以想要使用前,请卸载当前非contrib版本的opencv,即pip uninstall opencv-python后;再重新安装opencv-contrib-python,即pip install opencv-contrib-python
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-contrib-pythonSIFT Feature Detection
#!/usr/bin/env python # -*- coding=utf-8 -*- # Summary: 使用OpenCV3.x-Python检测SIFT特征点 # Author: Amusi # Date: 2018-03-17 # Reference: https://docs.opencv.org/master/d5/d3c/classcv_1_1xfeatures2d_1_1SIFT.htmlimport cv2 import numpydef main():img = cv2.imread("lena.png")cv2.imshow('Input Image', img)cv2.waitKey(0)# 检测sift = cv2.xfeatures2d.SIFT_create()keypoints = sift.detect(img, None)# 显示# 必须要先初始化img2img2 = img.copy()img2 = cv2.drawKeypoints(img, keypoints, img2, color=(0,255,0))cv2.imwrite('sift.png', img2)cv2.imshow('Detected SIFT keypoints', img2)cv2.waitKey(0)if __name__ == '__main__':main()
SURF Feature Detection
总结
以上是生活随笔为你收集整理的OpenCV-Python Feature2D 特征点检测 (SIFT,SURF)的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: cmake之 ADD_LIBRARY()
- 下一篇: python 中值滤波