I am developing a project using opencv and opencl. Right now, the kernels and the buffer runs using the opencv specified functions. For some reasons, I want to use OpenCL's native function instead of opencv function with least number of changes. I have two files. In the main file I created the context and pass it to the function to the second file. In the second file I need to build and execute kernel. If I would use OpenCV's function I can use execute kernel with the context that has been passed to the second file. But as I am planning to use OpenCL's native one, I need to bild the kernel and for that I need device list. My question is, is there any way I can get the device list from opencv created context? or how can I get the device list without passing the info from the main file?
Here is the snippet of main file:
vector<ocl::Info> oclinfo;
int devnums = ocl::getDevice(oclinfo);
if( devnums < 1 )
{
std::cout << "no device found\n";
return -1;
}
ocl::setBinpath("./");
cv::ocl::Context* clCxt = ocl::Context::getContext();
ScanKernel( Mat& img,string kernelsrc,string kernelName,cv::ocl::Context* clCxt)
here is the code snippet of the second file:
const char * source = kernelsrc.c_str();
size_t sourceSize[] = { strlen(source) };
cpProgram = clCreateProgramWithSource((cl_context)clCxt->oclContext(), 1, &source, sourceSize, &ciErr1);
if (ciErr1 != CL_SUCCESS) {
printf("Error in clCreateProgramWithSource, Line %u in file %s %d !!!\n\n", __LINE__, __FILE__,ciErr1);
}
else
{ printf("*** Got createprogramwithsource\n");
**ciErr1 = clBuildProgram(cpProgram, NULL, NULL, NULL, NULL, NULL);**
if (ciErr1 != CL_SUCCESS) {
printf("Error in building, Line %u in file %s error NO: %d!!!\n\n", __LINE__, __FILE__,ciErr1);
}
I need help on getting the device list for clBuildProgram function.