I need to use opencv-cuda for some image distortion correction, I manually transplanted opencv4.6.0 version, and the following error occurred during use.
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.6.0) /home/hl/Workspace/opencv/workspace/opencv-4.6.0/modules/core/src/cuda/gpu_mat.cu:270: error: (-217:Gpu API call) invalid argument in function 'copyTo
Here’s my code:
static cv::cuda::GpuMat gpu_xmap, gpu_ymap;
static void cv_process_RGBA(void *pdata, int32_t width, int32_t height)
{
cv::cuda::GpuMat d_Mat_RGBA(height, width, CV_8UC4, pdata,16640);
cv::cuda::GpuMat d_Mat_RGBA_Src;
d_Mat_RGBA.copyTo(d_Mat_RGBA_Src); // cannot avoid one copy
cv::cuda::remap(d_Mat_RGBA_Src, d_Mat_RGBA, gpu_xmap, gpu_ymap, cv::INTER_CUBIC, cv::BORDER_CONSTANT, cv::Scalar(0.f, 0.f, 0.f, 0.f));
// Check
if(d_Mat_RGBA.data != pdata)
std::cerr << "Error reallocated buffer for d_Mat_RGBA" << std::endl;
}