Using OpenCV in Qt for Beginner


in *.pro

=================================================================================
QT       -= gui

TARGET = test003
CONFIG   += console
CONFIG   -= app_bundle

TEMPLATE = app

INCLUDEPATH += ../OpenCV/opencvlibrary/opencv/include/opencv

SOURCES += main.cpp

LIBS += -L$/usr/local/lib\
-lcv \
-lhighgui

=================================================================================

in main.cpp

=================================================================================

#include <QtCore/QCoreApplication>
#include “cv.h”
#include “highgui.h”

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
CvCapture* capture = cvCreateFileCapture(argv[1]);
IplImage* frame = 0;
cvNamedWindow(“Display”, CV_WINDOW_AUTOSIZE);
while (1)
{
frame = cvQueryFrame(capture);
if (!frame)
break;
cvShowImage(“Display”, frame);
char c = cvWaitKey(33);
if ( c == 27 )
break;
}
cvReleaseCapture(&capture);
cvDestroyWindow(“Display”);

return a.exec();
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: