PDA

View Full Version : Opencv and qt linux



hezbon
8th August 2012, 12:37
I want to start handling image processing using opencv and qt so i have downloaded the opencv 2.2.0 and extracted it.
i have included the file file paths to my .pro.
Myy question is can i use it just like qextserial or opencv sources have to be compiled?
if so why am getting error in cvReleaseCapture as undefined function.

high_flyer
8th August 2012, 16:12
opencv is a lib.
you have to build it, and in your Qt project add the include paths to it, and library path with opencv lib is, and link to it.

hezbon
9th August 2012, 07:51
opencv is a lib.
you have to build it, and in your Qt project add the include paths to it, and library path with opencv lib is, and link to it.
I have built it using Cmake and I used the Cmake-gui and then run the make and did the make install so i have the libraries built and when i try running my first program i get this error :-1: error: collect2: error: ld returned 1 exit status.
and i have given the path to my lis

#-------------------------------------------------
#
# Project created by QtCreator 2012-08-08T05:04:23
#
#-------------------------------------------------

QT += core gui

TARGET = opvc
TEMPLATE = app


INCLUDEPATH +=/usr/local/include/opencv
INCLUDEPATH +=/usr/local/include/opencv2/core
INCLUDEPATH +=/usr/local/include/opencv2/imgproc
INCLUDEPATH +=/usr/local/include/opencv2/ml
INCLUDEPATH +=/usr/local/include/opencv2/highgui
INCLUDEPATH +=/usr/bin/ld
INCLUDEPATH +=/home/oloo/Downloads/OpenCV2.4/lib
LIBS +=-L/usr/bin

LIBS += -L/usr/local/lib/libopencv_contrib.so
LIBS += -LD: /usr/local/lib
LIBS += -L/home/oloo/Downloads/OpenCV2.4/lib
SOURCES += main.cpp\
mainwindow.cpp

HEADERS += mainwindow.h

FORMS += mainwindow.ui

and this my code

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <cv.h>
#include <highgui.h>
#include <core_c.h>
#include <types_c.h>
#include <cxcore.h>
#include <ml.h>
#include <cvaux.h>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{

IplImage *img=0;
cap=cvCaptureFromCAM(0);
//cap.cvCaptureFromCAM(0);
ui->setupUi(this);

//IplImage *img=cvLoadImage("img.jpg");
//cvNamedWindow("Example1", CV_WINDOW_AUTOSIZE );
}

MainWindow::~MainWindow()
{
delete ui;
}

high_flyer
9th August 2012, 09:09
is /usr/local/lib/l in your LD_LIBRARY_PATH?

hezbon
9th August 2012, 11:35
I have added libraries and now i dont get the error but now my code cannot open my webcam

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <cv.h>
#include <highgui.h>
#include <core_c.h>
#include <types_c.h>
#include <cxcore.h>
#include <ml.h>
#include <cvaux.h>
#include <QtGui>
#include <QtDebug>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{

//IplImage *img=0;

//cap.cvCaptureFromCAM(0);
ui->setupUi(this);

IplImage *img=cvLoadImage("img.jpg");
// do{
cap=cvCaptureFromCAM(0);
// }while(!cap);

if(cap==NULL){

qDebug()<<"cannot connect"<<cvErrorStr(cvGetErrStatus());
}

cvNamedWindow("Example1", CV_WINDOW_AUTOSIZE );
}

MainWindow::~MainWindow()
{
delete ui;
}

high_flyer
9th August 2012, 14:39
I have added libraries and now i dont get the error but now my code cannot open my webcam
This is not a Qt issue - ask it on an openCV forum.