Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between UMat and Mat in OpenCV?

Tags:

opencv

mat

I have been through the documentation and didn't get a clear detailed description about UMat; however I think it has something to relate with GPU and CPU. Please help me out. Thank you.

like image 248
Aniket Sharma Avatar asked Nov 09 '15 04:11

Aniket Sharma


1 Answers

Perhaps section 3 of this document will help: [link now broken] https://software.intel.com/sites/default/files/managed/2f/19/inde_opencv_3.0_arch_guide.pdf

Specifically, section 3.1:

A unified abstraction cv::UMat that enables the same APIs to be implemented using CPU or OpenCL code, without a requirement to call OpenCL accelerated version explicitly. These functions use an OpenCL-enabled GPU if exists in the system, and automatically switch to CPU operation otherwise.

and section 3.3:

Generally, the cv::UMat is the C++ class, which is very similar to cv::Mat. But the actual UMat data can be located in a regular system memory, dedicated video memory, or shared memory.

Link to usage suggested in the comments by @BourbonCreams:
https://docs.opencv.org/3.0-rc1/db/dfa/tutorial_transition_guide.html#tutorial_transition_hints_opencl

like image 61
beaker Avatar answered Nov 13 '22 02:11

beaker