Linking openCv with Qt



  • hello everyone,
    i want to include OpenCv libraries with qt 4.8.5.

    getting error like :
    error: opencv2/core/core.hpp: No such file or directory

    i feel thankful if u help me to link this libraries properly.

    // my .pro file
    # Additional import path used to resolve QML modules in Creator's code model
    QML_IMPORT_PATH =
    
    # The .cpp file which was generated for your project. Feel free to hack it.
    SOURCES += main.cpp \
        test.cpp
    
    RESOURCES += qml.qrc
    
    # Installation path
    # target.path =
    
    # Please do not modify the following two lines. Required for deployment.
    include(qtquick1applicationviewer/qtquick1applicationviewer.pri)
    
    # Default rules for deployment.
    include(deployment.pri)
    
    
    INCLUDEPATH +=/home/anas/opencvArm/include/
    LIBS += -L/home/anas/opencvArm/lib/
    
    HEADERS += \
    
    // test.h
    #include <opencv2/core/core.hpp>
    #include <opencv2/highgui/highgui.hpp>
    #include <opencv2/contrib/contrib.hpp>
    #include <opencv2/imgproc/imgproc.hpp>
    
    #include <QtCore>
    #include <iostream>
    #include <stdio.h>
    using namespace cv;
    using namespace std;
    
    class openCV : public QObject
    {
        Q_OBJECT
    public:
    void loadImage();
    };
    ``
    
    
    /// test.cpp```
    
    void openCV::loadImage(){
    string imageName("HappyFish.jpg");
        if( argc != 2)
        {
         cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
         return -1;
        }
    
        Mat image;
        image = imread(argv[1], CV_LOAD_IMAGE_COLOR);   // Read the file
    
        if(! image.data )                              // Check for invalid input
        {
            cout <<  "Could not open or find the image" << std::endl ;
            return -1;
        }
    else std::cout << "its working\n";
    }
    

    // //// main.cpp

    #include "qtquick1applicationviewer.h"
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
    
        QtQuick1ApplicationViewer viewer;
        viewer.addImportPath(QLatin1String("modules"));
        viewer.setOrientation(QtQuick1ApplicationViewer::ScreenOrientationAuto);
        viewer.setMainQmlFile(QLatin1String("qrc:/main.qml"));
        viewer.showExpanded();
    
        return app.exec();
    }
    

  • Lifetime Qt Champion

    Hi,

    Maybe a silly question but are you sure that OpenCV is properly installed in opencvArm ?


Log in to reply
 

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