Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Fedora OpenCV with Qt: The program has unexpectedly finished
Forum Update on Monday, May 27th 2025

Fedora OpenCV with Qt: The program has unexpectedly finished

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tamercan
    wrote on last edited by
    #1

    I am trying to configure OpenCV with Qt Creator 2.7.0 (Qt 5.0.2) on Fedora 23 64bit. While executing my program, I get the following error:

    The program has unexpectedly finished. Starting /home/tamercan/build-myfirst2-Desktop_Qt_5_7_0_GCC_64bit-Debug/myfirst2... /home/tamercan/build-myfirst2-Desktop_Qt_5_7_0_GCC_64bit-Debug/myfirst2 crashed.
    This is my main.cpp

    #include <opencv2/core/base.hpp>
    #include <opencv2/core/mat.hpp>
    #include <opencv2/core/types.hpp>
    #include <opencv2/highgui/highgui_c.h>
    #include <opencv2/highgui.hpp>
    #include <opencv2/imgproc.hpp>
    #include <opencv2/objdetect/objdetect_c.h>
    #include <opencv2/objdetect.hpp>
    #include <opencv2/videoio.hpp>
    #include <iostream>
    #include <vector>

    using namespace cv;
    using namespace std;

    int main(int argc, char* argv[])
    {
    VideoCapture cap(0); // open the video camera no. 0

    namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"
    // Load Face cascade (.xml file)
        CascadeClassifier face_cascade;
        face_cascade.load( "xml/haarcascade_frontalface_alt.xml" );
    
    while (1)
    {
        Mat frame;
    
        bool bSuccess = cap.read(frame); // read a new frame from video
    
         if (!bSuccess) //if not success, break loop
        {
             cout << "Cannot read a frame from video stream" << endl;
             break;
        }
         // Detect faces
             std::vector<Rect> faces;
             face_cascade.detectMultiScale( frame, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30) );
    
             // Draw circles on the detected faces
             for( int i = 0; i < faces.size(); i++ )
             {
                 Point center( faces[i].x + faces[i].width*0.5, faces[i].y + faces[i].height*0.5 );
                 ellipse( frame, center, Size( faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, Scalar( 255, 0, 255 ), 4, 8, 0 );
    
    
                     imshow( "Detected Face", frame );
             }
    
    
    
                 //rectangle( frame, center, Size( faces[i].width*2, faces[i].height*2), Scalar( 255, 0, 255 ) );
    
    
    
    
        if (waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
       {
            cout << "esc key is pressed by user" << endl;
            break;
       }
    }
    return 0;
    

    }
    My .pro file is

    QT += core
    QT -= gui

    CONFIG += c++11

    TARGET = myfirst2
    CONFIG += console
    CONFIG -= app_bundle

    QMAKE_DEFAULT_INCDIRS="" && make

    TEMPLATE = app

    SOURCES += main.cpp

    INCLUDEPATH += /usr/include/
    LIBS += -L/usr/lib -lopencv_core -lopencv_highgui -lopencv_video -lopencv_videoio -lopencv_

    jsulmJ 1 Reply Last reply
    0
    • T Tamercan

      I am trying to configure OpenCV with Qt Creator 2.7.0 (Qt 5.0.2) on Fedora 23 64bit. While executing my program, I get the following error:

      The program has unexpectedly finished. Starting /home/tamercan/build-myfirst2-Desktop_Qt_5_7_0_GCC_64bit-Debug/myfirst2... /home/tamercan/build-myfirst2-Desktop_Qt_5_7_0_GCC_64bit-Debug/myfirst2 crashed.
      This is my main.cpp

      #include <opencv2/core/base.hpp>
      #include <opencv2/core/mat.hpp>
      #include <opencv2/core/types.hpp>
      #include <opencv2/highgui/highgui_c.h>
      #include <opencv2/highgui.hpp>
      #include <opencv2/imgproc.hpp>
      #include <opencv2/objdetect/objdetect_c.h>
      #include <opencv2/objdetect.hpp>
      #include <opencv2/videoio.hpp>
      #include <iostream>
      #include <vector>

      using namespace cv;
      using namespace std;

      int main(int argc, char* argv[])
      {
      VideoCapture cap(0); // open the video camera no. 0

      namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"
      // Load Face cascade (.xml file)
          CascadeClassifier face_cascade;
          face_cascade.load( "xml/haarcascade_frontalface_alt.xml" );
      
      while (1)
      {
          Mat frame;
      
          bool bSuccess = cap.read(frame); // read a new frame from video
      
           if (!bSuccess) //if not success, break loop
          {
               cout << "Cannot read a frame from video stream" << endl;
               break;
          }
           // Detect faces
               std::vector<Rect> faces;
               face_cascade.detectMultiScale( frame, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30) );
      
               // Draw circles on the detected faces
               for( int i = 0; i < faces.size(); i++ )
               {
                   Point center( faces[i].x + faces[i].width*0.5, faces[i].y + faces[i].height*0.5 );
                   ellipse( frame, center, Size( faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, Scalar( 255, 0, 255 ), 4, 8, 0 );
      
      
                       imshow( "Detected Face", frame );
               }
      
      
      
                   //rectangle( frame, center, Size( faces[i].width*2, faces[i].height*2), Scalar( 255, 0, 255 ) );
      
      
      
      
          if (waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
         {
              cout << "esc key is pressed by user" << endl;
              break;
         }
      }
      return 0;
      

      }
      My .pro file is

      QT += core
      QT -= gui

      CONFIG += c++11

      TARGET = myfirst2
      CONFIG += console
      CONFIG -= app_bundle

      QMAKE_DEFAULT_INCDIRS="" && make

      TEMPLATE = app

      SOURCES += main.cpp

      INCLUDEPATH += /usr/include/
      LIBS += -L/usr/lib -lopencv_core -lopencv_highgui -lopencv_video -lopencv_videoio -lopencv_

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Tamercan How is it related to Qt? Where does it crash? Did you try to debug to see where it crashes?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      T 1 Reply Last reply
      0
      • jsulmJ jsulm

        @Tamercan How is it related to Qt? Where does it crash? Did you try to debug to see where it crashes?

        T Offline
        T Offline
        Tamercan
        wrote on last edited by Tamercan
        #3

        @jsulm I didnt try to debug.When i add opencv library to my project it crashes.it works normally

        jsulmJ 1 Reply Last reply
        0
        • T Tamercan

          @jsulm I didnt try to debug.When i add opencv library to my project it crashes.it works normally

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Tamercan When you should debug to wee where it crashes. This is actually the first thing to do in such a situation.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved