Does OpenGL display image faster than OpenCV?

OpenGL is optimised for rendering images, so it's likely faster. It really depends if the OpenCV implementation uses any GPU acceleration AND if the bottleneck is on rendering side of things.

Have you tried GPU accelerated OpenCV? - http://opencv.org/platforms/cuda.html

How big is the image you are displaying? How long does it take to display the image using cv::imshow now?


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

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

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.

Please note:

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.

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.

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

Tags:

C++

Opengl

Opencv