Throw error when use cuda::warpAffine

When I use cv::cuda::warpAffine function and the GpuMat is created by cv::cuda::createContinuous function, the code throws error:
OpenCV(4.5.0) D:/opencv-4.5.0/modules/core/include\opencv2/core/cuda/common.hpp:102 error: (-217:Gpu API call) invalid argument in function ‘cv::cuda::device::bindTexture’

The code as follows:
cuda::GpuMat imgGpu = cuda::createContinuous(img.size(), img.type());
imgGpu.upload(img);
cuda::GpuMat dstGpu = cuda::createContinuous(img.size(), img.type());
warpAffine(imgGpu, dstGpu, rot_mat, imgGpu.size(), INTER_LINEAR);

That implementation of warpAffine uses texture memory which needs to be aligned i.e. pitched.

Internally this could be changed so that the non texture version would be executed if the matrix is continuous, however even if that is successful the performance will degrade due to the lack of memory alignment.

Do you have a good reason for using continuous GpuMat’s given that most CUDA functions will be slower when working with them?

1 Like

OK,I got it. Thank you.