OpenCV 透明 API 缺少 UMat

OpenCV Transparent API UMat is missing

我尝试在桌面 java 应用程序中使用 OpenCV Transparent API UMat class 进行硬件加速,但找不到 UMat class 实施。我正在使用 OpenCV version 4.1,其中 T-API java 绑定据说从 version 3.0 开始可用,如 here:

T-API (transparent API) has been introduced, this is transparent GPU acceleration layer using OpenCL. It does not add any compile-time or runtime dependency of OpenCL. When OpenCL is available, it’s detected and used, but it can be disabled at compile time or at runtime. It covers ~100 OpenCV functions. This work has been done by contract and with generous support from AMD and Intel companies.

让我们分解这个问题。

Is T-API deprecated? If yes, what replaces it?

不,T-API 并未有效弃用。可以看到here, that the T-API is still alive under the OpenCV 4.1.2 version tag. Your main issue is that there is no actual Java wrapper for the T-API, as we can see at this answer and we can't see a UMat implementation under the OpenCV Java Docs.

And by the way what is the OpenCV Graph API G-API? Is it a replacement for the T-API?

再次查看 the docs,我们读到:

OpenCV 3.0 introduced Transparent API (or T-API) which allowed to offload OpenCV function calls transparently to OpenCL devices and save on Host/Device data transfers with cv::UMat – and it was a great step forward. However, T-API is a dynamic API – user code still remains unconstrained and OpenCL kernels are enqueued in arbitrary order, thus eliminating further pipeline-level optimization potential. G-API brings implicit graph model to OpenCV 4.0. Graph model captures all operations and its data dependencies in a pipeline and so provides G-API framework with extra information to do pipeline-level optimizations.

据记载,G-API 似乎不是 "replacement",而是更像是 OpenCV 硬件加速计划的改进。 G-API 为新版本的 OpenCV 带来了面向 pipe-line/graph 的范例,而不是仅仅对无组织的内核进行一些优化操作。