Ask Your Question

OpenCL/gpu and umat

asked 2016-06-28 04:32:03 -0500

atv gravatar image

updated 2016-06-28 04:40:40 -0500

I've been reading a bit about OpenCL support in opencv 3, and that all i need is to use a UMat instead of a regular Mat.

Is that all that i need, assuming my system supports opencl? Would be there be a big speed increase? I'd be very interested in that.

Anyone tried this on a recent mac system, do they all support OpenCL ?

Also: if i use Umat but there is no OpenCL/GPU support, will it fall back to regular CPU ?

Thanks, Alef

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2016-06-28 05:25:29 -0500

berak gravatar image

you can toggle ocl hardware / cpu usage with a flag:

#include "opencv2/core/ocl.hpp"
using namespace cv;

bool useOCL = true; 
cout << "useOCL "  <<  cv::ocl::useOpenCL() << endl;

then, there's certain things, you cannot do with a UMat:

  • pixel access (at())
  • overloaded maths operators (C = A * B must be gemm(A,B,1,noArray(),0,C) )
  • printing to stdout or such
  • save / read to FileStorage or imread()/imwrite()
  • gui / imshow()

for all of these it will need copying to a "normal"(CPU) Mat, before you can do that

unfortunately, there are no nice tutorials(yet), but have a look at the samples

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-06-28 04:32:03 -0500

Seen: 629 times

Last updated: Jun 28 '16