1 | initial version |
It turns out that LBerger was on the right track. You have to use
cv::ocl::attachContext(PlatformName, platforms[0], context(), devices[0]()); // C++
or for C code of OpenCL:
cv::ocl::attachContext(PlatformName, platform, context, device); // C
to use the context created by OpenCL, I was able to do it using the c++ code from my comment and I had to borrow some code to get the first 2 values, I'm sure there is a more efficient method (and one that doesn't assume you only have 1 platform):
// C Code Changes from my original Question
cl_image_desc desc_src;
desc_src.image_type = CL_MEM_OBJECT_IMAGE2D;
desc_src.image_width = mat.cols;
desc_src.image_height = mat.rows;
desc_src.image_depth = 0;
desc_src.image_array_size = 0;
desc_src.image_row_pitch = mat.step[0];
desc_src.image_slice_pitch = 0;
desc_src.num_mip_levels = 0;
desc_src.num_samples = 0;
desc_src.buffer = 0;
size_t sz = 0;
clGetPlatformInfo(platform, CL_PLATFORM_NAME, 0, 0, &sz);
char PlatformName[sz+1];
clGetPlatformInfo(platform, CL_PLATFORM_NAME, sz, PlatformName, 0);
cv::ocl::attachContext(PlatformName, platform, context, device);
IDKmem = clCreateImage(context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR,&tif_format,&desc_src,mat.ptr(),&err);
Hope that helps someone else.