Andrei CACIO Andrei CACIO - 7 days ago 4
C++ Question

Compilation error when I call the match method from BruteForceMatcher_GPU

I'm running Ubuntu 12.04, OpenCV and Cuda 5.5
I got the following code:

BruteForceMatcher_GPU< Hamming > matcher;
ORB_GPU orb(1000);
GpuMat patternImage_descriptors;
orb(patternImage_g, GpuMat(), patternImage_keypoints, patternImage_descriptors);

// where patternImage_g is an image I'm loading with GpuMat patternImage_g(originalImage)
// after I make it Gray and resizeing it to 640x480

// then I call
vector<GpuMat> descriptors(1);
descriptors[0] = patternImage_descriptors;
// to train the matcher and then

vector< vector<DMatch> > matches;
matcher.match(frame_descriptors, matches);

// Where frame_descriptors were extracted via ORB_GPU

and then I get this compilation error:

MatchingEngineGPU.cpp: In member function 'void
MatchingEngineGPU::processFrameFromFile(const Frame&, Frame&)':
MatchingEngineGPU.cpp:28:43: error: no matching function for call to
std::vector<std::vector<cv::DMatch> >&)'
MatchingEngineGPU.cpp:28:43: note: candidates are:
/usr/local/include/opencv2/gpu/gpu.hpp:1388:10: note: void
cv::gpu::BruteForceMatcher_GPU_base::match(const cv::gpu::GpuMat&, const
cv::gpu::GpuMat&, std::vector<cv::DMatch>&, const cv::gpu::GpuMat&)
/usr/local/include/opencv2/gpu/gpu.hpp:1388:10: note: candidate expects 4
arguments, 2 provided
/usr/local/include/opencv2/gpu/gpu.hpp:1404:10: note: void
cv::gpu::BruteForceMatcher_GPU_base::match(const cv::gpu::GpuMat&,
std::vector<cv::DMatch>&, const std::vector<cv::gpu::GpuMat>&)
/usr/local/include/opencv2/gpu/gpu.hpp:1404:10: note: no known conversion
for argument 2 from 'std::vector<std::vector<cv::DMatch> >' to

Compilation command:

g++ *.hpp *.cpp `pkg-config --cflags --libs opencv`

And I've checked the documentation for BruteForceMatcher_GPU and it has the following function:

void match(const GpuMat& query, std::vector<DMatch>& matches,
const std::vector<GpuMat>& masks = std::vector<GpuMat>());

It might be just a C++ logic error but for the life of me I can't figure it out, please help me.


As the error message and the documentation state, match takes a reference to std::vector<DMatch>, not a std::vector<std::vector<DMatch>>, which is what you're passing.