Results 1 to 6 of 6

Thread: Opencv and qt linux

  1. #1
    Join Date
    Jul 2012
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Default Opencv and qt linux

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Opencv and qt linux

    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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jul 2012
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Opencv and qt linux

    Quote Originally Posted by high_flyer View Post
    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;
    }

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Opencv and qt linux

    is /usr/local/lib/l in your LD_LIBRARY_PATH?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Jul 2012
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Opencv and qt linux

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

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Opencv and qt linux

    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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. OpenCV + QT4
    By thereisnoknife in forum Qt Programming
    Replies: 6
    Last Post: 8th March 2013, 05:19
  2. Replies: 5
    Last Post: 25th April 2012, 11:34
  3. OpenCV on mac
    By sandeep_hyd123 in forum Newbie
    Replies: 1
    Last Post: 17th June 2011, 04:53
  4. opencv-qt-mac
    By ireneluis in forum Qt Programming
    Replies: 0
    Last Post: 16th March 2010, 15:24
  5. Qt and OpenCV
    By malorie in forum Newbie
    Replies: 2
    Last Post: 7th March 2010, 14:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.