- Download the required tools (all available on the respective official website)
- QT Integration Pack (Qt-opensource-windows-x86-mingw492-5.5.0.exe), which integrates MinGW, QT Creator, etc., does not require you to download MinGW and QT Creator separately.
- OpenCV3.0.0
- CMake3.3.0
- Install QT (need to register the account on the official website first, notice the selection of the components when selecting All)
- Install OPENCV set the decompression path on OK
- Install the CMake, the process is also very simple (note: 1, the installation path can not have Chinese and space 2, check to add all the environment variables)
- Generate Makefiles File
- Set the environment variable of the system, that is, add D:\work\qt\5.5\mingw492_32\bin to the PATH environment variable of the system, because the library under that directory will be used during CMake compilation.
- Click the CMake (Cmake-gui) icon on the desktop to perform the CMake. , in the where is the source code bar and where to build thebinaries columns are D:\work\opencvsrc\opencv\sources and D:\work\ respectively OpenCV is the directory where the compiled library file is stored, and you need to create it yourself. Then click the Configure button to open a new window, select MinGW makefiles under Specify the generator for this project, then select Specify native compilers, click Next button, open a new window, fill in the C column D:/work/qt/tools/mingw492_32/bin/gcc.exe, fill in the C + + column d:/work/qt/tools/ Mingw492_32/bin/g++.exe, Fortran do not fill, and then click the Finish button to start the configuration.
- There will be an error (specific description and solution see: http://bbs.csdn.net/topics/391028493), click Configure again, this time will not prompt any error, indicating that the configuration is successful.
- We also need to putqt Plus, find with , put it below the with_qt and With_opengl selected, and will With_ipp check out (otherwise compile error), again Configure. An error message similar to the following will appear:
CMake Error atc:/cmake/share/cmake-3.0/modules/findqt4.cmake:1316(message): Found unsuitable Qt version"" fromNOTFOUND, ThisCoderequires Qt4. XCall Stack (most recent call first): CMake/opencvfindlibsgui.cmake: the(find_package) CMakeLists.txt:466(include) to find the qt_qmake_executable, its value is filled with: D:/work/qt/5.5/mingw492_32/bin/Qmake.exe will Qt5concurrent_dir,qt5core_dir,qt5gui_dir,qt5test_dir,qt5widgets_dir,qt5opengl_dir, Their value is filled in as: D:/work/qt/5.5/mingw492_32/lib/cmake/Qt5concurrentd:/work/qt/5.5/mingw492_32/lib/cmake/qt5cored:/work/qt/5.5/mingw492_32/lib/cmake/Qt5guid:/work/qt/5.5/mingw492_32/lib/cmake/QT5TESTD:/work/qt/5.5/mingw492_32/lib/cmake/QT5WIDGETSD:/work/qt/5.5/mingw492_32/lib/cmake/Qt5opengl again configure, when the configuration is complete, there will be no error prompts. Although there will be a lot of warnings, but not to tube, press generate. When the generate is complete, close the CMake window.
The makefile file is then generated.
- Compiling OPENCV
- Configuring the Environment
- Create a new folder under the D:\WORK\OPENCV directory Necessary_file
- Copy the Lib and Bin folders in the D:\work\opencv directory into the Necessary_file
- Copy the Include folder in the D:\work\opencv\install directory into the Necessary_file
- Add the path D:\work\opencv\necessary_file\bin to the system environment variable path.
- Environmental testing
- Open QT Creator, create a new empty project, and add a CPP file, any name
- Add the following statement inside the project file. Pro file:
includepath+=D:\WORK\OPENCV\NECESSARY_FILE\INCLUDE\OPENCV D:\work\opencv\necessary_file\include\ Opencv2 + =-L D:\WORK\OPENCV\NECESSARY_FILE\LIB\LIBOPENCV_*.A
- Add the following code to the CPP file:
#include"cv.h"#include"cxcore.h"#include"highgui.h"intMainintargcChar*argv[]) { //declaring Iplimage Pointersiplimage*pImg; //Loading PicturesPimg=cvloadimage ("e:/1.jpg",1); //Create WindowCvnamedwindow ("Image",1); //Display ImageCvshowimage ("Image", PIMG); //Wait for the buttonCvwaitkey (0); //destroying WindowsCvdestroywindow ("Image"); //Release ImageCvreleaseimage (&pImg); return 0;}
- Experimental results
Reference:
1, http://blog.csdn.net/zhaocj/article/details/38944037
2, http://www.mamicode.com/info-detail-500574.html
3, http://blog.csdn.net/qiurisuixiang/article/details/8665278
2015-07-18
QT development environment with OPENCV configuration under Win7