Qt 5.6.1 with Opencv
-
wrote on 9 Aug 2017, 05:23 last edited by
-
I have to use the opencv library in my project build in qt 5.6.1 with mingw compiler but I guess because I am unable to configure qt with opencv 3.9.0 this is the reason of several errors.
Please tell me the procedure to use qt with opencv.
wrote on 9 Aug 2017, 05:37 last edited by joeQ 8 Sept 2017, 05:44@navya.dubey Hi, friend.
- you should to use
LIBS
in pro file to add the OpenCV libs path. like below snippet code:
INCALUDEPATH += opencv_headers_directory # add opencv libs directory LIBS += -Lopencv_libs_directory # add libs such as core, highgui, imgcodecs... LIBS += -lopencv_libs_name LIBS += -lopencv_libs_name LIBS += -lopencv_libs_name LIBS += -lopencv_libs_name
- In your source files
#include <opencv2/core.hpp> #include <opecv2/highgui.hpp> ...
You can click reference link to get more informations about how to use third party libraried in Qt
Reference
- you should to use
-
@navya.dubey Hi, friend.
- you should to use
LIBS
in pro file to add the OpenCV libs path. like below snippet code:
INCALUDEPATH += opencv_headers_directory # add opencv libs directory LIBS += -Lopencv_libs_directory # add libs such as core, highgui, imgcodecs... LIBS += -lopencv_libs_name LIBS += -lopencv_libs_name LIBS += -lopencv_libs_name LIBS += -lopencv_libs_name
- In your source files
#include <opencv2/core.hpp> #include <opecv2/highgui.hpp> ...
You can click reference link to get more informations about how to use third party libraried in Qt
Reference
wrote on 9 Aug 2017, 05:59 last edited byhi @joeQ
I tried this but this error appears
I haven't set any privacy, I don't know the reason behind this error. - you should to use
-
hi @joeQ
I tried this but this error appears
I haven't set any privacy, I don't know the reason behind this error.wrote on 9 Aug 2017, 06:06 last edited by joeQ 8 Sept 2017, 06:13Note: -L and -l
LIBS += -Lopencv_libs_directory # add libs such as core, highgui, imgcodecs... LIBS += -lopencv_libs_name LIBS += -lopencv_libs_name
like
INCLUDE += C:/opencv/build/include LIBS += -LC:/opencv/build/x86/vc14/lin CONFIG(debug, debug|release) { # use debug lib LIBS += -lopencv_core2413d.lib LIBS += -lopencv_highgui2413d.lib LIBS += -lopencv_imgcodecs2413d.lib LIBS += -lopencv_imgproc2413d.lib } CONFIG(release, debug|release) { # use release lib LIBS += -lopencv_core2413.lib LIBS += -lopencv_highgui2413.lib LIBS += -lopencv_imgcodecs2413.lib LIBS += -lopencv_imgproc2413.lib }
-
Note: -L and -l
LIBS += -Lopencv_libs_directory # add libs such as core, highgui, imgcodecs... LIBS += -lopencv_libs_name LIBS += -lopencv_libs_name
like
INCLUDE += C:/opencv/build/include LIBS += -LC:/opencv/build/x86/vc14/lin CONFIG(debug, debug|release) { # use debug lib LIBS += -lopencv_core2413d.lib LIBS += -lopencv_highgui2413d.lib LIBS += -lopencv_imgcodecs2413d.lib LIBS += -lopencv_imgproc2413d.lib } CONFIG(release, debug|release) { # use release lib LIBS += -lopencv_core2413.lib LIBS += -lopencv_highgui2413.lib LIBS += -lopencv_imgcodecs2413.lib LIBS += -lopencv_imgproc2413.lib }
wrote on 9 Aug 2017, 06:25 last edited by@joeQ
I am so sorry but I didn't get the meaning of -L and -l . I have just included the whole path and it says" not found" -
@joeQ
I am so sorry but I didn't get the meaning of -L and -l . I have just included the whole path and it says" not found"wrote on 9 Aug 2017, 06:32 last edited by@navya.dubey
use/
try again, not use\
in the path string. -
@navya.dubey
use/
try again, not use\
in the path string.wrote on 9 Aug 2017, 06:40 last edited by@joeQ the problem still remains the same now the .pro file is not showing error but .cpp shows
-
@joeQ the problem still remains the same now the .pro file is not showing error but .cpp shows
wrote on 9 Aug 2017, 06:47 last edited byHi guys, Can you be careful? Please to read you pro file code. why did you use debug lib twice?
I said not to use
\
in any path. Please check you code carefully. -
Hi guys, Can you be careful? Please to read you pro file code. why did you use debug lib twice?
I said not to use
\
in any path. Please check you code carefully.wrote on 9 Aug 2017, 06:54 last edited by@joeQ
I tried with / as well as with \ and the problem is same anyhow.
I deleted the repetition, problem still remains. -
@joeQ
I tried with / as well as with \ and the problem is same anyhow.
I deleted the repetition, problem still remains.wrote on 9 Aug 2017, 06:59 last edited bydid you include opencv head files?
-
Hi,
In addition to all the good clues @joeQ provided, the main problem here is: trying to build an application with MinGW and link to a C++ library built with Visual Studio. It's not possible. You have to use a MinGW build of OpenCV to link to your application. Or use a VS build of Qt to link to your OpenCV lib built with Visual Studio. Note that prior to Visual Studio 2017, you also have to exactly match the versions of Visual Studio used to build everything C++ you might use in your project.
VS2017 has backward compatibility but only with VS2015.
-
Hi,
In addition to all the good clues @joeQ provided, the main problem here is: trying to build an application with MinGW and link to a C++ library built with Visual Studio. It's not possible. You have to use a MinGW build of OpenCV to link to your application. Or use a VS build of Qt to link to your OpenCV lib built with Visual Studio. Note that prior to Visual Studio 2017, you also have to exactly match the versions of Visual Studio used to build everything C++ you might use in your project.
VS2017 has backward compatibility but only with VS2015.
wrote on 10 Aug 2017, 06:43 last edited by@SGaist hey I tried to build opencv using cmake following this tutorial
https://www.youtube.com/watch?v=ZOSu-2Oju-A
there are several errors while building the code
I followed all the steps in the video but the output is not same as of the video tutorial, I hope you understood the basic problem please help. -
You have to tell CMake where to find Qt in order for it to build its libhighgui with the Qt backend.
-
You have to tell CMake where to find Qt in order for it to build its libhighgui with the Qt backend.
wrote on 10 Aug 2017, 09:38 last edited by@SGaist how to tell cmake where to find qt because I have set the environment variables of the system to know the location of mingw compiler in qt.
what to do next? -
@SGaist how to tell cmake where to find qt because I have set the environment variables of the system to know the location of mingw compiler in qt.
what to do next?@navya.dubey
Hilike
cmake .. -DCMAKE_PREFIX_PATH="C:\Qt\5.7\msvc2015\lib\cmake\Qt5" -
@navya.dubey
Hilike
cmake .. -DCMAKE_PREFIX_PATH="C:\Qt\5.7\msvc2015\lib\cmake\Qt5"wrote on 10 Aug 2017, 10:12 last edited by mrjj 8 Oct 2017, 10:16Where to add it
-
Where to add it
@navya.dubey
Sorry, i miss scrolled and edited your post.You use it as commandline option when you call cmake as shown
-
@navya.dubey
Sorry, i miss scrolled and edited your post.You use it as commandline option when you call cmake as shown
wrote on 10 Aug 2017, 10:19 last edited by@mrjj You mean I have to go to the location where CMake is present and then I have to execute this command, right?
-
@mrjj You mean I have to go to the location where CMake is present and then I have to execute this command, right?
Lifetime Qt Championwrote on 10 Aug 2017, 10:22 last edited by mrjj 8 Oct 2017, 10:22No, you make sure there is path to cmake
then you go to the project folder where the Cmake.tx file is and then
call cmakeif no paths, you can fully tell
c:\programfile\whatever\cmake .. OPTION
Same way as done here
https://forum.qt.io/topic/82074/creating-a-multi-purpose-node-editor-if-there-is-none-available/20
its also a Cmake project -
You can also add that using the GUI you showed in your post.
2/20