如何从opencv 3.0 Beta中的文件读取UMat? [英] How to read UMat from a file in opencv 3.0 Beta?
问题描述
我想使用UMat
,因此我的代码可以使用OpenCL(OpenCV 3.0.0 Beta)在GPU和CPU上运行.
I want to use UMat
so my code can be run on both GPU and CPU using OpenCL (OpenCV 3.0.0 Beta).
,但是我找不到将图像文件读入UMat
或将Mat
转换为UMat
的方法.
but I can not find a way to read an image file into a UMat
or convert a Mat
to UMat
.
如何将图像读入UMat
?
推荐答案
以下是Mat
到UMat
转换的示例. Coudlnt可以找到有关此文档.因此,唯一的选择是阅读源代码.
Sample for Mat
to UMat
conversion is below. Coudlnt' find documentation for this. So only option was to read the source.
UMat img = imread( "lena.jpg", IMREAD_COLOR ).getUMat( ACCESS_READ );
ACCESS_READ, ACCESS_WRITE, ACCESS_RW, ACCESS_FAST
For undestanding UMat
usage, a complete sample for face detection is available here. Also note that documentation still refers to older flags as imread
second parameter. You might need to use newer flags as in your OpenCV header file.
这篇关于如何从opencv 3.0 Beta中的文件读取UMat?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!