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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值