是否可以将OpenCV GpuMat绑定为OpenGL纹理?

编程入门 行业动态 更新时间:2024-10-10 11:29:36
本文介绍了是否可以将OpenCV GpuMat绑定为OpenGL纹理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我找不到任何参考资料,除了:

I haven't been able to find any reference except for:

answers.opencv/question/9512/how-to-bind-gpumat-to-texture/

它讨论了CUDA方法。

which discusses a CUDA approach.

理想情况下,我想更新一个OpenGL纹理, cv :: gpu :: GpuMat 没有复制回CPU,并且没有直接使用CUDA(虽然我认为这可能是必要的,直到添加此功能)。

Ideally I'd like to update an OpenGL texture with the contents of a cv::gpu::GpuMat without copying back to CPU, and without directly using CUDA (although i presume this may be necessary until this feature is added).

推荐答案

OpenCV支持OpenGL。请参见 opencv2 / core / opengl_interop.hpp 头文件。您可以将GpuMat的内容复制到纹理:

OpenCV has OpenGL support. See opencv2/core/opengl_interop.hpp header file. You can copy the content of GpuMat to Texture:

cv::gpu::GpuMat d_mat(768, 1024, CV_8UC3); cv::ogl::Texture2D tex; tex.copyFrom(d_mat); tex.bind(); // draw something

您也可以使用 cv :: ogl :: Buffer 类。它是OpenGL缓冲存储器的包装器。这个内存可以映射到没有内存复制的CUDA内存:

You can also use cv::ogl::Buffer class. It is a wrapper for OpenGL buffer memory. This memory can be mapped to CUDA memory without memory copy:

cv::ogl::Buffer ogl_buf(1, 1000, CV_32FC3); cv::gpu::GpuMat d_mat = ogl_buf.mapDevice(); // fill d_mat with CUDA ogl_buf.unmapDevice(); // use ogl_buf in OpenGL ogl_buf.bind(cv::ogl::Buffer::ARRAY_BUFFER); glDrawArray(...);

更多推荐

是否可以将OpenCV GpuMat绑定为OpenGL纹理?

本文发布于:2023-11-12 10:07:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581184.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:纹理   OpenCV   GpuMat   OpenGL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!