FAST角点检测
FAST角点由E. Rosten教授提出,相比其他检测手段,这种方法的速度正如其名,相当的 快。值得关注的是他所研究的理论都是属于实用类的,都很快。Rosten教授实现了FAST角点 检测,并将其提供给了OpenCv,相当的有爱呀;不过OpenCv中的函数和Rosten教授的实现似 乎有点点不太一样。遗憾的是,OpenCv中目前还没有FAST角点检测的文档。下面是我从 Rosten的代码中找到的函数声明,可以看到粗略的参数说明。
/*
The references are:
* Machine learning for high-speed corner detection,
E. Rosten and T. Drummond, ECCV 2006
* Faster and better: A machine learning approach to corner detection
E. Rosten, R. Porter and T. Drummond, PAMI, 2009
*/
void cvCornerFast( const CvArr* image, int threshold, int N,
int nonmax_suppression, int* ret_number_of_corners,
CvPoint** ret_corners);
image: OpenCV image in which to detect corners. Must be 8 bit unsigned.
threshold: Threshold for detection (higher is fewer corners). 0-- 255
N: Arc length of detector, 9, 10, 11 or 12. 9 is usually best.
nonmax_suppression: Whether to perform nonmaximal suppression.
ret_number_of_corners: The number of detected corners is returned here.
ret_corners: The corners are returned here.
EmguCv中的 Image<TColor,TDepth>.GetFASTKeypoints方法也实现了FAST角点检 测,不过参数少了一些,只有 threshold和nonmaxSupression,其中N我估计取的默认值9, 但是返回的角点数目我不知道是怎么设置的。
使用FAST角点检测的示例代码如下:
FAST关键点
private string FASTKeyPointFeatureDetect()
{
//获取参数
int threshold = int.Parse (txtFASTThreshold.Text);
bool nonmaxSuppression = cbFASTNonmaxSuppression.Checked;
bool showDetail = cbFASTShowDetail.Checked;
//计算
Stopwatch sw = new Stopwatch();
sw.Start();
MKeyPoint[] keyPoints = imageSourceGrayscale.GetFASTKeypoints(threshold, nonmaxSuppression);
sw.Stop();
//显示
Image<Bgr, Byte> imageResult = imageSourceGrayscale.Convert<Bgr, Byte>();
StringBuilder sbResult = new StringBuilder();
int idx = 0;
foreach (MKeyPoint keypoint in keyPoints)
{
imageResult.Draw(new CircleF(keypoint.Point, (int)(keypoint.Size / 2)), new Bgr(255d, 0d, 0d), (int)(keypoint.Size / 4));
if (showDetail)
sbResult.AppendFormat("第{0}点(坐标 :{1},尺寸:{2},方向:{3}°,响应:{4},octave:{5}),",
idx, keypoint.Point, keypoint.Size, keypoint.Angle, keypoint.Response, keypoint.Octave);
idx++;
}
pbResult.Image = imageResult.Bitmap;
//释放资源
imageResult.Dispose();
//返回
return string.Format("·FAST关键点,用时{0:F05}毫秒 ,参数(阀值:{1},nonmaxSupression:{2}),检测到{3}个关键点\r\n{4}",
sw.Elapsed.TotalMilliseconds, threshold, nonmaxSuppression, keyPoints.Length, showDetail ? (sbResult.ToString() + "\r\n") : "");
}