Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved How to install openCv in Qt

    3rd Party Software
    opencv qt 5.4.0 path
    2
    16
    5304
    Loading More Posts
    • 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.
    • Trav
      Trav last edited by

      Hello,

      I am looking for context in regards to getting openCv essentially in my application to work. I have managed to do what I would like to accomplish but am taking a learning curve and diving into Qt for lots of obvious reasons and at this point I just am learning and navigating so far what I have found though is to put (see below) into the .pro file but nothing is happening or suggesting when [example ] #include<opencv>

      LIBS += -L/usr/local/lib
      -lopencv_core /
      -lopencv_imgproc /
      -lopencv_features2d/
      -lopencv_highgui

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        You must use backslashes when doing multiline assignments like this one.

        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 Reply Quote 0
        • Trav
          Trav last edited by

          Im using he backslashes just essentially replaced what I had above ****** LIBS += -L\usr\local\lib
          -lopencv_core
          -lopencv_imgproc
          -lopencv_features2d
          -lopencv_highgui

          But still am having difficulties is there something I'm missing here? I am using Mac OSX... and have accomplished this is Xcode but just doesn't seem to be working is there anything else to configure etc?

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            I meant: use backslashes when marking a new line. For the paths themselves use forward slashes.

            What error are you 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 Reply Quote 0
            • Trav
              Trav last edited by

              @Trav said:

              LIBS += -L/usr/local/lib
              -lopencv_core /
              -lopencv_imgproc /
              -lopencv_features2d/
              -lopencv_highgui

              2 days ago

              sorry for the wait... all I'm getting is opencv.cpp not found... is there solid documentation somewhere on this subject? thank you

              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                opencv.cpp not found ? Where's that file coming from ?

                Not knowing what your current error relates to I can't give you any recommendation.

                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 Reply Quote 0
                • Trav
                  Trav last edited by

                  The actual file itself 'openCV ' is located on my desktop... I made a file 'build' inside the folder and then 'lib' where all the files are located ; highgui etc. Is there a crucial step I missed here ? I mean I downloaded openCV installed Cmake by following a tutorial and installed this perfectly fine in Xcode.. But since moving to Qt I have not been able to get the same results.

                  1 Reply Last reply Reply Quote 0
                  • Trav
                    Trav last edited by

                    Could you please tell me in your case how would you do this if you were using Mac assuming we have Qt installed and openCV...

                    1 Reply Last reply Reply Quote 0
                    • SGaist
                      SGaist Lifetime Qt Champion last edited by

                      There are several possibilities.

                      You can use pkg-config or do it like you do currently and provide the INCLUDEPATH and LIBS with the adequate data.

                      Can you share your complete .pro file ? From the bits you've given, one time you have used the wrong line ending char and the other you are complete missing it.

                      Example:

                      LIBS += \
                          -L/usr/local/lib \
                          -lopencv_core \
                          -lopencv_highgui
                      
                      INCLUDEPATH += \
                          /usr/local/include 
                      

                      You should also post the exact error you are having.

                      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 Reply Quote 0
                      • Trav
                        Trav last edited by

                        Yes please see bottom for code. If it at all has changed I have been modifying it and tuning it according to different tutorials to see if it'll work etc. But essentially the end result is the same ERROR: opencv.h not found' when using ' #include <opencv.h> or something similar; highgui, core ...

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

                        Project created by QtCreator 2016-05-15T23:16:25

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

                        QT += core gui

                        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

                        TARGET = cam
                        TEMPLATE = app

                        // new
                        QT += core
                        QT -= gui

                        TARGET = RP_openCV_01
                        CONFIG += console
                        CONFIG -= app_bundle

                        TEMPLATE = app

                        SOURCES += main.cpp
                        mainwindow.cpp

                        LIBS += -L/opt/local/lib
                        -lopencv_highgui.3.1.0
                        -lopencv_core.3.1.0

                        INCLUDEPATH += /opt/local/include

                        HEADERS += mainwindow.h

                        FORMS += mainwindow.ui

                        1 Reply Last reply Reply Quote 0
                        • Trav
                          Trav last edited by

                          Only error is the error that is indicating the header files are not found " OPENCV.H not found!'

                          QT += core gui

                          greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

                          TARGET = cam
                          TEMPLATE = app

                          // new
                          QT += core
                          QT -= gui

                          TARGET = RP_openCV_01
                          CONFIG += console
                          CONFIG -= app_bundle

                          TEMPLATE = app

                          SOURCES += main.cpp
                          mainwindow.cpp

                          LIBS += -L/opt/local/lib
                          -lopencv_highgui.3.1.0
                          -lopencv_core.3.1.0

                          INCLUDEPATH += /opt/local/include

                          HEADERS += mainwindow.h

                          FORMS += mainwindow.ui

                          1 Reply Last reply Reply Quote 0
                          • SGaist
                            SGaist Lifetime Qt Champion last edited by

                            Shouldn't it be #include <opencv2/opencv.hpp> ?

                            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 Reply Quote 0
                            • Trav
                              Trav last edited by

                              Sorry, yes; I have used the #include <opencv2/opencv.hpp> and the error I stated above is still valid

                              1 Reply Last reply Reply Quote 0
                              • SGaist
                                SGaist Lifetime Qt Champion last edited by

                                Do you mean the opencv.h not found error ?

                                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 Reply Quote 0
                                • Trav
                                  Trav last edited by

                                  Hey, thanks for your help I actually got it and have reproduced the desired outcome... essentially what happened because I am new to Qt & OpenCV etc. It seems I have placed the code before Sources' in the project.pro file which produced the errors... I did this before as well I don't quite understand why it decides to work now but did not before? but essentially I'm good :) thanks for support

                                  1 Reply Last reply Reply Quote 0
                                  • SGaist
                                    SGaist Lifetime Qt Champion last edited by

                                    Good !

                                    In that case, please mark the thread as solved using the "Topic Tool" button so that other forum users may know a solution has been found :)

                                    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 Reply Quote 0
                                    • First post
                                      Last post