OpenGL support

OpenCV includes OpenGL support. OpenGL is a graphical library integrated in almost all graphical cards as a standard. OpenGL allows us to draw 2D up to complex 3D scenes. OpenCV includes OpenGL support due to the importance of representing 3D spaces in a number of tasks. To allow window support in OpenGL, we have to set up the WINDOW_OPENGL flag when we create the window using the namedWindow call.

The following code creates a window with OpenGL support and draws a rotate plane where we are going to show the web camera frames:

Mat frame; GLfloat angle= 0.0; GLuint texture; VideoCapture camera; int loadTexture() { if (frame.data==NULL) return -1; glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); ...

Get Building Computer Vision Projects with OpenCV 4 and C++ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.