OpenCV - NCV Assertion Failed:

Hey I compiled OpenCv on TX1 its capturing images and saving images but i am receiving following error at the end

gpu::setDevice(0);

int detections_number;
cv::gpu::CascadeClassifier_GPU cascade_gpu;

ostringstream filename_cv;
filename_cv << imageCnt << ".jpg";

cascade_gpu.load("haarcascade_frontalface_alt.xml");
cv::Mat image_cv4t = imread(filename.str().c_str(), CV_LOAD_IMAGE_UNCHANGED);
gpu::GpuMat image_cv4t_device(image_cv4t);

      putText(image_cv4t, "Camera:1", Point(53,110),
                                FONT_HERSHEY_SIMPLEX, 1, Scalar(255,250,0), 1, CV_AA);
  gpu::GpuMat objbuf;
  detections_number = cascade_gpu.detectMultiScale( image_cv4t_device,
                                                    objbuf, 1.2,  2);

  cv::Mat obj_host;
  Rect* faces = obj_host.ptr<Rect>();
  objbuf.colRange(0, detections_number).download(obj_host);



    for(int i = 0; i < detections_number;i)
              cv::rectangle(image_cv4t, faces[i], Scalar(255));


  imwrite(filename_cv.str(),image_cv4t);

Done! Press Enter to exit…
OpenCV Error: Gpu API call (NCV Assertion Failed: cudaError_t=29, file=/hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/gpu/src/nvidia/core/NCV.cu, line=336
) in NCVDebugOutputHandler, file /hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/gpu/src/cascadeclassifier.cpp, line 173
terminate called after throwing an instance of ‘cv::Exception’
what(): /hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/gpu/src/cascadeclassifier.cpp:173: error: (-217) NCV Assertion Failed: cudaError_t=29, file=/hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/gpu/src/nvidia/core/NCV.cu, line=336
in function NCVDebugOutputHandler

Aborted

Hello, raak:
Would you please provide the openCV version you are using?
You built openCV by yourself or use opencv4tegra directly?

br
ChenJian

Hey Chen,

issue resolved, I am using OpenCV for Tegra, the sample code provided by OpenCv is buggy.

Thanks

Hello raak:

I have the same error, could you please tell me how to solve it? thanks!

Hi Richard,

for the particular problem, passing of empty mat objects was the issue.

i used .empty() to verify mat objects before passing