Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

What's causing the assertion fail in cv::ocl::convertFromImage

I'm getting an assertion fail in the last assertion in ocl.cpp (line 5466?),

OpenCV Error: Assertion failed (clEnqueueCopyImageToBuffer(q, clImage, clBuffer, src_origin, region, offset, 0, NULL, NULL) == CL_SUCCESS) in convertFromImage, file /home/xxxxx/opencv-3.0.0/modules/core/src/ocl.cpp, line 5466

This line:

CV_Assert(clEnqueueCopyImageToBuffer(q, clImage, clBuffer, src_origin, region, offset, 0, NULL, NULL) == CL_SUCCESS);

which I would have thought it wouldn't have made it all the way through the function and then fault there. Here is the code, I'm probably mixing up the library notation somehow.

int main()
{
cv::Mat mat(480, 640, CV_32FC4);
mat.setTo(cv::Scalar(0,1,1,0));
cv::imshow("CVforCLimage", mat);
cv::waitKey(0);

cl_platform_id platform;
cl_device_id device;
cl_context context;
cl_int err;
clGetPlatformIDs(1, &platform, NULL);
clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device, NULL);
context = clCreateContext(NULL, 1, &device, NULL, NULL, &err);

cl_mem IDKmem;
cl_image_format tif_format;
tif_format.image_channel_order =   CL_RGBA;
tif_format.image_channel_data_type =   CL_FLOAT;

IDKmem = clCreateImage2D(context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR,&tif_format,mat.cols, mat.rows, 0,mat.data,&err);
cv::UMat Umat;
cv::ocl::convertFromImage(IDKmem, Umat);
cv::imshow("CVforCLimage", Umat);
cv::waitKey(0);

return 0;
}

The function convertFromImage is causing the problem, I tried to make it as basic as I could to try and understand the numenclautre. Thanks!