在Python中将OpenCL加速功能与OpenCV3一起使用 [英] Using OpenCL accelerated functions with OpenCV3 in Python

查看:614
本文介绍了在Python中将OpenCL加速功能与OpenCV3一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OpenCV3引入了T-API(透明API),这使用户可以使用GPU(或其他启用OpenCL的设备)加速的功能,我正在努力寻找如何利用Python来实现这一功能.

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.

在C ++中,当您使用UMat而不是Mat对象时,像ocl::setUseOpenCL(true);这样的调用会启用OpenCL加速.但是我没有找到任何关于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.

是否有人提供示例代码,链接或指南,说明如何使用Python中的OpenCV3实现OpenCL加速?

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

更新:

进一步挖掘后,我在modules/core/include/opencv2/core/ocl.hpp中找到了它:

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();

我设法从Python打电话给我

Which I managed to call from Python:

print(cv2.ocl.haveOpenCL())
cv2.ocl.setUseOpenCL(True)
print(cv2.ocl.useOpenCL())

它会产生以下输出:

True
True

但是它仍然运行相同,我想我仍然没有使用OpenCL,因为我没有在Python中使用UMat.

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

推荐答案

信息更新

对于那些看到此内容的人来说,OpenCL for OpenCV python 版本已经实现

2016年10月6日

at 6 Oct 2016

有关更多信息,您可以看一下这个问题:已实现T-API python支持#6078

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

这篇关于在Python中将OpenCL加速功能与OpenCV3一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆