Opencv in Qt



  • Hi friends,
    I have been to call the opencv function from Qt(Qml),but it doesn't working well...It always showing error(Undefined reference to cvLoadImage,cvNamedWindow,etc.)....But when i run that opencv code in console application means ,it is running well..But when i using it with Qt,it is displaying this error..Could anyone please sought out the problem..
    thanks in advance..



  • hello friends,
    No idea about this?????????


  • Lifetime Qt Champion

    Hi,

    Please allow at least 24 to 72 hours before bumping your own thread. Not all people on this forum live the same timezone as you or even might have an answer.

    If you are having undefined reference it means that you are not linking the library to your application when compiling.



  • Hi SGaist,
    Sorry for the delay sir. I've used pro file as
    @
    LIBS += -L/usr/local/lib
    -lopencv_core
    -lopencv_imgproc
    @

    This is what i'm trying. From Qml, i'm calling a function.
    @
    QString mainwindow::get_opencv(QString &get_word)
    {
    IplImage *img2 = cvLoadImage("images_.png");
    CvPoint pt1 = cvPoint(130,90);
    int thickness = 2;
    char text[20];
    char m_framecnt[100]="kannamohan";
    CvScalar blue = CV_RGB(0,0,250);
    double hscale = 1.0;
    double vscale = 1.0;
    double shear = 0;
    //int thickness2 = 1;
    int line_type = 4;
    snprintf(text,sizeof(text), "%s",m_framecnt);
    cvNamedWindow("Window",CV_WINDOW_AUTOSIZE);
    CvFont font1 ;//= fontQt("Times");
    cvInitFont(&font1,CV_FONT_HERSHEY_DUPLEX,hscale,vscale,shear,thickness,line_type);
    cvPutText(img2,text,pt1,&font1,blue);
    cvShowImage("Window",img2);
    cvWaitKey(0);
    cvReleaseImage(&img2);
    cvDestroyWindow("Window");
    }
    @
    It is telling undefined reference to cvLoadImage,CvPoint,etc..
    please help me sir..


  • Lifetime Qt Champion

    I would say you are not linking to opencv_highgui



  • Hi,

    have you set all your includepaths properly and added all necessary variables to your system environment variables ?

    a quick guide to use qtcreator with opencv is here:

    http://www.barbato.us/2010/09/20/using-opencv-within-qtcreator-in-windows/

    I'm sure you can search the net for more guides.

    In your case you might be missing:

    #include <opencv2/core/core.hpp>
    #include <opencv2/highgui/highgui.hpp>

    as well, or equivalent.

    As in the tutorial you might also add:

    INCLUDEPATH += C:\OpenCVx.x\include
    LIBS += -LC:\OpenCVx.x\lib
    -lopencv_corexyz
    -lopencv_highguixyz\

    To your .pro.
    While placeholders x y and z represent versionsing.

    How to set this up is also explained in OpenCV 2 Computer Vision Application Programming Cookbook by Robert Laganière.



  • hi SGaist and Refuzee,
    You both are right.I'm working in linux. I have missed that -lopencv_highgui \ in profile
    Thank you a lot... Still it is not over,i need to check that application.Tomorrow i will check it and i will tell the working process


  • Lifetime Qt Champion

    Since you're on linux you can take advantage of pkg-config


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.