OpenGL显示图像的速度是否比OpenCV快? [英] Does OpenGL display image faster than OpenCV?

查看:607
本文介绍了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!

请参阅文档: http://docs.opencv.org/modules/highgui/doc/user_interface.html#imshow http://docs.opencv.org/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快?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆