I want to use UMat
so my code can be run on both GPU and CPU using OpenCL (OpenCV 3.0.0 Beta).
but I can not find a way to read an image file into a UMat
or convert a Mat
to UMat
.
How can I read an image into a UMat
?
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 );
Different access flags as in source are
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.