"how can i change the device on which opencl-code will be executed with umat in opencv?" Code Answer

2

i use something like this to check versions and hardware being used for opencl support.

ocl::setuseopencl(true);
if (!ocl::haveopencl())
{
    cout << "opencl is not available..." << endl;
    //return;
}

cv::ocl::context context;
if (!context.create(cv::ocl::device::type_gpu))
{
    cout << "failed creating the context..." << endl;
    //return;
}

cout << context.ndevices() << " gpu 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;
}

then you can set your preferred hardware to use, using this

cv::ocl::device(context.device(1));

hope this helps you.

By modesitt on February 17 2022

Answers related to “how can i change the device on which opencl-code will be executed with umat in opencv?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.