在 MATLAB 和 OpenCV 之间提取不同的 SURF 特征? [英] Different SURF Features Extracted Between MATLAB and OpenCV?

查看:29
本文介绍了在 MATLAB 和 OpenCV 之间提取不同的 SURF 特征?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 OpenCV 中实现了我在 MATLAB 中设计的算法.我正在为 OpenCV 中的 SURF 特征提取器编写单元测试,我想将 MATLAB 提取的 SURF 特征的输出与 OpenCV 进行比较.

这个问题是,对 MATLAB 和 OpenCV 提取器使用相同的参数时,我得到了不同数量的特征.这怎么可能?是否有不同的方式来实现 SURF?

对于 MATLAB (http://www.mathworks.com/help/vision/ref/detectsurffeatures.html) 我正在使用:

MetricThresh:200
NumOctaves: 3
NumScaleLevels:4
冲浪尺寸:64

对于我正在使用的 OpenCV:

HessianThreshold:200
nOctaves: 3
nOctaveLayers:4
扩展:假
直立:真

这里发生了什么?有没有更好的方法来测试 openCV 和 MATLAB 是否从同一张图像中提取了相同的 SURF 特征?

感谢您的帮助!

解决方案

在底层,MATLAB 将 OpenCV 用于它的一些 计算机视觉功能,包括检测SURF功能.如果您查看 $matlabroot/bin/$arch 文件夹,您会发现 OpenCV 共享库以及网关库 ocv.dll).

其实两者的文档中都提到了相同的参考论文,这表明算法参数在两个框架中具有相同的含义.

MATLAB

<块引用>

Herbert Bay、Andreas Ess、Tinne Tuytelaars、Luc Van Gool 冲浪:加速鲁棒特征",计算机视觉和图像理解(CVIU), 卷.110, No. 3, pp. 346--359, 2008

OpenCV

<块引用>

Bay, H. 和 Tuytelaars, T. 和 Van Gool, L. SURF: Speeded Up Robust Features",第 9 届 > 欧洲计算机视觉会议,2006 年

<小时>

首先,请确保您在两者中使用相同的参数值,并考虑默认值.以下是 OpenCVMATLAB 供参考.

所以试试下面的代码:

在 MATLAB 中:

>>img = [];% 一些 2d 灰度图像>>pts = detectSURFFeatures(img, 'MetricThreshold',200, ...'NumOctaves',3, 'NumScaleLevels',4);

在 C++ OpenCV 中:

cv::Mat img;//一些灰度图像cv::SURF surf(200.0, 3, 4-2, false, true);cv::垫掩码;//可选掩码(此处未使用)std::vector<cv::KeyPoint>分;冲浪(img,面具,pts);

除此之外,MATLAB 通常包含旧版本的 OpenCV(我的 MATLAB R2013a 附带 v2.4.2 DLL),这可能会导致与您使用的任何 OpenCV 版本不同的结果(目前最新的是 v2.4.6)

I'm implementing an algorithm in OpenCV that I've designed in MATLAB. I'm writing a unit test for the SURF feature extractor in OpenCV, and I want to compare the output of MATLAB's extracted SURF features to OpenCV.

This issue is, using the same parameters for both MATLAB and OpenCV extractors I'm getting different numbers of features. How is this possible? Are there different ways to implement SURF?

For MATLAB (http://www.mathworks.com/help/vision/ref/detectsurffeatures.html) I'm using:

MetricThresh: 200
NumOctaves: 3
NumScaleLevels: 4
SURFSize: 64

For OpenCV I'm using:

HessianThreshold: 200
nOctaves: 3
nOctaveLayers: 4
extended: false
upright: true

What's going on here? Is there a better way to test that openCV and MATLAB are producing the same extracted SURF features from the same image?

Thank you for your help!

解决方案

Under the hood, MATLAB uses OpenCV for some of its computer vision functions, including detecting SURF features. If you look inside the $matlabroot/bin/$arch folder, you'll find OpenCV shared libraries in addition to a gateway library ocv.dll).

In fact, the same reference paper is mentioned in the documentation of both, which suggests that the algorithm parameters have the same meaning in both frameworks.

MATLAB

Herbert Bay, Andreas Ess, Tinne Tuytelaars, Luc Van Gool "SURF: Speeded Up Robust Features", Computer Vision and Image Understanding (CVIU), Vol. 110, No. 3, pp. 346--359, 2008

OpenCV

Bay, H. and Tuytelaars, T. and Van Gool, L. "SURF: Speeded Up Robust Features", 9th > European Conference on Computer Vision, 2006


First thing, make sure you are using the same parameter values in both, taking into account the default values. Here are the doc pages for OpenCV and MATLAB for reference.

So try the following codes:

In MATLAB:

>> img = [];     % some 2d grayscale image
>> pts = detectSURFFeatures(img, 'MetricThreshold',200, ...
       'NumOctaves',3, 'NumScaleLevels',4);

In C++ OpenCV:

cv::Mat img;     // some grayscale image
cv::SURF surf(200.0, 3, 4-2, false, true);

cv::Mat mask;    // optional mask (unused here)
std::vector<cv::KeyPoint> pts;
surf(img, mask, pts);

Other than that, MATLAB usually include an older version of OpenCV (my MATLAB R2013a ships with v2.4.2 DLLs), which could result in different results from whatever OpenCV version you are using (latest as of now is v2.4.6)

这篇关于在 MATLAB 和 OpenCV 之间提取不同的 SURF 特征?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆