我找不到任何参考资料,除了:
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纹理?
发布评论