Problem with OpenCV on Ubuntu
-
wrote on 30 Jul 2020, 17:21 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?
-
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?
wrote on 30 Jul 2020, 17:46 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?
-
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.
-
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.
wrote on 30 Jul 2020, 18:36 last edited by@SGaist I removed -I from include and it's works. Thanks!
1/4