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();
}

Iklan

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s