将数据从Mat/oclMat传输到cl_mem(OpenCV + OpenCL) [英] Transfer data from Mat/oclMat to cl_mem (OpenCV + OpenCL)

查看:243
本文介绍了将数据从Mat/oclMat传输到cl_mem(OpenCV + OpenCL)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个需要大量OpenCL代码的项目中工作.我正在使用OpenCV的ocl模块更快地开发我的项目,但是有些功能尚未实现,因此我必须编写自己的OpenCL代码.

I am working on a project that needs a lot of OpenCL code. I am using OpenCV's ocl module to develop my project faster but there are some functions not implemented and I will have to write my own OpenCL code.

我的问题是:将数据从Mat和/或oclMat传输到cl_mem数组的最快,最便宜的方法是什么?重新措辞这一点,是否存在从oclMat或Mat传输或排队(clEnqueueWriteBuffer)数据的好方法?

My question is this: what is the quickest and cheapest way to transfer data from Mat and/or oclMat to a cl_mem array. Re-wording this, is there a good way to transfer or enqueue (clEnqueueWriteBuffer) data from oclMat or Mat?

当前,我正在使用一个for循环从Mat中读取数据(或从oclMat下载然后使用for循环),然后将其放入队列.事实证明这是昂贵的,因此,我的问题是.

Currently, I am using a for-loop to read data from Mat (or download from oclMat and then use for-loops) and then enqueuing it. This is turning out to be costly, hence my question.

感谢任何看到此问题的人:)

Thanks to anyone who sees this question :)

推荐答案

我为 Boost.Compute 库,可简化OpenCL和OpenCV的使用.看看 功能.

I've written a set of interop functions for the Boost.Compute library which ease the use of OpenCL and OpenCV. Take a look at the opencv_copy_mat_to_buffer() function.

还有一些功能,可以从OpenCL缓冲区复制回主机cv::Mat,也可以将cv::Mat复制到OpenCL image2d对象.

There are also functions for copying from a OpenCL buffer back to the host cv::Mat and for copying cv::Mat to OpenCL image2d objects.

这篇关于将数据从Mat/oclMat传输到cl_mem(OpenCV + OpenCL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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