OpenGL显示图像的速度是否比OpenCV快?

编程入门 行业动态 更新时间:2024-10-28 02:32:53
本文介绍了OpenGL显示图像的速度是否比OpenCV快?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用OpenCV在投影仪上显示图像.但是 cv :: imshow 似乎不够快,或者从我的CPU到GPU再到投影仪的数据传输速度都很慢,所以我想知道是否有一种比显示更快的方法? OpenCV?

I am using OpenCV to show image on the projector. But it seems the cv::imshow is not fast enough or maybe the data transfer is slow from my CPU to GPU then to projector, so I wonder if there is a faster way to display than OpenCV?

我考虑了 OpenGL ,因为OpenGL直接使用GPU,所以该命令可能比来自OpenCV使用的CPU的命令要快.如果我错了,请纠正我.

I considered OpenGL, since OpenGL directly uses GPU, the command may be faster than from CPU which is used by OpenCV. Correct me if I am wrong.

推荐答案

OpenCV已经支持OpenGL本身用于图像输出.不需要自己写这个!

OpenCV already supports OpenGL for image output by itself. No need to write this yourself!

请参阅文档: docs.opencv/modules/highgui/doc/user_interface.html#imshow docs.opencv/modules/highgui/doc/user_interface.html#namedwindow

首先使用namedWindow创建窗口,您可以在其中传递WINDOW_OPENGL标志. 然后,您甚至可以使用OpenGL缓冲区或GPU矩阵作为imshow的输入(数据永远不会离开GPU).但它还将使用OpenGL显示常规矩阵数据.

Create the window first with namedWindow, where you can pass the WINDOW_OPENGL flag. Then you can even use OpenGL buffers or GPU matrices as input to imshow (the data never leaves the GPU). But it will also use OpenGL to show regular matrix data.

请注意:

要启用OpenGL支持,请使用CMake使用以下命令配置OpenCV: WITH_OPENGL = ON.当前只有WIN32,GTK支持OpenGL 和Windows和Linux上的Qt后端(MacOS和Android并非 支持的).对于GTK后端,需要gtkglext-1.0库.

To enable OpenGL support, configure OpenCV using CMake with WITH_OPENGL=ON . Currently OpenGL is supported only with WIN32, GTK and Qt backends on Windows and Linux (MacOS and Android are not supported). For GTK backend gtkglext-1.0 library is required.

请注意,这是OpenCV 2.4.8,并且此功能最近已更改.我知道Qt后端结合了早期版本中的OpenGL支持,但是我不记得是什么时候引入的.

Note that this is OpenCV 2.4.8 and this functionality has changed quite recently. I know there was OpenGL support in earlier versions in conjunction with the Qt backend, but I don't remember when it was introduced.

关于性能:在CV社区中,使用OpenGL输出图像是一种非常流行的优化方法,尤其是在输出视频序列时.

About the performance: It is a quite popular optimization in the CV community to output images using OpenGL, especially when outputting video sequences.

更多推荐

OpenGL显示图像的速度是否比OpenCV快?

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

发布评论

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

>www.elefans.com

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