原文地址:http://docs.opencv.org/trunk/doc/py_tutorials/py_feature2d/py_fast/py_fast.html#fast-algorithm-for-corner-detection
,下面我们将判断它是否是一个特征点。我们首先把它的密度(即像素值)设为
。
。
个连续的像素点,它们的像素值要么都比
大,要么都比
小,那么它就是一个角点。(如上图中白色虚线所示)。
这里被设定为12。
是一个角点,那么上述四个像素点中至少有3个应该必须都大于
或者小于
(因为若是一个角点,超过四分之三个圆的部分应该满足判断条件,半圆比包含上述某三个点)。如果都不满足,那么
不可能是一个角点。完整的分段测试可以被用于接受的所有候选点,通过检测圆上的所有点。这种检测有很好的性能,但是有一些缺点:
。
),可以有下面三种状态中的一种:
被划分为3个子集,
,
,
。
。如果
是一个角点,那些
为真;否则为假。
。
是
和它周围16个像素点的绝对偏差的和。
值。
值较低的点将会被剔除。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() # find and draw the keypoints kp = fast.detect(img,None) img2 = cv2.drawKeypoints(img, kp, color=(255,0,0)) # Print all default params print "Threshold: ", fast.getInt(‘threshold‘) print "nonmaxSuppression: ", fast.getBool(‘nonmaxSuppression‘) print "neighborhood: ", fast.getInt(‘type‘) print "Total Keypoints with nonmaxSuppression: ", len(kp) cv2.imwrite(‘fast_true.png‘,img2) # Disable nonmaxSuppression fast.setBool(‘nonmaxSuppression‘,0) kp = fast.detect(img,None) print "Total Keypoints without nonmaxSuppression: ", len(kp) img3 = cv2.drawKeypoints(img, kp, color=(255,0,0)) cv2.imwrite(‘fast_false.png‘,img3)
【OpenCV文档】用于角点检测的Fast算法,布布扣,bubuko.com
原文:http://blog.csdn.net/candycat1992/article/details/22285979