Friday, December 23, 2011

Configuring Open CV in QT

First of all you will have to download open cv version 2.1 from here
Extract the zip file in your Drive(preferably C Drive)
Go inside the folder that is :Open CV2.1/bin folder and copy all those dll files to C:/Qt/2010.05/bin. The . Dll files are cv210.dll, cv210d.dll,cvaux210.dll, cxcore210.dll, highgui210.dll, ml210.dll,   opencv_ffmpeg210.dll.
Then Start New Project in QT and you will need to prove the path for the library files statically in your project. In the PRO section of new project provide path for header files and library files as well.
"INCLUDEPATH += C:\OpenCV2.1\include\opencv\
LIBS += C:\OpenCV2.1\lib\cv210.lib \
C:\OpenCV2.1\lib\cvaux210.lib \
C:\OpenCV2.1\lib\cxcore210.lib\
C:\OpenCV2.1\lib\cxts210.lib \
C:\OpenCV2.1\lib\highgui210.lib \
C:\OpenCV2.1\lib\ml210.lib 
"
INCLUDEPATH provides path for the header files of Open-CV and LIBS+ statically include the library files to the QT project.
Finally Start coding in Mainwindows.cpp by
#include <cv.h>
#include <highgui.h>
#include <cxcore.h>
Check whether Open CV is sucessfully configured or not by the following code.


    IplImage *img=cvLoadImage("Image_name.jpg");
    cvNamedWindow("rss",CV_WINDOW_AUTOSIZE);
    cvShowImage("rss",img);
    cvWaitKey(0);
    cvReleaseImage(&img);
    cvDestroyWindow("rss");


Include the image you want to display in the build folder of your project. For Example your folder name is Image_display the copy the image (Image_name.jpg) inside the folder Image_display-build-desktop. Or If you find the problem then simplly you can provide path in this section


IplImage *img=cvLoadImage("C:\Qt\Image_name.jpg");



No comments:

Post a Comment