Hello,
I am loading and manipulating images using OpenCV and want to perform morphological erosion on them using Nvidia NPP, but I always get the following error:
error: (-217:Gpu API call) an illegal memory access was encountered in function ‘download’
The error states that it fails in function download, but when setting breakpoints it actually seems to happen when calling nppiErode_8u_C1R.
This is the error in the debugger:
No source available for “void ForEachPixelByte<unsigned char, 1, ErodeReplicateBorderFunctor<unsigned char, 1> >() at 0x55555f777928”
Also, the first call does not throw an error, but the second call does (in the second iteration of the loop).
I am loading the image in a cv::Mat and upload it into a cv::cuda::GpuMat.
Then I perform operations on it using some of OpenCV’s CUDA-functions and store the resulting image in another GpuMat. This runs in a loop (the part after the first four declarations):
stream_left = cv::cuda::Stream::Null();
cv::cuda::GpuMat src = cv::cuda::GpuMat(1242, 2208, CV_8UC1);
cv::cuda::GpuMat out = cv::cuda::GpuMat(1242, 2208, CV_8UC1);
cv::Mat src_host;
// load image into src_host and perform some OpenCV-CUDA-functions ...
// ...
src = mask.createMaskUsingCUDA(image_left_gpu, stream_left);
// using NPP
cv::Mat kernel = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(5, 5));
cv::cuda::GpuMat kernel_gpu;
kernel_gpu.upload(kernel);
NppiSize roi;
roi.width = kernel_gpu.cols;
roi.height = kernel_gpu.rows;
NppiSize mask;
mask.width = kernel_gpu.cols;
mask.height = kernel_gpu.rows;
NppiPoint anchor;
anchor.x = ((kernel.cols - 1) / 2) + 1;
anchor.y = ((kernel.rows - 1) / 2) + 1;
nppiErode_8u_C1R(src.ptr<Npp8u>(), static_cast<int>(src.step), out.ptr<Npp8u>(), static_cast<int>(out.step), roi, kernel.ptr<Npp8u>(), mask, anchor);
out.download(src_host, stream_left);
I already tried different values for the step, but that does not seem to change anything.
I really appreciate any help.
Thank you!