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 with OpenCV on Ubuntu

Problem with OpenCV on Ubuntu

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 462 Views
  • 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 Offline
    C Offline
    Creatorczyk
    wrote on 30 Jul 2020, 17:21 last edited by
    #1

    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?

    P 1 Reply Last reply 30 Jul 2020, 17:46
    0
    • C Creatorczyk
      30 Jul 2020, 17:21

      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?

      P Offline
      P Offline
      Pl45m4
      wrote on 30 Jul 2020, 17:46 last edited by Pl45m4
      #2

      @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
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 30 Jul 2020, 18:00 last edited by
        #3

        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 30 Jul 2020, 18:36
        0
        • S SGaist
          30 Jul 2020, 18:00

          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.

          C Offline
          C Offline
          Creatorczyk
          wrote on 30 Jul 2020, 18:36 last edited by
          #4

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

          1 Reply Last reply
          0

          1/4

          30 Jul 2020, 17:21

          • Login

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