python的opencv库使用gpu加速_在Python中将OpenCL加速功能与OpenCV3一起使用

OpenCV3 introduced its T-API (Transparent API) which gives the user the possibility to use functions which are GPU (or other OpenCL enabled device) accelerated, I'm struggling to find how to tap into that with Python.

With C++ there are calls like ocl::setUseOpenCL(true); that enable OpenCL acceleration when you use UMat instead of Mat objects. However I found no documentation whatsoever for Python.

Does anybody have any sample code, links or guides on how to achieve OpenCL acceleration with OpenCV3 in Python?

UPDATE:

After some further digging I've found this in modules/core/include/opencv2/core/ocl.hpp:

CV_EXPORTS_W bool haveOpenCL();

CV_EXPORTS_W bool useOpenCL();

CV_EXPORTS_W bool haveAmdBlas();

CV_EXPORTS_W bool haveAmdFft();

CV_EXPORTS_W void setUseOpenCL(bool flag);

CV_EXPORTS_W void finish();

Which I managed to call from Python:

print(cv2.ocl.haveOpenCL())

cv2.ocl.setUseOpenCL(True)

print(cv2.ocl.useOpenCL())

And it produces the following output:

True

True

However it still runs the same, I suppose I'm still not using OpenCL because I don't use UMat in Python.

解决方案

Information update

For those of you who see this, OpenCL for OpenCV python version has already been impemented

at 6 Oct 2016

More information

For more information, you can take a look at this issue: T-API python support implemented #6078

你可能感兴趣的:(python的opencv库使用gpu加速_在Python中将OpenCL加速功能与OpenCV3一起使用)