Problem qith OpenCV and Qt creator



  • 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


  • Lifetime Qt Champion

    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.



  • 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.


  • Lifetime Qt Champion

    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.



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


  • Lifetime Qt Champion

    What is the exact error you are getting ?



  • 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


  • Lifetime Qt Champion

    What error does your compiler give you ?



  • 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


  • Lifetime Qt Champion

    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



  • 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


  • Lifetime Qt Champion

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

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



  • 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??


  • Lifetime Qt Champion

    Yes it is right



  • 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


  • Lifetime Qt Champion

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

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



  • 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



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


  • Lifetime Qt Champion

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


Log in to reply
 

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