OpenCV-Python官方教程-25-角点检测的FAST算法

原理(略)

OpenCV 中 FAST 特征检测器

FAST 算法比其它角点检测算法都快。
但是在噪声很高时不够稳定,这是由阈值决定的。

和其他特征点检测一样我们可以在 OpenCV 中直接使用 FAST特征检测器。如果你愿意的话,你还可以设置阈值,是否进行非最大值抑制,要使用的邻域大小等。
代码示例:

import cv2
import numpy as np
from matplotlib import pyplot as plt

img = cv2.imread('head.jpg')
# Initiate FAST object with default values
fast = cv2.FastFeatureDetector_create()
# find and draw the keypoints
kp = fast.detect(img,None)
img2 = cv2.drawKeypoints(img,kp,None,color=(255,0,0))
# Print all default params
print ('Threshold:{}'.format(fast.getThreshold()))
print ('nonmaxSuppression:{}'.format(fast.getNonmaxSuppression()))
print ('neighborhood:{}'.format(fast.getType()))
print ('Total Keypoints with nonmaxSuppression:{}'.format(len(kp)))

# Disable nonmaxSuppression
fast.setNonmaxSuppression(0)
kp = fast.detect(img,None)
print ('Total Keypoints without nonmaxSuppression:{}'.format(len(kp)))
img3 = cv2.drawKeypoints(img,kp,None,color=(255,0,0))

plt.subplot(131),plt.imshow(img)
plt.title('src'),plt.xticks([]),plt.yticks([])
plt.subplot(132),plt.imshow(img2)
plt.title('with NMS'),plt.xticks([]),plt.yticks([])
plt.subplot(133),plt.imshow(img3)
plt.title('without NMS'),plt.xticks([]),plt.yticks([])
plt.show()

Threshold:10
nonmaxSuppression:True
neighborhood:2
Total Keypoints with nonmaxSuppression:130
Total Keypoints without nonmaxSuppression:779

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值