What is the difference between UMat and Mat in OpenCV?
Asked Answered
M

1

38

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.

Macnamara answered 9/11, 2015 at 4:42 Comment(0)
C
56

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

Counterpoise answered 9/11, 2015 at 16:48 Comment(2)
Link is broken. I found this instead but it has a very brief explanation: docs.opencv.org/3.0-rc1/db/dfa/tutorial_transition_guide.htmlGodart
@Godart Wow, that is brief ;) I tried looking before in the Wayback Machine, but unfortunately the page wasn't archived. Hopefully the portion I quoted is enough to get people going. I'll add a note that the link is broken. Thanks!Counterpoise

© 2022 - 2024 — McMap. All rights reserved.