Thursday 2 June 2011

OpenCV and Qt installation and integration in Windows

Hello All,
After trying a lot to install and integrate OpenCv and Qt in windows and succeeded in it I have reached at the following step by step method.


1) Download Qt libraries 4.7.3 for Windows (minGW 4.4, 319 MB) and Qt Creator 2.2 for Windows (52 MB) by clicking on these links.


2) Download zip file of MinGW with GCC 4.4.0 from this link.


3) Download OpenCV-2.0.0a-win32.exe.


4) Unzip MinGW-gcc440_1.zip in C: drive and name it as MinGW the address should be like this C:\MinGW and inside this folder there should be mingw folders _patches,bin,doc etc.


5) Now install Qt libraries 4.7.3 for Windows(minGW 4.4,319 MB) it will look for MinGW installed in your computer give the location as C:\MinGW. Wait for completing the installation.


6) Install Qt Creator 2.2 for Windows install all the required files wait for completion of installation.


7) Now in your C:\Qt directory there will be two folders 4.7.3 and qtcreator-2.2.0.


8) Install OpenCV-2.0.0a-win32.exe choose the option add OpenCV to Path for all users. Wait for the installation.


9) Your OpenCV should be installed in C: drive as C:\OpenCV2.0.


10) Now change Environment Variables as follows.
Add New Variables as by clicking on New in User Variables
Add a New Variable Path and set variable value as
C:\Qt\4.7.3\bin;C:\Qt\qtcreator-2.2.0\bin;C:\Qt\qtcreator-2.2.0\mingw\bin;
Add a New Variable QTDIR and and set variable value as C:\Qt\4.7.3
Add a New Variable QMAKESPEC and set variable value as win32-g++.


11) Restart the computer for environment variables to get registered.


12) Now open qt choose new project go for gui mobile application.


13) Add following lines in your .pro file
INCLUDEPATH += C:/OpenCV2.0/include/opencv/ ;
LIBS += -lm -LC:/OpenCV2.0/lib -LC:/OpenCV2.0/bin -lcv200 -lhighgui200 -lcvaux200 -lcxcore200
14) Now your opencv is linked with qt.


15) While building don't forget to click on projects on left and uncheck option Build Shadow build.


16) Have fun with opencv tell me if this doesn't work and you have any problem please mail me at dhawalkapil@gmail.com or comment here.



2 comments: