QT development environment with OPENCV configuration under Win7

Source: Internet
Author: User

  1. 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
  2. Install QT (need to register the account on the official website first, notice the selection of the components when selecting All)
  3. Install OPENCV set the decompression path on OK
  4. 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)
  5. 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.
  6. Compiling OPENCV
    • Find Opencvcompileroptions.cmake under the D:\work\opencvsrc\opencv\sources\cmake
      open it and find Add_extra_compiler_option (-werror=non-virtual-dtor) to comment it out and turn it into: #add_extra_compiler_ Option (-werror=non-virtual-dtor)
    • Open the system's command terminal, enter the D:\WORK\OPENCV directory, execute the mingw32-make command, which takes a period of time (about 40 minutes). After the command executes, execute the mingw32-make install command. This allows the OpenCV library file for Qt to be generated.
  7. 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.
  8. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.