Solved Using opencv3.1 with Qt5.5 in Windows 10
-
@brotify Can you search for opencv_core310.lib (and other needed *.lib files) in the installation directory?
-
It seems like you are trying to use OpenCV built using MinGW with Qt built with Visual Studio. There are two things you can do.
-
use OpenCV pre built. Which is in your build folder of OpenCV downloaded zip
-
change the kit in your Qt Creator to use MinGW build of Qt.
Hope this helps
-
-
Please note that I have solved my problem but I will not delete this post because it may help other people.
@asanka424
Thanks, I selected Mingw32 as the kit and it worked but this time I get a different error. I tried a simple opencv program which shows the image however it gives this error:
undefined reference to `cv::imread(cv::String const&, int)'Here is my code,
#include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <iostream> using namespace cv; using namespace std; int main( ) { Mat image; image = imread("img.jpg", CV_LOAD_IMAGE_COLOR); if(! image.data ) { cout << "Could not open or find the image" << std::endl ; return -1; } namedWindow( "Display window", WINDOW_AUTOSIZE );// Create a window for display. imshow( "Display window", image ); waitKey(0); return 0; }
and here is my .pro file
QT += core QT -= gui CONFIG += c++11 TARGET = untitled CONFIG += console CONFIG -= app_bundle INCLUDEPATH += C:/opencv2/release/install/include LIBS += -LC:/opencv2/release/install/x86/mingw/bin\ -lopencv_core310 \ -lopencv_highgui310 \ -lopencv_imgproc310 \ -lopencv_features2d310 \ -lopencv_calib3d310 \ TEMPLATE = app SOURCES += main.cpp
And lastly can you show me how to use first method that is using opencv pre-built?
-
@mrdebug
I was not aware of that Qt has two different versions. So far I was using VC. Now I am using MinGw and it seems that the problem was this. Yet I have another problem which I posted before this post. -
Ok, I want to thanks all of you who tried to help me. Hopefully I solved my problem. I solved the last problem by adding to .pro file
LIBS += "C:\opencv2\release\lib\libopencv_imgcodecs310.dll.a"
-
Hello
I am also in a same situation, i did not find any solution till now.
I am using Qt creator 5.5 with mingw492_32 and openCv 3.10 with VC.
When i try to write a small code to read the image matrix usingcv::imread()
it gives me error.error: undefined reference to `cv::imread(cv::String const&, int)
this is my
test.pro
QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = Test TEMPLATE = app SOURCES += main.cpp\ mainwindow.cpp HEADERS += mainwindow.h FORMS += mainwindow.ui INCLUDEPATH += LC:\opencv\build\include LIBS += C:\opencv\build\x64\vc14\lib\opencv_world310.lib \ C:\opencv\build\bin\opencv_ffmpeg310.dll
i have only one library file in the openCV folder
Do you have any idea what i am suppose to do? -
Hi.
You can't use the vc libraries of OpenCV with Qt built with Mingw. If you want to use Qt with mingw you have to build OpenCV with Mingw.
I confirm Qt 5.5 works perfectly with OpenCV 3.
http://www.denisgottardello.it/ComputerVisionStudio/index.php -
Is there any link which explains perfect installation of OpenCV 3 and Qt5.5?
-
These lines of code work perfectly with Qt 5.5.0 and OpenCV 3.0
set PATH=%PATH%;C:\Qt\Qt5.5.0\Tools\mingw492_32\bin;C:\Program Files (x86)\CMake 2.8\bin
cmake -G "MinGW Makefiles" -DWITH_FFMPEG=OFF -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_opencv_videoio=ON -DWITH_IPP=OFF -DWITH_OPENCL=OFF -DWITH_JASPER=OFF -DWITH_OPENEXR=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DOPENCV_EXTRA_MODULES_PATH=modules/opencv_contrib-master/modules .mingw32-make -j 4
I have only some problems with webcams in some 64 bit machines.
Another hard problem is to setup the pro file. You have to include the libraries in a particular order (depends from your program). Some libraries can be included more than one time.
This solution sounds to be very strange but I assure, to have OpenCV working I have spent a lot of time.If you need professional support please send me an email at info@denisgottardello.it
-
@mrdebug
I seriously did not understand from 3rd line (cmake).I set the paths of Qt and CMake
Below are my paths
C:\Qt\5.5\mingw492_32\bin
C:\CMake\bin
I don't understand what I have to do in CMake?
Can you say me any step by step procedure or any other way?