This question must be duplicate many times, but it just doesn't work and sometimes it still remains unanswered. Sources of information are mainly these
http://www.laganiere.name/opencvCookbook/chap1s1_2.shtml
http://www.youtube.com/watch?v=dgcXYQijV6c
This is the summation of what I think one should/can do. (And now it works for me.) Hopefully I mentioned everything from the very beginning, the aim is to write a very clear tutorial.
Installation of OpenCV for QtCreator
Now I have created a new console app in QtCreator.
//cvHello.pro QT += core QT -= gui TARGET = cvHello CONFIG += console CONFIG -= app_bundle TEMPLATE = app INCLUDEPATH += C:/Programs/opencv24/opencv_bin2/install/include LIBS += "C:/Programs/opencv24/opencv_bin2/bin/*.dll" SOURCES += main.cpp OTHER_FILES += \ img.JPG
And the main file:
//main.cpp #include <iostream> #include "opencv2/core/core.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv/cv.h" using namespace std; int main() { cout << "Hello World!" << endl; cv::Mat mat; mat = cv::imread("img.JPG"); cvNamedWindow("hello"); cv::imshow("hello",mat); cvWaitKey(0); return 0; }
From Qt Wiki. OpenCV is a cross-platform, open-source, commonly used computer vision library. It uses C++ as its primary interface, but other languages such as C and Python can also be used. OpenCV was originally developed by Intel back in 1999 and is now maintained by Willow Garage and ItSeez.
Qt Creator is a cross-platform integrated development environment (IDE) built for the maximum developer experience. Qt Creator runs on Windows, Linux, and macOS desktop operating systems and allows developers to create software across desktop, mobile, and embedded platforms.
Finally I am starting to be happy. When adjusting this question I had to try all ways, how to define LIBS. Listing them manually helped, at first I wrote them somehow wrongly.
This is how it works finally:
LIBS += -LC:\\Programs\\opencv24\\opencv_bin2\\bin \ libopencv_core240d \ libopencv_highgui240d \ libopencv_imgproc240d \ libopencv_features2d240d \ libopencv_calib3d240d \
Btw if I've made any grammar mistakes, I am sorry for my english. :)
The originally accepted answer did not work for me, I am running MSVC2013 Professional and QT5.9. I found SIMPLE and SUREFIRE CROSS-PLATFORM solution that should help anyone who is trying to link an external library (like openCV) with QT.
The steps listed below are found in the Qt5 documentation: http://doc.qt.io/qtcreator/creator-project-qmake-libraries.html under the "To Add Library" section.
Let me add some specificity from here:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With