Does OpenGL render faster than OpenCV?

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

I considered OpenGL , since OpenGL directly uses the GPU, the command can be faster than from the CPU that OpenCV uses. Correct me if I am wrong.

+7
source share
3 answers

OpenCV already supports OpenGL for displaying images on its own. No need to write it yourself!

See documentation: http://docs.opencv.org/modules/highgui/doc/user_interface.html#imshow http://docs.opencv.org/modules/highgui/doc/user_interface.html#namedwindow

First create a window with namedWindow , where you can pass the WINDOW_OPENGL flag. Then you can even use OpenGL buffers or GPU matrices as input for imshow (data never leaves the GPU). But he will also use OpenGL to display regular matrix data.

Note:

To enable OpenGL support, configure OpenCV with CMake with WITH_OPENGL = ON. OpenGL is currently supported only with WIN32, GTK and Qt for Windows and Linux (MacOS and Android are not supported). GTK backend requires the gtkglext-1.0 library.

Please note that this is OpenCV 2.4.8, and this functionality has changed recently. I know that in previous versions there was support for OpenGL along with the Qt backend, but I do not remember when it was introduced.

About performance:. Very popular optimization in the CV community for displaying images using OpenGL, especially when displaying video sequences.

+8
source

OpenGL is optimized for rendering images, so it is most likely faster. In fact, it depends on whether the OpenCV implementation uses any GPU acceleration and if the bottleneck is on the rendering side.

Have you tried GPUs with OpenCV acceleration? - http://opencv.org/platforms/cuda.html

How large is the image you display? How long does it take to display an image using cv::imshow now?

+6
source

I know this is an old question, but I have exactly the same problem. And from my observations, I came to the conclusion that the root of the problem is the projector’s own delay , especially if you are using an older model.

How did i do this?

I displayed the same video sequence using cv::imshow() on the laptop monitor and on the projector. Then I waved my hand. It was obvious that the projector was introducing a significant delay.

To double-check, I opened the video from the webcam, waved my hand in front of him and saw the difference on the monitor and on the projector. The webcam does not process or perform opencv operations, therefore, as I understand it, the only thing that explains the delay is the projector itself.

0
source

All Articles