Python Opencv实践 - FAST关键点检测

参考资料:

FAST角点检测算法笔记_亦枫Leonlew的博客-CSDN博客

【OpenCV-Python】28.OpenCV的特征检测——特征点检测_opencv特征点检测_机器视觉小学徒的博客-CSDN博客

import cv2 as cv
import numpy as np
import matplotlib.pyplot as plt

img = cv.imread("../SampleImages/shunsuke.jpg", cv.IMREAD_COLOR)

#FAST关键点检测
#1. 创建FAST对象
#   cv.FastFeatureDetector_create()
fast = cv.FastFeatureDetector_create()
#2. 设置阈值
#    fast.setThreshold(thresh)
#    thresh: 阈值
fast.setThreshold(20)
#3. 确保非极大值抑制打开
fast.setNonmaxSuppression(1)
#4. 调用FAST对象的detect方法检测关键点
#   kp = fast.detect(img, None)
#   kp:关键点信息
#   img:待检测图像
keypoints = fast.detect(img, None)

#绘制关键点
img_threshold20 = img.copy()
cv.drawKeypoints(img_threshold20, keypoints, img_threshold20, (0,255,0))
#关闭非极大值抑制
fast.setNonmaxSuppression(0)
keypoints = fast.detect(img, None)
img_nonmaxsuppression_disabled = img.copy()
cv.drawKeypoints(img_nonmaxsuppression_disabled, keypoints, img_nonmaxsuppression_disabled, (0,255,0))

#显示图像
fig,axes = plt.subplots(nrows=1, ncols=3, figsize=(16,16), dpi=100)
axes[0].set_title("Original")
axes[0].imshow(img[:,:,::-1])
axes[1].set_title("Non Max Suppression Enabled")
axes[1].imshow(img_threshold20[:,:,::-1])
axes[2].set_title("Non Max Suppression Disabled")
axes[2].imshow(img_nonmaxsuppression_disabled[:,:,::-1])

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

亦枫Leonlew

希望这篇文章能帮到你

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值