c++ - opencv中ocl模块的使用方法

标签 c++ opencv opencl

我正在尝试在 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> .参见 here举个例子。

关于c++ - opencv中ocl模块的使用方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19424538/

相关文章:

c++ - 在 Sublime text 3 中编译简单的 C++ 程序时出错

python - 全局名称 'img' 未定义?

c++ - OpenCV 边缘增强

c++ - OpenCL - GPU 上的多线程

opencl - OpenCL 2.0 的管道什么时候有用?

c++ - 在C++中动态创建指针函数

c++ - 如何使用 Boost MSM 减少编译时间

opencl - 理想的全局/本地工作组规模 (OpenCL)

c++ - 什么时候使用虚拟析构函数?

opencv - 如何使用openCV确定平移和旋转矩阵