OpenCV中的FAST算法在哪里?

Kil*_*anK 2 python opencv corner-detection

我无法在Python OpenCV模块中找到FAST角点检测器,我尝试了这个就像在该链接中描述的那样.我的OpenCV版本是3.1.0.

我知道像SIFT和SURF这样的特征描述算法已转移到cv2.xfeatures2d,但FAST算法并不在那里.

Yah*_*wil 9

我认为opencv-3.1.0文档中的示例代码没有更新.提供的代码不起作用.

试试这个:

    # Ref: https://github.com/jagracar/OpenCV-python-tests/blob/master/OpenCV-tutorials/featureDetection/fast.py
import numpy as np
import cv2
from matplotlib import pyplot as plt

img = cv2.imread('simple.jpg',0)

# Initiate FAST object with default values
fast = cv2.FastFeatureDetector_create(threshold=25)

# find and draw the keypoints
kp = fast.detect(img,None)
img2 = cv2.drawKeypoints(img, kp, None,color=(255,0,0))

print("Threshold: ", fast.getThreshold())
print("nonmaxSuppression: ", fast.getNonmaxSuppression())
print("neighborhood: ", fast.getType())
print("Total Keypoints with nonmaxSuppression: ", len(kp))

cv2.imwrite('fast_true.png',img2)

# Disable nonmaxSuppression
fast.setNonmaxSuppression(0)
kp = fast.detect(img,None)

print "Total Keypoints without nonmaxSuppression: ", len(kp)

img3 = cv2.drawKeypoints(img, kp, None, color=(255,0,0))

cv2.imwrite('fast_false.png',img3)
Run Code Online (Sandbox Code Playgroud)