2
votes

I am trying to make a feature matching algorithm with OpenCV on CUDA. I am using the ORB features. The main problem I have is that I am able to well compute the ORB keypoints but the descriptors are always empty. I tried all the ways but without success. I tried with the last version of opencv (3.4.0) and the 3.2.0 version. This is the simplified version of my code:

cv::Ptr<cv::cuda::ORB> orb_gpu = cv::cuda::ORB::create(5000);
std::vector<cv::KeyPoint> keypoints;
cv::cuda::GpuMat descriptors;
cv::cuda::GpuMat img_gpu(curr_frame);
orb_gpu->detect(img_gpu, keypoints); 
orb_gpu->compute(img_gpu, keypoints, descriptors);
cv::Mat desc_cpu;
descriptors.upload(desc_cpu);
1

1 Answers

2
votes

The problem is with the direction of memory copy. You are calling upload instead of download function to copy descriptors from device to host. The following line is the culprit:

descriptors.upload(desc_cpu);

Replace it with:

descriptors.download(desc_cpu);

upload copies from host to device whereas download copies from device to host.

I have tested and verified the example with OpenCV 3.4 compiled with CUDA 8 on Ubuntu 14.04.