Monday, 3 September 2012

OPENCV 2.1 QT CREATOR INTEGRATION

Assuming u downloaded this setup 
and installed it successfully 
"OpenCV-2.1.0-win32-vs2008.exe" 

Let us assume for now that the installation directory is "C:\OpenCV2.1" 

To make ur current qt project or a new project "opencv" compatible :| 
here are the modifications or rather additions which are to be made to ur 
.pro file 

# INCLUDING HEADER PATHS AND LIBRARIES AND THEIR PATHS###

INCLUDEPATH
 +="C:\OpenCV2.1\include/opencv"


LIBS += -L"C:\OpenCV2.1/lib"


LIBS += -lcv210 -lcxcore210 -lhighgui210 -lcvaux210 -lcxts210 -lml210 -lopencv_ffmpeg210


# END OF HEADER INCLUDES AND LIB INCLUDES ### 


so, a sample complete .pro file would look like this.... 

#-------------------------------------------------
#
# Project created by QtCreator 2010-09-21T15:20:29
#
#-------------------------------------------------
QT       += core


QT       -= gui


INCLUDEPATH   +="C:\OpenCV2.1\include/opencv"




LIBS += -L"C:\OpenCV2.1/lib"
LIBS += -lcv210 -lcxcore210 -lhighgui210 -lcvaux210 -lcxts210 -lml210 -lopencv_ffmpeg210


TARGET = opencvTest


CONFIG   += console


CONFIG   -= app_bundle


TEMPLATE = app


SOURCES += main.cpp




heres a sample program as well to help u with it







##dont forget to include QDir,QDebug as well to ur existing app

## along with its existing defaults i.e. QCoreApplication if its  a console app

## etc....etc....

#include "cv.h"

#include "cxcore.h"

#include "highgui.h"

#include "stdio.h"



int main(int argc, char *argv[])

{     QCoreApplication a(argc, argv);

   IplImage* test=cvLoadImage("test.jpg",1);

    cvNamedWindow("test",CV_WINDOW_AUTOSIZE);      cvShowImage("test",test);

    float i=32.45;

   char* temp="amar";

   qDebug() <<   QDir::currentPath() << i <<temp;

    return a.exec();

}





a sample project will be added soon 

No comments:

Post a Comment