如何在opencv中使用ocl模块

How to use ocl module in opencv

本文关键字:ocl 模块 opencv      更新时间:2023-10-16

我正在尝试在opencv中使用ocl模块。我正在使用Visual Studio 2012

我从使用 surf 进行功能检测的示例代码开始。代码如下所示:

SURF detector;
SURF extractor;
BFMatcher matcher;
std::vector<KeyPoint> keypoints_1, keypoints_2;
detector.detect( image1, keypoints_1 );
detector.detect( image2, keypoints_2 );
//-- Step 2: Calculate descriptors (feature vectors)
Mat descriptors_1, descriptors_2;
extractor.compute( image1, keypoints_1, descriptors_1 );
extractor.compute( image2, keypoints_2, descriptors_2 );
//-- Step 3: Matching descriptor vectors using FLANN matcher
std::vector< DMatch > matches;
matcher.match( descriptors_1, descriptors_2, matches);

代码运行良好,现在我想使用 SURF_OCL 而不是 SURF。我该怎么办?

以下代码不起作用:

ocl::SURF_OCL detector;
ocl::SURF_OCL extractor;

生成编译时错误:

'ocl' : is not a class or namespace name
'SURF_OCL' : undeclared identifier

我应该怎么做才能使用 ocl 库中的函数?

你缺少一个#include <...>,可能#include <opencv2/nonfree/ocl.hpp> .有关示例,请参阅此处。