CUDA Canny Edge Detector

Can anyone help me figure out how to use the Canny Edge detector with CUDA in OpenCV (4.5.1)? Of course I have a CUDA GPU (on my Nvidia Jetson Nano) and I’ve tested it working with other CUDA OpenCV functions.

As suggested here I’ve tried the following:

#include
#include<opencv2/opencv.hpp>
#include<opencv2/core/core.hpp>
#include<opencv2/cudaimgproc.hpp>
#include<opencv2/core/cuda.hpp>
using namespace std;
using namespace cv;

int main(int argc, char *argv)
{

VideoCapture videoStream(0);


cv::Ptr<cv::cuda::CannyEdgeDetector> gpuEdgeDetector =cv::cuda::createCannyEdgeDetector(50.0,100.0);
//Ptr<cuda::CannyEdgeDetector> gpuEdgeDetector = cuda::createCannyEdgeDetector(50.0,100.0);
//Ptr<cuda::CannyEdgeDetector> gpuEdgeDetector;
//gpuEdgeDetector->setLowThreshold(50.0)
//gpuEdgeDetector->setHighThreshold(100.0);


// loop through each video frame
while (videoStream.isOpened())
{

    // get video frame
    Mat frame;
    videoStream >> frame;

    // check if curtent video frame is still available
    if (frame.empty())
    {
        std::cout << "End of video" << endl;

        cv::waitKey();
        break;
    }

    // canny edge detection
    //Mat edges;

    // convert Mats to GPU Mats for cuda
    cuda::GpuMat gpuFrame(frame);

    cuda::GpuMat gpuEdges;

    gpuEdgeDetector->detect(gpuFrame,gpuEdges);
    //Canny(frame, edges, cannyLowThresh, cannyHightThresh);

    //convert results to Mat to view
    Mat edges;
    gpuEdges.upload(edges);


    // display
    imshow("Edges", edges);
    imshow("Video player", frame);


    char c = (char)cv::waitKey(50);
    if (c == 27) // press escape to break
    {
        break;
    }
}

videoStream.release();
std::cout << "press any key to quit" << endl;
cv::waitKey(0);
return(0);

}

But this line:
cv::Ptrcv::cuda::CannyEdgeDetector cannyFilter = cv::cuda::createCannyEdgeDetector(50.0, 100.0);

gives me the error:
"undefined reference to 'cv::cv::cuda::createCannyEdgeDetector(double, double, int, bool)

I understand this undefined reference usually means I have not included the required libraries but I don’t believe that’s the case here because Qt seems to find this function with autocomplete. By the way the last two arguments (int,bool) are defaults (3,false).

Please can someone share an example working in OpenCV 4.5 or above and show me where I have gone wrong? Thank you

do you link -lopencv_cudaimgproc ?

false positive. your ide might find headers/definitions, but not (binary) libraries