Ask Your Question
1

opencv error: the function/feature is not implemented

asked 2016-01-20 02:20:12 -0600

busrakkk gravatar image

updated 2016-01-20 02:26:55 -0600

I am using opencv 3.1.0, visual studio 2013 and cuda 6.5 I wrote a simple code (got it from original tutorial) which includes gpu namespaces i changed them to cv::cuda since opencv 3.0 doesn't support it anymore. but the code still doesn't work. get the error "opencv error: the function/feature is not implemented"

Here is the code

    #include <opencv2/opencv.hpp>
    #include <opencv2/gpu/gpu.hpp>
    using namespace cv;
    int main() {
    Mat src = imread(“car1080.jpg”, 0);
    if (!src.data) exit(1);
    //gpu::GpuMat d_src(src);
    cv::cuda::GpuMat d_src(src);
    //gpu::GpuMat d_dst;
    cv::cuda::GpuMat d_dst;
    //gpu::bilateralFilter(d_src, d_dst, -1, 50, 7);
    cv::cuda::bilateralFilter(d_src, d_dst, -1, 50, 7);
    //gpu::Canny(d_dst, d_dst, 35, 200, 3);
    cv::Canny(d_dst, d_dst, 35, 200, 3);
    Mat dst(d_dst);
    imwrite(“out.png”, dst);
    return 0;
    }

As I searched, rebuilding opencv using cmake with additional options can be a solution to that problem. However, they are not so sure. Any help?

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
2

answered 2016-01-20 03:49:08 -0600

updated 2016-01-20 06:21:20 -0600

It seems that in order to get the cuda functionality working you need to explicitly include the CUDA header of that function. This setup did it just fine on my system

UPDATE

  • It seems that the error is not due the reasons I expected but due to the misuse between Mat and GpuMat container.
  • There is no constructor for a Mat element that takes a GpuMat as input.
  • In order to transfer data you need to download from Gpu memory.

Adapted and working code --> Verified

#include <opencv2/opencv.hpp>
#include <opencv2/cuda.hpp>
#include <opencv2/cudaimgproc.hpp>

using namespace cv;

int main() {
    Mat src = imread("/home/spu/Desktop/test.jpg", 0);
    if (!src.data) exit(1);
    cuda::GpuMat d_src(src);
    cuda::GpuMat d_dst;
    cuda::bilateralFilter(d_src, d_dst, -1, 50, 7);
    Mat dst;
    d_dst.download(dst);
    cv::Canny(dst, dst, 35, 200, 3);
    resize(dst, dst, Size(dst.cols/3, dst.rows/3));
    imshow("test", dst); waitKey(0);
    return 0;
}

And the result as seen below

image description

edit flag offensive delete link more

Comments

I added cuda.hpp but same problem continued. Some people say disabling WITH_CUBLAS or WITH_NVCUVID at CMake can cause the problem.

busrakkk gravatar imagebusrakkk ( 2016-01-20 04:47:56 -0600 )edit

Why would you disable WITH_CUBLAS and WITH_NVCUVID if you want CUDA support? Could you add your CMAKE output? Also, only cuda.hpp does not work for me, I explicitly needed cudaimgproc.hpp. What error is generated if you run the code above?

StevenPuttemans gravatar imageStevenPuttemans ( 2016-01-20 05:52:08 -0600 )edit

Because I'm really new at OpenCV&CUDA. The error is; "OpenCV Error: The function/feature is not implemented You should explicitly call download method for cuda::GpuMat object in .... "

p.s. when I enable WITH_CUBLAS and WITH_NVCUVID I get "CMake Error: The following variables are used in this project but they are set to NOTFOUND. .... CUDA_nuvecuvenc_LIBRARY (ADVANCED)"

busrakkk gravatar imagebusrakkk ( 2016-01-20 06:06:24 -0600 )edit

Do you have a valid CUDA development kit installed?

StevenPuttemans gravatar imageStevenPuttemans ( 2016-01-20 06:11:41 -0600 )edit

I found the exact reason of your error and pointed it out above :)

StevenPuttemans gravatar imageStevenPuttemans ( 2016-01-20 06:21:46 -0600 )edit
1

CUDA is working and valid i have tested. The code is working now thanks a lot :)

busrakkk gravatar imagebusrakkk ( 2016-01-20 06:31:11 -0600 )edit

You are welcome :)

StevenPuttemans gravatar imageStevenPuttemans ( 2016-01-20 06:42:21 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-01-20 02:20:12 -0600

Seen: 10,003 times

Last updated: Jan 20 '16