我正在尝试在 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/