OpenCV-Python Feature2D 特征点检测 (SIFT,SURF)
生活随笔
收集整理的這篇文章主要介紹了
OpenCV-Python Feature2D 特征点检测 (SIFT,SURF)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
git
LINK
下面介紹屬于nonfree的特征檢測方法,如SIFT和SURF。
這些方法在opencv-contrib中,所以想要使用前,請卸載當(dāng)前非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
總結(jié)
以上是生活随笔為你收集整理的OpenCV-Python Feature2D 特征点检测 (SIFT,SURF)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: cmake之 ADD_LIBRARY()
- 下一篇: python 中值滤波