[Ubuntu 18.04] how add opencv built from source to QT applications
I have built opencv 4 from source and I would like to add it to my QT5 application.
source folder: /home/mike/opencv-4.0.1/ build folder: /home/mike/opencv-4.0.1/build/
I tried to define the below opencv.pri file to keep things organized but I get so many no such file or directory for included files in the source.
Any clue is much appreciate it.
here is the pri file:
INCLUDEPATH += -I/home/mike/opencv-4.0.1/include
LIBS += -L/home/mike/opencv-4.0.1/build -lopencv_core -lopencv_imgcodecs -lopencv_highgui -lopencv_shape -lopencv_videoio -lopencv_calib3d -lopencv_face
and here is the pro file.
#-------------------------------------------------
#
# Project created by QtCreator 2019-01-01T16:34:40
#
#-------------------------------------------------
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
include(/home/mike/opencv-4.0.1/opencv.pri)
TARGET = OpticalMeasure
TEMPLATE = app
QT += core gui xml xmlpatterns
QT += multimedia multimediawidgets
QT += concurrent widgets
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
CONFIG += c++11
LD_LIBRARY_PATH=/home/mike/Qt5.12.0/5.12.0/gcc_64/lib
#INCLUDEPATH += /usr/include/opencv
#LIBS += -L/usr/lib/x86_64-linux-gnu/ -lopencv_core -lopencv_imgcodecs -lopencv_highgui
#LIBS += -L/usr/local/lib -lopencv_shape -lopencv_videoio
#-lopencv_core -lopencv_imgcodecs -lopencv_highgui -lopencv_shape -lopencv_videoio -lopencv_calib3d -lopencv_face
LIBS += -L/home/mike/Qt5.12.0/5.12.0/gcc_64/lib
SOURCES += \
main.cpp \
mainwindow.cpp \
utils/settings.cpp \
utils/utils.cpp \
workerthread.cpp \
camera_calibration.cpp
HEADERS += \
mainwindow.h \
utils/constants.h \
utils/settings.h \
utils/utils.h \
workerthread.h
FORMS += \
mainwindow.ui \
videosettings.ui \
imagesettings.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
RESOURCES += \
resources.qrc \
camera.qrc
QT+=widgets
DISTFILES += \
resources/calibration.xml \
resources/calibration.xml \
resources/calibration.json \
test