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. Problem qith OpenCV and Qt creator

Problem qith OpenCV and Qt creator

Scheduled Pinned Locked Moved General and Desktop
19 Posts 4 Posters 10.2k Views 2 Watching
  • 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.
  • A Offline
    A Offline
    AlbertoAlegria
    wrote on last edited by
    #1

    I recently install Qt creator and link with OpenCV, thats my problem. I cant know if there are correctly linked. Also, when i compile a project, an error show a popup called SIAGBRT:
    @
    The inferior stopped because it received a signal from the Operating System.

    Signal name :
    SIGABRT
    Signal meaning :
    Aborted

    @
    But if i execute, Qt show me:
    @
    The program has unexpectedly finished.
    @
    BTW, i add my code in the main.cpp and the .pro file. Hope you help me :c

    Main.cpp:
    @#include "mainwindow.h"
    #include <QApplication>

    #include "opencv2/objdetect/objdetect.hpp"
    #include "opencv2/highgui/highgui.hpp"
    #include "opencv2/imgproc/imgproc.hpp"

    #include <iostream>

    using namespace std;
    using namespace cv;

    void rotate(Mat& src, double angle, Mat& dst)
    {
    char* wName = "hola";
    int len = max(src.cols, src.rows);
    Point2f pt(len/2., len/2.);
    Mat r = getRotationMatrix2D(pt, angle, 1.0);

    warpAffine(src, dst, r, Size(len, len));
    
    namedWindow(wName, CV_WINDOW_AUTOSIZE);
    imshow(wName, dst);
    
    cvWaitKey(0);
    

    }

    int main(int argc, char *argv[])
    {
    Mat imgSrc;
    Mat imgDst;

    char* imageName = "ball.jpg";
    
    imgSrc = imread(imageName, 1);
    
    rotate(imgSrc, 30, imgDst);
    return 0;
    

    }

    /*int main(int argc, char *argv[])
    {
    QApplication a(argc, argv); i coment this just to see if works :c
    MainWindow w;
    w.show();

    return a.exec&#40;&#41;;
    

    }
    */
    @

    .pro File:
    @
    #-------------------------------------------------

    Project created by QtCreator 2014-03-27T13:08:30

    #-------------------------------------------------

    QT += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = rotation
    TEMPLATE = app

    SOURCES += main.cpp
    mainwindow.cpp

    INCLUDEPATH += /usr/local/include/opencv
    INCLUDEPATH += /usr/local/include/opencv2

    LIBS += -L/usr/local/lib
    -lopencv_core
    -lopencv_imgproc
    -lopencv_highgui
    -lopencv_ml
    -lopencv_video
    -lopencv_features2d
    -lopencv_calib3d
    -lopencv_objdetect
    -lopencv_contrib
    -lopencv_legacy
    -lopencv_flann

    HEADERS += mainwindow.h

    FORMS += mainwindow.ui
    @

    My computer:
    @
    OS: Ubuntu 12.04 (Latest version)
    OpenCV version: 2.4.8
    Qt version: 5.2.1
    Qt Creator version: 3.0.1
    @

    Please ignore OpenCV code, i compile in terminal and works.
    PS: I use an image, and dont know if I need to import in the project, i just put inside the folder project
    PS2: sorry for the english, im mexican :c

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Not really a Qt question but: ball.jpg must be in the same folder as your executable (which is probably located in a shadow build) or you must give the fullpath to it.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        AlbertoAlegria
        wrote on last edited by
        #3

        ok, em... waht's a shadow build? i put my image in the same folder of my project, where my .pro file an main.cpp file are.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          The shadow build is where the compilation currently takes place (it avoids to pollute your source tree). Look in the project panel you'll see a QLineEdit named "Build directory", copy your image in the folder indicated there.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          C 1 Reply Last reply
          0
          • A Offline
            A Offline
            AlbertoAlegria
            wrote on last edited by
            #5

            Ok, thanks, about linking wuth opencv, can you help me? thanks

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              What is the exact error you are getting ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • A Offline
                A Offline
                AlbertoAlegria
                wrote on last edited by
                #7

                I cant compile my OpenCV program in Qt, i post my OpenCV code and my .pro file. I dont know exactly waths happenned, I'm new in Qt, but in OpenCV I have a little bit more experience

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  What error does your compiler give you ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    burdos
                    wrote on last edited by
                    #9

                    i have a problem I just downloaded the qt and also I want to use the opencv but I can't because it says
                    #-------------------------------------------------

                    Project created by QtCreator 2014-04-02T02:57:55

                    #-------------------------------------------------

                    QT += core gui

                    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

                    TARGET = JanelaOpenCv
                    TEMPLATE = app
                    LIBS += -lopencv_core
                    -lopencv_highgui
                    SOURCES += main.cpp
                    mainwindow.cpp

                    HEADERS += mainwindow.h

                    FORMS += mainwindow.ui
                    it says that they cannot find the libraries I do not know how to kink them or how to start working with it thanks

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      If OpenCV is not installed in a known path, you need to tell Qt where to find it.

                      Add
                      @LIBS += -L/path/to/OpenCV/libraries@

                      To your pro file

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • B Offline
                        B Offline
                        burdos
                        wrote on last edited by
                        #11

                        ok fine i did this
                        #-------------------------------------------------

                        Project created by QtCreator 2014-04-02T13:24:58

                        #-------------------------------------------------

                        QT += core

                        QT -= gui

                        TARGET = Consola
                        CONFIG += console
                        CONFIG -= app_bundle
                        LIBS += -L/path/to/OpenCV/libraries
                        TEMPLATE = app

                        SOURCES += main.cp

                        i have my openCv in the following path so how do i have to do set it to start using it
                        the path is the following
                        E:\Open Cv\opencv\build\x86\vc12\lib
                        so please help me how to do it i am new on it

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          @LIBS += -LE:/OpenCV/opencv/build/x86/vc12/lib@

                          Forward slashes and avoid spaces in the path, it's known to be problematic

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0
                          • B Offline
                            B Offline
                            burdos
                            wrote on last edited by
                            #13

                            Oh ok thanks for the help so it runs now very well so it means that all the libraries in the folder can be used right??

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              Yes it is right

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              1 Reply Last reply
                              0
                              • B Offline
                                B Offline
                                burdos
                                wrote on last edited by
                                #15

                                i am trying to do run my code in this way
                                //objectTrackingTutorial.cpp

                                //Written by Kyle Hounslow 2013

                                //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software")
                                //, to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
                                //and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

                                //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

                                //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
                                //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
                                //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
                                //IN THE SOFTWARE.

                                #include <sstream>
                                #include <string>
                                #include <iostream>
                                #include <opencv\highgui.h>
                                #include <opencv\cv.h>

                                using namespace cv;
                                //initial min and max HSV filter values.
                                //these will be changed using trackbars
                                int H_MIN = 0;
                                int H_MAX = 256;
                                int S_MIN = 0;
                                int S_MAX = 256;
                                int V_MIN = 0;
                                int V_MAX = 256;

                                but it says
                                E:\QT\Qt Projects\Project 2\Consola\Project_image\main.cpp:19: error: opencv\highgui.h: No such file or directory
                                #include <opencv\highgui.h>
                                ^

                                E:\QT\Qt Projects\Project 2\Consola\Project image\main.cpp

                                so please how can i solve it

                                1 Reply Last reply
                                0
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #16

                                  Add the path of OpenCV's include.
                                  Something like:

                                  @INCLUDEPATH += E:/OpenCV/opencv/include@

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  1 Reply Last reply
                                  0
                                  • B Offline
                                    B Offline
                                    burdos
                                    wrote on last edited by
                                    #17

                                    i just did it but ok i have this code
                                    QT += core gui

                                    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

                                    TARGET = Project_image
                                    TEMPLATE = app
                                    INCLUDEPATH += E:/OpenCV/opencv/include
                                    LIBS += -LE:/OpenCV/opencv/build/x86/vc12/lib
                                    SOURCES += main.cpp
                                    mainwindow.cpp
                                    ../../../project 1/objectTrackingTut.cpp
                                    ../../../project 1/objectTrackingTut.cpp
                                    ../../../project 1/objectTrackingTut.cpp

                                    HEADERS += mainwindow.h

                                    FORMS += mainwindow.ui

                                    and in the main i have
                                    #include <sstream>
                                    #include <string>
                                    #include <iostream>
                                    #include <opencv\highgui.h>
                                    #include <opencv\cv.h>

                                    using namespace cv;
                                    //initial min and max HSV filter values.
                                    //these will be changed using trackbars
                                    int H_MIN = 0;
                                    int H_MAX = 256;
                                    int S_MIN = 0;
                                    int S_MAX = 256;
                                    int V_MIN = 0;
                                    int V_MAX = 256;
                                    //default capture width and height
                                    const int FRAME_WIDTH = 640;
                                    const int FRAME_HEIGHT = 480;
                                    //max number of objects to be detected in frame
                                    const int MAX_NUM_OBJECTS=50;
                                    //minimum and maximum object area
                                    const int MIN_OBJECT_AREA = 2020;
                                    const int MAX_OBJECT_AREA = FRAME_HEIGHT
                                    FRAME_WIDTH/1.5;
                                    //names that will appear at the top of each window
                                    const string windowName = "Original Image";
                                    const string windowName1 = "HSV Image";
                                    const string windowName2 = "Thresholded Image";
                                    const string windowName3 = "After Morphological Operations";
                                    const string trackbarWindowName = "Trackbars";
                                    void on_trackbar( int, void* )
                                    {//This function gets called whenever a
                                    // trackbar position is changed

                                    and i still have problems it says

                                    #include <opencv\highgui.h> not such a file or directory i do not know why

                                    1 Reply Last reply
                                    0
                                    • SGaistS SGaist

                                      The shadow build is where the compilation currently takes place (it avoids to pollute your source tree). Look in the project panel you'll see a QLineEdit named "Build directory", copy your image in the folder indicated there.

                                      C Offline
                                      C Offline
                                      chfakht
                                      wrote on last edited by
                                      #18

                                      @SGaist please where can i found the build directory in QtCreator !!

                                      1 Reply Last reply
                                      0
                                      • SGaistS Offline
                                        SGaistS Offline
                                        SGaist
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #19

                                        Look at the Projects panel, you have the "Build directory" path there

                                        Interested in AI ? www.idiap.ch
                                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        1 Reply Last reply
                                        0

                                        • Login

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