0
votes

I got an error when performing "surf(img1, cv::cuda::GpuMat(), keypoints1GPU, descriptors1GPU);" which exactly refers to https://github.com/opencv/opencv/blob/3.4/samples/gpu/surf_keypoint_matcher.cpp The c++ code is:

{
    ...
    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);
    ...
}

The error details: OpenCV Error: Gpu API call (invalid device symbol) in loadGlobalConstants, file /tmp/opencv/opencv/opencv_contrib/modules/xfeatures2d/src/cuda/surf.cu, line 109

Device info.: Device 0: "Tesla V100-SXM2-32GB" 32256Mb, sm_70, Driver/Runtime ver.10.10/10.0 Driver Version: 418.39 CUDA Version: 10.1

OpenCV info.: version 3.2.0

Any ideas would be greatly appreciated.

1

1 Answers

0
votes

I've experienced the same problem and found the solution via the help of this thread

It seems like there is a problem related to indexing in OpenCV functions. In your case, changing code as I show below should work:

{
    ...
    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);
    ...
}

My OpenCV version is 4.2.0.