Results 1 to 3 of 3

Thread: Problem with openCV compilation in Qt Creator

  1. #1
    Join Date
    Mar 2009
    Location
    india->gujarat->bhavnagar
    Posts
    36
    Thanks
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Question Problem with openCV compilation in Qt Creator

    here is the code below:
    Qt Code:
    1. const char *filename="C://OpenCV2.2//data//haarcascades//haarcascade_frontalface_alt.xml";
    2. cascade = ( CvHaarClassifierCascade* )cvLoad(filename,0,0,0);
    3. if( !cascade )
    4. {
    5. fprintf( stderr, "ERROR: Could not load classifier cascade\n" );
    6. return -1;
    7. }
    8. storage=cvCreateMemStorage(0);
    9. capture=cvCaptureFromCAM(0);
    10. // assert( cascade && storage && capture );
    11. IplImage* frame= cvQueryFrame(capture);
    12. m_i=QImage(QSize(frame->width,frame->height),QImage::Format_RGB888);
    13. ui->frame->setMinimumSize(m_i.width(),m_i.height());
    14. ui->frame->setMaximumSize(ui->frame->minimumSize());
    15.  
    16. m_opencvimg=cvCreateImageHeader(cvSize(m_i.width(),m_i.height()),8,3);
    17. m_opencvimg->imageData=(char*)m_i.bits();
    18.  
    19. if(frame->origin== IPL_ORIGIN_TL)
    20. cvCopy(frame,m_opencvimg,0);
    21. else
    22. cvFlip(frame,m_opencvimg,0);
    23.  
    24. cvCvtColor(m_opencvimg,m_opencvimg,CV_BGR2RGB);
    25.  
    26. m_timer=new QTimer(this);
    27. connect(m_timer,SIGNAL(timeout()),this,SLOT(queryFrame()));
    28. m_timer->start(50);
    To copy to clipboard, switch view to plain text mode 


    Error's i was getting while compiling this code:

    C:/Users/mind_freak/facedetect-build-desktop/../facedetect/widget.cpp:15: error: returning a value from a constructor

    i dont know i have given the correct path to the xml file but unable to load.

    help me out of this....i am stuck with this....

    thanks..

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Problem with openCV compilation in Qt Creator

    Qt Code:
    1. if( !cascade )
    2. {
    3. fprintf( stderr, "ERROR: Could not load classifier cascade\n" );
    4. return -1;
    5. }
    To copy to clipboard, switch view to plain text mode 
    Error message explains everything - you can't have a value return statement in constructor, this makes no sense. Remove the return -1 line.
    Despite that, your constructor is doing a lot of work, this is not good, better create and call an initialization method, then in case of error you can return "false" or something.

  3. The following user says thank you to stampede for this useful post:

    mind_freak (22nd February 2011)

  4. #3
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with openCV compilation in Qt Creator

    C:/Users/mind_freak/facedetect-build-desktop/../facedetect/widget.cpp:15: error: returning a value from a constructor
    The problem is the piece of code
    Qt Code:
    1. cascade = ( CvHaarClassifierCascade* )cvLoad(filename,0,0,0);
    2. if( !cascade )
    3. {
    4. fprintf( stderr, "ERROR: Could not load classifier cascade\n" );
    5. return -1; // <---- This is the line
    6. }
    To copy to clipboard, switch view to plain text mode 

    If the code is inside the constructor you cannot return a value
    A camel can go 14 days without drink,
    I can't!!!

  5. The following user says thank you to mcosta for this useful post:

    mind_freak (22nd February 2011)

Similar Threads

  1. OpenCV integration with Qt creator
    By mind_freak in forum Qt Programming
    Replies: 11
    Last Post: 8th January 2013, 22:50
  2. Qt Creator Compilation error when compiling Qt Creator 2.0 for x64
    By agerlach in forum Qt Tools
    Replies: 2
    Last Post: 9th July 2010, 22:56
  3. Using OpenCV with QT creator
    By gmiller39 in forum Newbie
    Replies: 3
    Last Post: 7th July 2010, 15:32
  4. Replies: 4
    Last Post: 19th March 2010, 18:16
  5. I've got a qt&opencv problem.
    By eralvc in forum Installation and Deployment
    Replies: 2
    Last Post: 23rd October 2008, 09:58

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.