执行“ surf(img1,cv :: cuda :: GpuMat(),keypoints1GPU,descriptors1GPU)时出现错误;”确切指的是https://github.com/opencv/opencv/blob/3.4/samples/gpu/surf_keypoint_matcher.cppC ++代码为:
{
...
cv::cuda::GpuMat img1, img2;
img1.upload(imread("query.jpg", IMREAD_GRAYSCALE));
CV_Assert(!img1.empty());
img2.upload(imread("ref.jpg", IMREAD_GRAYSCALE));
CV_Assert(!img2.empty());
cv::cuda::printShortCudaDeviceInfo(cv::cuda::getDevice());
cv::cuda::SURF_CUDA surf;
cv::cuda::GpuMat keypoints1GPU, keypoints2GPU;
cv::cuda::GpuMat descriptors1GPU, descriptors2GPU;
surf(img1, GpuMat(), keypoints1GPU, descriptors1GPU);
surf(img2, GpuMat(), keypoints2GPU, descriptors2GPU);
...
}
错误详细信息:OpenCV错误:loadGlobalConstants中的Gpu API调用(无效的设备符号),文件/tmp/opencv/opencv/opencv_contrib/modules/xfeatures2d/src/cuda/surf.cu,行109
设备信息:设备0:“ Tesla V100-SXM2-32GB” 32256Mb,sm_70,驱动程序/运行时ver.10.10 / 10.0驱动程序版本:418.39 CUDA版本:10.1
OpenCV信息:版本3.2.0
任何想法都将不胜感激。
我也遇到过同样的问题,并在this thread的帮助下找到了解决方案
似乎在OpenCV函数中存在与索引相关的问题。在您的情况下,更改如下所示的代码应该可以:
{ ... cv::cuda::GpuMat img1, img2, img1dummy, img2dummy; img1dummy.upload(imread("query.jpg", IMREAD_GRAYSCALE)); CV_Assert(!img1dummy.empty()); img2dummy.upload(imread("ref.jpg", IMREAD_GRAYSCALE)); CV_Assert(!img2dummy.empty()); cv::cuda::printShortCudaDeviceInfo(cv::cuda::getDevice()); cv::cuda::SURF_CUDA surf; cv::cuda::GpuMat keypoints1GPU, keypoints2GPU; cv::cuda::GpuMat descriptors1GPU, descriptors2GPU; img1 = img1dummy.clone(); img2 = img2dummy.clone(); surf(img1, GpuMat(), keypoints1GPU, descriptors1GPU); surf(img2, GpuMat(), keypoints2GPU, descriptors2GPU); ... }
我的OpenCV版本是4.2.0。