have been using QT+OPENCV development projects, while in VS directly lazy use precompiled OPENCV for development, resulting in the use of OpenGL prompts "No OpenGL support":
On the Internet, the reason is obvious because the precompiled library does not support OpenGL, so it is necessary to use CMake to rebuild the project. My development environment is: Win 8.1+VS2013+OPENCV 2.4.9.
Starting with the OpenCV2.4.2 version, OPENCV supports OpenGL in a visual window, and interfaces can be found in Highgui modules. This allows OPENCV to easily render any 3D content. However, OPENCV does not enable OPENGL support by default, so you need to set the flag enable_opengl=
YES, (Default Enable_opengl = NO).
After this configuration is successful, a 3D object embedding OpenGL in the display output of OPENCV will be demonstrated. The whole process is as follows:
First, generate OPENCV solution
Install CMake and open, select the OpenCV installation path after the "Browse source ..." button on the first line "where is the source code". My Opencv2.0 installation path is e:/opencv/opencv/, where I need to select the source folder, click the "Browse Build ..." button on the second line and select the path to the resulting solution. Place it in the E:/opencv/opencvbuild folder and click on the Configure at the bottom left when the setting is complete.
Select the compiler version of Visual Studio 12 (Visual Studio 2013) In the pop-up dialog box and click Finish.
In the following compile parameter settings find With_opengl, tick, click Configure again.
Click Configure again, finish clicking Generate, and close cmake. All the configuration work before this compilation is complete.
Ii. compiling OpenCV in vs
Open the OpenCV.sln under E:\opencv\OpencvBuild with VS2013. Before compiling, confirm that the solution platform is debug| Win 32. Right-click on the project All_build, select Build, Finish find Cmaketargets->install, and select Build again.
Wait for the build to complete. If the first selected solution platform chooses debug 32-bit, the solution configuration is changed to release, and then the All_build and install are waiting to be generated again, and the compilation of OpenCV is complete.
(There may be a compile error.) According to the online introduction, OpenGL in VS is supported, do not need to install, but if the compiler does not pass the situation, you can try to all use <gl\gl.h> header files before the place to add #include <windows.h>)
iii. Configuring OpenCV in VS
Here with the VS Property table Configuration OpenCV project, each time only need to add a property sheet to complete configuration, more convenient than manual interface configuration. The property manager->-> Add an existing property by right-clicking the "Test" (project name).
After you modify the name of the project's property sheet and click "Add", you can see our new property sheet (named OpenCV) in the property manager.
Right click on the property sheet we just created and click "Properties", click "VC + + catalog" in the pop-up window, click on the "Include directory" on the right side, add: E:\opencv\OpencvBuild\install\include
Similarly, in the Library directory add: E:\opencv\OpencvBuild\lib\Debug
Click the linker-> enter-> additional dependencies and add the appropriate library files as needed:
In the same way, to "release | Win32 attribute, add the property sheet to the following configuration:
Add in include directory: E:\opencv\OpencvBuild\install\include
Add in library directory: E:\opencv\OpencvBuild\lib\Release
Add to Additional dependencies: the library file under E:\opencv\OpencvBuild\install\include\Release.
After the VS complete configuration, the last step is to add the system variable Path:e:\opencv\opencvbuild\install\x86\vc12\bin;
Four, simple demonstration
All of the configuration on OpenCV and OpenGL has been completed, and the next step is to experiment with the following OPENCV to create an OpenGL window, which opens up a real-world enhancement project in the property manager debug| Win32, select Add Existing property sheet, select the previously generated OpenCV property sheet (Put the property sheet file in the project folder beforehand):
After compiling the reality enhancement project and generating the executable file, the input image can get the 3D drawing of OpenGL rendering.