throw_no_cuda exception when run the opencv4.1.1 simple program on the Jetson AGX Xavier

Dear Support,

I just successfully flashed the JetPack4.3 into the Jetson AGX Xavier. Also did good source build of OpenCV4.1.1 in the Jetson AGX Xavier as well.

But after I try to run a simple OpenCV C++ program, I got following errors.

Please keep in mind, the same program runs very well in the OpenCV3.4 in Jetson TX2.

Could you please give me the suggestions how to solve the problem for OpenCV4.1.1?

Thanks a lot
Jimmy

compile command

nvcc pkg-config --cflags opencv4 08_haar_face_gpu.cpp pkg-config --libs opencv4

error message: after good compile with no error and run a.out

terminate called after throwing an instance of ‘cv::Exception’
what(): OpenCV(4.1.1) /home/jiande/OpenCV/opencv-4.1.1/modules/core/include/opencv2/core/private.cuda.hpp:113: error: (-213:The function/feature is not implemented) The called functionality is disabled for current build or platform in function ‘throw_no_cuda’

08_haar_face_gpu.cpp

#include “opencv2/objdetect/objdetect.hpp”
#include “opencv2/highgui/highgui.hpp”
#include “opencv2/imgproc/imgproc.hpp”
#include “opencv2/cudaobjdetect.hpp”
#include
#include <stdio.h>

using namespace std;
using namespace cv;

int main( )
{
Mat h_image;
h_image = imread(“images/lena_color_512.tif”, 0);
Ptrcuda::CascadeClassifier cascade = cuda::CascadeClassifier::create(“haarcascade_frontalface_alt2.xml”);
cuda::GpuMat d_image;
cuda::GpuMat d_buf;
d_image.upload(h_image);
//cascadeGPU->setMinNeighbors(0);
//cascadeGPU->setScaleFactor(1.01);
cascade->detectMultiScale(d_image, d_buf);
std::vector detections;
cascade->convert(d_buf, detections);
if (detections.empty())
std::cout << “No detection.” << std::endl;
cvtColor(h_image,h_image,COLOR_GRAY2BGR);
for(int i = 0; i < detections.size(); ++i)
{
rectangle(h_image, detections[i], Scalar(0,255,255), 5);
}

imshow(“Result image”, h_image);

waitKey(0);
return 0;
}

Also did good source build of OpenCV4.1.1 in the Jetson AGX Xavier as well.

Did you build opencv4.1.1 with cuda enabled?

Hi Wayne,

I used the Nvidia build scripts where:

cmake -D WITH_CUDA=ON -D CUDA_ARCH_BIN=“5.3,6.2,7.2” -D CUDA_ARCH_PTX="" -D OPENCV_EXTRA_MODULES_PATH=…/…/opencv_contrib-4.1.1/modules -D WITH_GSTREAMER=ON -D WITH_LIBV4L=ON -D BUILD_opencv_python2=ON -D BUILD_opencv_python3=ON -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF -D CMAKE_BUILD_TYPE=RELEASE -D OPENCV_GENERATE_PKGCONFIG=YES -D CMAKE_INSTALL_PREFIX=/usr/local …

I think that -D WITH_CUDA=ON means that cuda enable.

Do I miss something else here?

Thanks
Jimmy

Unfortunately we are not developing openCV so cannot share solid answer here.
I would suggest to file a topic on openCV forum and see if any difference between 4.1.1 and 3.2.