Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save webstorage119/caa3c636b3e008df6741714d32008616 to your computer and use it in GitHub Desktop.
Save webstorage119/caa3c636b3e008df6741714d32008616 to your computer and use it in GitHub Desktop.
First example of using OpenCL in OpenCV 3.x
// This example shows how to create
// a context from a specified device type
// using OpenCL wrappers provided by OpenCV 3.x
//
// The default platform is the zero-th platform
// returned by clGetPlatformIDs.
//
// To compile it on Mac OS X, add `-framework opencl`
// to CXX_FLAGS
#include <iostream>
#include <opencv2/core/ocl.hpp>
int main()
{
cv::ocl::Context ctx;
ctx.create(cv::ocl::Device::TYPE_CPU);
std::cout << ctx.ndevices() << std::endl;
std::cout << (ctx.create() ? "true":"false") << std::endl;
return 0;
}
// output:
//1
//false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment