Last active
June 4, 2024 09:09
-
-
Save csukuangfj/49d6e8fb4bf4b694f2235b8fcfd1ca8b to your computer and use it in GitHub Desktop.
First example of using OpenCL in OpenCV 3.x
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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