Performance of OpenCV GPU BruteForceMatcher
Hello,
I'm trying to accelerate the OpenCV CPU BruteForce Matcher by using its GPU version. Here is my code:
// OpenCV CPU BruteForceMatcher
timer.start();
vector < vector<DMatch> > cpu_matches;
Ptr<DescriptorMatcher> cpu_matcher = DescriptorMatcher::create("BruteForce");
cpu_matcher->knnMatch(descriptors_img , descriptors_fond , cpu_matches , 2);
timer.stop();
cout << "OpenCV CPU MATCHING TIME : " << timer.ellapsedTime() << " ms." << endl;
// OpenCV GPU BruteForceMatcher
timer.start();
GpuMat gpu_descriptors_img (descriptors_img) , gpu_descriptors_fond (descriptors_fond);
vector < vector<DMatch> > gpu_matches;
BruteForceMatcher_GPU_base gpu_matcher;
gpu_matcher.knnMatch(gpu_descriptors_img , gpu_descriptors_fond , gpu_matches , 2);
timer.stop();
cout << "OpenCV GPU MATHING TIME : " << timer.ellapsedTime() << " ms." << endl;
The problem is that the GPU matcher is always slower than the cpu one. Can anyone can explain me why? thank you.
Set up: I'm Using CUDA 5.0 with GeForce GTX 650 (compute capability 3.0) , Ubuntu 14.04 LTS
are you using OpenCV with IPP or without IPP? IPP uses GPU internally! If not, try measuring without the overhead of loading images from/to gpu. and call the gpu function once before time measurement (first call might be slow).