Hello together,
I recently started trying to use OpenCVs OpenCL. By executing following code but i´m not able to find any device (cv::ocl::haveOpenCL() returns true).
cv::ocl::Context context;
if (!context.create(cv::ocl::Device::TYPE_ALL))
{
cout << "Failed creating the context..." << endl;
//return;
}
cout << context.ndevices() << " CPU devices are detected." << endl; //This bit provides an overview of the OpenCL devices you have in your computer
for (int i = 0; i < context.ndevices(); i++)
{
cv::ocl::Device device = context.device(i);
cout << "name: " << device.name() << endl;
cout << "available: " << device.available() << endl;
cout << "imageSupport: " << device.imageSupport() << endl;
cout << "OpenCL_C_Version: " << device.OpenCL_C_Version() << endl;
cout << endl;
}
So I thought OpenCL isn´t set-up correctly so I tried it with the "normal OpenCL" with following lines of code, which outputs the devices and platforms as expected: Output: http://img5.fotos-hochladen.net/uploads/consoleoutput8v5g1ysdam.png"
std::vector<cl::Platform> all_platforms;
cl::Platform::get(&all_platforms);
if (all_platforms.size() == 0) {
std::cout << " No platforms found. Check OpenCL installation!\n";
}
else
{
std::cout << "################################################################" << endl;
std::cout << "################## Verfuegbare Hardware ########################" << endl;
std::cout << "################################################################" << endl;
for (int i = 0; i < all_platforms.size(); i++)
{
std::cout << "Platform " << i+1 << ": " << all_platforms[i].getInfo<CL_PLATFORM_NAME>() << "\n";
std::cout << "Platform version: " << all_platforms[i].getInfo<CL_PLATFORM_VERSION>() << "\n";
//get default device of the default platform
std::vector<cl::Device> all_devices;
all_platforms[i].getDevices(CL_DEVICE_TYPE_ALL, &all_devices);
if (all_devices.size() == 0) {
std::cout << " No devices found. Check OpenCL installation!\n";
}
else
{
for (int j = 0; j < all_devices.size(); j++)
{
cl::Device default_device = all_devices[j];
std::cout << "Device " << j+1 << ": " << default_device.getInfo<CL_DEVICE_NAME>() << "\n";
}
}
std::cout << "___________________________________________" << endl;
}
}
After that I tried to use the OpenCVs OpenCL nevertheless by executing a comparison between UMat Canny and Mat Canny, the UMat Canny runs much faster. Now i´m quite confused why it works and on which device and platform it runs? I hope someone can clarify whats going on :D
i appreciate your help. Thanks