mans
mans

Reputation: 18148

How to use ocl module in opencv

I am trying to use ocl module in opencv. I am using Visual studio 2012

I started by sample code for feature detection using surf. The code seems as follow:

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);

The code works perfectly, Now I want to use SURF_OCL instead of SURF. What should I do?

The following code doesn't work:

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

generate compile time error:

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

What should I do to be able to use functions from ocl library?

Upvotes: 3

Views: 6798

Answers (1)

Albert
Albert

Reputation: 68110

You are missing an #include <...>, probably #include <opencv2/nonfree/ocl.hpp>. See here for an example.

Upvotes: 3

Related Questions