In the earlier post we configured codeblocks with opencv. However, If you are looking for more advanced GUI application then you should go for QT library. QT provides excellent easy to use front end framework with their super fast visual editor qt creator.
In this post we will configure qt creator and opencv.
- OpenCV: Download OpenCV pre-built for windows. As said earlier we are not going to use those binaries instead we will make our own. (those pre-built binary sucks most of the time). extract it to C:\ You will find two folder there: ‘build’ and ‘sources’.
- QT Library (5.3.1): Don’t know why official website doesn’t provide 64 bit MinGW version of QT. However, you can find 64 bit mingw here. Install it in C:\Qt
- Qt Creator (3.2.0): Download and install 64 bit form here and install it in C:\Qt
- MinGW 64: MinGw 64bit is already installed with Qt library. You can see it in C:\Qt\qt-5.3.1-x64-mingw482r4-sjlj\mingw64
- Path Editor: Download a handy tiny path editor tool from here.
- CMake: Download Cmake from here. install it in C:\.
- Open path editor and set the following two folder into system variable. C:\Qt\qt-5.3.1-x64-mingw482r4-sjlj\mingw64\bin”
- Open cmake, set source path to C:\opencv\sources and binary path to C:\opencv-mingw. [make a folder in C:\ called “opencv-mingw”]
- Hit configure button. A pop up window will open and the from drop-down menu select ‘MinGW Makefiles’ and press next. There you have to select c and c++ compilers which would be found in bin folder of mingw. If you are trying opencv 3.0 alpha then just deselect IPP option. And finally press generate button.
- Now open command prompt go to C:\opencv-mingw. Type: mingw32–make
- now type: mingw32–make install
And you are Done ! You have successfully built copencv! Now it is time to configure qt creator with opencv library.
Run qt creator and create a new qt widget application, give it a name “opencv”.
- Add these lines in opencv.pro file: INCLUDEPATH += C:\opencv-mingw\install\include
LIBS += -L”C:/opencv-mingw/install/x64/mingw/bin”
LIBS += -lopencv_core249 -lopencv_highgui249 -lopencv_imgproc249
- add the following lines in main() function:
cv::Mat image= cv::imread(“pic.jpg”);
- Dont forget to put a picture called pic.jpg in project folder !
Now run the program 🙂