OpenCV Error: No CUDA support

Please provide complete information as applicable to your setup.

**• Hardware Platform (Jetson / GPU) Jetson AGX Xavier
**• DeepStream Version 5.0
**• JetPack Version (valid for Jetson only) 4.4

I am adding radial undistort function into gst-dsexample.cpp and get compilation through without problem. But when I run the pipeline. I got this error message:

OpenCV Error: No CUDA support (The library is compiled without CUDA support) in throw_no_cuda, file /build/opencv-L2vuMj/opencv-3.2.0+dfsg/modules/core/include/opencv2/core/private.cuda.hpp, line 97
terminate called after throwing an instance of 'cv::Exception'

What I add in the gstdsexample.h:

include “opencv2/calib3d/calib3d.hpp”
include “opencv2/core/core.hpp”
include “opencv2/core/cuda.hpp”

and

static cv::cuda::GpuMat gpu_xmap, gpu_ymap;

in gstdsexample.cpp

I call init_undistort_map in gst_dsexample_start, where init_undistort_map is defined as below:

static gboolean
init_undistort_map(GstDsExample * dsexample)
{
	//create xmap,ymap and load them to gpumat
	  int max_width = dsexample->processing_width;
	  int max_height = dsexample->processing_height;
	  /* Initialize maps from CPU */
	  cv::Mat xmap(max_height, max_width, CV_32FC1);
	  cv::Mat ymap(max_height, max_width, CV_32FC1);
	  cv::Mat cam(3, 3, cv::DataType<float>::type);
	  cam.at<float>(0, 0) = 825.47875363f;
	  cam.at<float>(0, 1) = 0.0f;
	  cam.at<float>(0, 2) = 626.52873675f;

	  cam.at<float>(1, 0) = 0.0f;
	  cam.at<float>(1, 1) = 828.1890254f;
	  cam.at<float>(1, 2) = 356.23308552f;

	  cam.at<float>(2, 0) = 0.0f;
	  cam.at<float>(2, 1) = 0.0f;
	  cam.at<float>(2, 2) = 1.0f;

	  cv::Mat dist(4, 1, cv::DataType<float>::type);
	  dist.at<float>(0, 0) = -0.4273608f;
	  dist.at<float>(1, 0) = 0.16401622f;
	  dist.at<float>(2, 0) = 0.00057418f;
	  dist.at<float>(3, 0) = -0.00062927f;
	  //dist.at<float>(4, 0) = -0.0273251f;

	  cv::fisheye::initUndistortRectifyMap(cam, dist, cv::Mat(), cam, cv::Size(max_width, max_height), CV_32FC1, xmap, ymap);

	  /* upload to GpuMats */
	  gpu_xmap.upload(xmap);
	  gpu_ymap.upload(ymap);

	  return TRUE;
}

and call undistort in gst_dsexample_transform_ip, where undistort is defined as below:

/*
 * Radial Undistort transformation (full-frame=0 and blur_objects=true)
 */
static GstFlowReturn
    undistort (GstDsExample * dsexample, cv::Mat in_mat)
    {
      //cv::Rect crop_rect;

      remap(in_mat,in_mat,gpu_xmap,gpu_ymap,cv::INTER_LINEAR);

      return GST_FLOW_OK;
    }

What am I missing? Please help! Thanks a lot.

see this link for opencv cuda support in AGX Xavier

1 Like

Hi @ynjiun,
Sorry for late reply!
The default OpenCV installed via SDKManager is not CUDA accelerated, so when you use “cv::cuda::GpuMat” with this opencv, it’s expected to report the “No CUDA support” error.

You may could uninstall current OpenCV and re-build a CUDA based opencv.