一:Fast特徵定義什麼是角點:
這次的定義基於假定特徵點周圍的圖像強度,通過檢查候選像素周圍一圈像素來決定是否接受一個特徵點。與中心點差異較大的像素如果組成連續的圓弧,並且弧長大於原周長的3/4,那麼我們認爲找到了一個特徵點。
二:加速技巧
首先測試圓上被90度分割的四個點(頂部,底部,左側及右側),那麼爲了滿足上述條件,四個點中至少三個點必須大於或者小於中心像素。如果不成立,那麼該點可以被直接移除而不需要檢查額外圓周上的點。在實踐中,大部分的像素點可以通過該測試進行移除,因此非常有效。
三:半徑參數
測試中圓的半徑是一個參數,實踐中發現,半徑爲3可以兼顧結果和效率。
四:算法適用
該算法可以獲得非常快的特徵點檢測,在需要考慮進行速度時可以選用,如在高幀率的視頻序列中進行視覺跟蹤。
Code:
-
#include <iostream>
-
#include <opencv2\highgui\highgui.hpp>
-
#include <opencv2\core\core.hpp>
-
#include <opencv2\features2d\features2d.hpp> // 特徵點檢測類都封裝在features2d這個模塊中
-
#include <opencv2\imgproc\imgproc.hpp>
-
-
using namespace std;
-
using namespace cv;
-
-
int main()
-
{
-
Mat image = imread("F:\\lena.png", 1);
-
if(!image.data)
-
{
-
cout << "Fail to load image" << endl;
-
return 0;
-
}
-
vector<KeyPoint> keypoints;
-
FastFeatureDetector fast(20);
-
fast.detect(image,keypoints);
-
drawKeypoints(image, keypoints, image, Scalar::all(-1), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS);
-
namedWindow("fast");
-
imshow("fast", image);
-
waitKey(0);
-
return 0;
-
-
}
Result:
參考blog:
http://blog.csdn.net/yangtrees/article/details/7530354
作者:小村長 出處:http://blog.csdn.net/lu597203933 歡迎轉載或分享,但請務必聲明文章出處。 (新浪微博:小村長zack, 歡迎交流!)