首页 > 学院 > 开发设计 > 正文

OpenCV角点检测器测试和比较

2019-11-06 08:52:00
字体:
来源:转载
供稿:网友

关于特征检测,OpenCV提供了通用的接口FeatureDetector类。简单调用其成员函数create()detect()即可完成角点检测。

选取8个以角点为特征的特征检测器进行测试,包括:

HARRISGFTT (Shi-tomasi)SIFTSURFFASTSTARORB (oriented BRIEF)BRISK

测试代码

#include <stdio.h>#include <iostream>#include "opencv2/core/core.hpp"#include "opencv2/features2d/features2d.hpp"#include "opencv2/nonfree/features2d.hpp"#include "opencv2/highgui/highgui.hpp"#include "opencv2/nonfree/nonfree.hpp"using namespace cv;using namespace std;int main(){ string imgPath = "road.jpg"; Mat img = imread(imgPath, CV_LOAD_IMAGE_COLOR); vector<string> detectorNames{"HARRIS","GFTT","SIFT", "SURF","FAST","STAR","ORB","BRISK"}; cout << "DetectorName" << '/t' << "Number of corners" << '/t' << "Time used" <<'/t'<<"efficiency" << endl << endl; for (string detectorName:detectorNames) { cout <<detectorName<<+"/t/t"; double t = (double)getTickCount(); //--detect keypoints Ptr<FeatureDetector> detector = FeatureDetector::create(detectorName); vector<KeyPoint> keyPoints; detector->detect(img, keyPoints, Mat()); cout << keyPoints.size() << "/t/t/t"; //--draw keypoints Mat imgKeyPoints; drawKeypoints(img, keyPoints, imgKeyPoints, Scalar::all(-1), DrawMatchesFlags::DEFAULT); imshow(detectorName+" KeyPoints", imgKeyPoints); //time used t = ((double)getTickCount() - t) / getTickFrequency(); cout << t << "/t"; //Number of coners detected per unit time(ms) double efficiency = keyPoints.size() / t / 1000; cout << efficiency << endl<<endl; } waitKey(0); return 0;}

运行结果

HARRIS 这里写图片描述

GFTT 这里写图片描述

SIFT 这里写图片描述

SURF 这里写图片描述

FAST 这里写图片描述

STAR 这里写图片描述

ORB 这里写图片描述

BRISK 这里写图片描述

比较

这里写图片描述

可以看出,FAST特征检测算法的检测速度是超群的,难怪敢自称“FAST”。从特征点检测效率以及检测出的特征点数来看,SURF表现也不错。以上各个角点检测器,使用的都是OpenCV默认的封装,可能会因为具体的参数设置差异,检测出的角点数有不同,可比性没法说明。但是,特征点检测效率还是很客观的。由以上结果得知,检测效率最高的前3个检测器分别为FAST,ORB,SURF。


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表