Qt Forum

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

    Update: Forum Guidelines & Code of Conduct

    Solved Problem with OpenCV on Ubuntu

    General and Desktop
    3
    4
    196
    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.
    • C
      Creatorczyk last edited by

      Hi,

      I want to add library Open CV to my qt project so in the pro file I added:

      QT       += core gui
      
      greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
      
      TARGET = ClientApp
      TEMPLATE = app
      
      DEFINES += QT_DEPRECATED_WARNINGS
      
      CONFIG += c++11 \
                opencv
      
      INCLUDEPATH += -I/usr/local/include/opencv4
      LIBS += -L/usr/local/lib -lopencv_core -lopencv_imgcodecs -lopencv_highgui
      
      SOURCES += \
              main.cpp \
              mainwindow.cpp
      
      HEADERS += \
              mainwindow.h
      
      FORMS += \
              mainwindow.ui
      
      # Default rules for deployment.
      qnx: target.path = /tmp/$${TARGET}/bin
      else: unix:!android: target.path = /opt/$${TARGET}/bin
      !isEmpty(target.path): INSTALLS += target
      

      But when I try to include in mainwindow.h:

      #include <opencv4/opencv2/core/core.hpp>
      

      I get error :

      /usr/local/include/opencv4/opencv2/core/core.hpp:48: error: opencv2/core.hpp: No such file or directory
       #include "opencv2/core.hpp"
                ^~~~~~~~~~~~~~~~~~
      

      I checked the core.hpp file in this path and it is. What could I do?

      Pl45m4 1 Reply Last reply Reply Quote 0
      • Pl45m4
        Pl45m4 @Creatorczyk last edited by Pl45m4

        @Creatorczyk said in Problem with OpenCV on Ubuntu:

        #include <opencv4/opencv2/core/core.hpp>

        Remove opencv4 and try just #include <opencv2/core/core.hpp>
        Your *.pro file looks correct.

        What version of OCV do you have installed?


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

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

          Hi,

          @Creatorczyk said in Problem with OpenCV on Ubuntu:

          INCLUDEPATH += -I/usr/local/include/opencv4

          You are providing the include path up to opencv4. Either remove it here, or as @Pl45m4 remove it from your includes.

          Note that you do not need to add the -I with INCLUDEPATH.

          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 Reply Quote 0
          • C
            Creatorczyk @SGaist last edited by

            @SGaist I removed -I from include and it's works. Thanks!

            1 Reply Last reply Reply Quote 0
            • First post
              Last post