失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > OpenCV-Python Feature2D 特征点检测(含ORB/KAZE/FAST/BRISK/AKAZE)

OpenCV-Python Feature2D 特征点检测(含ORB/KAZE/FAST/BRISK/AKAZE)

时间:2020-05-09 04:05:10

相关推荐

OpenCV-Python Feature2D 特征点检测(含ORB/KAZE/FAST/BRISK/AKAZE)

代码在git

link

Open3.x-Python 特征点检测方法

对于OpenCV3.x-Python,特征点检测及显示方法如下:

下面就重点介绍OpenCV3.x-Python中的各种特征点检测方法的使用示例。

测试图像为标准的lena.png

AKAZE Feature Detection

#!/usr/bin/env python# -*- coding=utf-8 -*-# Summary: 使用OpenCV3.x-Python检测AKAZE特征点# Author: Amusi# Date: -03-17# Reference: /master/d8/d30/classcv_1_1AKAZE.htmlimport cv2import numpydef main():img = cv2.imread("lena.png")cv2.imshow('Input Image', img)cv2.waitKey(0)# 检测akaze = cv2.AKAZE_create()keypoints = akaze.detect(img, None)# 显示# 必须要先初始化img2img2 = img.copy()img2 = cv2.drawKeypoints(img, keypoints, img2, color=(0,255,0))cv2.imshow('Detected AKAZE keypoints', img2)cv2.waitKey(0)if __name__ == '__main__':main()

BRISK Feature Detection

import cv2import numpydef main():img = cv2.imread("lena.png")cv2.imshow('Input Image', img)cv2.waitKey(0)brisk = cv2.BRISK_create()keypoints = brisk.detect(img, None)# 必须要先初始化img2img2 = img.copy()img2 = cv2.drawKeypoints(img, keypoints, img2, color=(0,255,0))cv2.imwrite('bk.png', img2)cv2.imshow('Detected BRISK keypoints', img2)cv2.waitKey(0)if __name__ == '__main__':main()

Fast Feature Detection

#!/usr/bin/env python3# -*- coding: utf-8 -*-"""Created on Wed Nov 24 14:08:30 @author: ledi"""#!/usr/bin/env python# -*- coding=utf-8 -*-# Summary: 使用OpenCV3.x-Python检测FAST特征点# Author: Amusi# Date: -03-17# Reference: /master/df/d74/classcv_1_1FastFeatureDetector.htmlimport cv2import numpydef main():img = cv2.imread("lena.png")cv2.imshow('Input Image', img)cv2.waitKey(0)# -03-17 Amusi: OpenCV3.x FeatureDetector写法有变化# OpenCV2.x# fast = cv2.FastFeatureDetector()# keypoints = fast.detect(img, None)# OpenCV3.x# 注意有_create()后缀fast = cv2.FastFeatureDetector_create()keypoints = fast.detect(img, None)# 必须要先初始化img2img2 = img.copy()img2 = cv2.drawKeypoints(img, keypoints, img2, color=(0,255,0))cv2.imwrite('bk.png', img2)cv2.imshow('Detected FAST keypoints', img2)cv2.waitKey(0)if __name__ == '__main__':main()

KAZE Feature Detection

#!/usr/bin/env python3# -*- coding: utf-8 -*-"""Created on Wed Nov 24 14:15:45 @author: ledi"""#!/usr/bin/env python# -*- coding=utf-8 -*-# Summary: 使用OpenCV3.x-Python检测KAZE特征点# Author: Amusi# Date: -03-17# Reference: /master/d3/d61/classcv_1_1KAZE.htmlimport cv2import numpydef main():img = cv2.imread("lena.png")cv2.imshow('Input Image', img)cv2.waitKey(0)# 检测kaze = cv2.KAZE_create()keypoints = kaze.detect(img, None)# 显示# 必须要先初始化img2img2 = img.copy()img2 = cv2.drawKeypoints(img, keypoints, img2, color=(0,255,0))cv2.imwrite('kaze.png', img2)cv2.imshow('Detected KAZE keypoints', img2)cv2.waitKey(0)if __name__ == '__main__':main()

ORB Feature Detection

#!/usr/bin/env python# -*- coding=utf-8 -*-# Summary: 使用OpenCV3.x-Python检测ORB特征点# Author: Amusi# Date: -03-17# Reference: /master/db/d95/classcv_1_1ORB.htmlimport cv2import numpydef main():img = cv2.imread("lena.png")cv2.imshow('Input Image', img)cv2.waitKey(0)# 检测orb = cv2.ORB_create()keypoints = orb.detect(img, None)# 显示# 必须要先初始化img2img2 = img.copy()img2 = cv2.drawKeypoints(img, keypoints, img2, color=(0,255,0))cv2.imwrite('orb.png', img2)cv2.imshow('Detected ORB keypoints', img2)cv2.waitKey(0)if __name__ == '__main__':main()

如果觉得《OpenCV-Python Feature2D 特征点检测(含ORB/KAZE/FAST/BRISK/AKAZE)》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。