Qt creator 5.0.1与Windows上的OpenCv 2.3.4 [英] Qt creator 5.0.1 with OpenCv 2.3.4 on windows

查看:254
本文介绍了Qt creator 5.0.1与Windows上的OpenCv 2.3.4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经寻找一个很好的指南,但我找不到一个最新版本的Qt和OpenCv。我听说他们都很好,所以我想与这两个项目。我是一个初学者Qt和OpenCv,所以你能一步一步告诉我吗?

解决方案

我一直在努力相当长一段时间,今天早上得到了工作。我想我会回馈这个美好的社区(因为它已经帮助我在许多事情)通过发布我的发现。享受!



我花了很多时间试图获得qt5和opencv 2.4.3工作(实际上,他们发布opencv 2.4.4之前它工作。)我一直在看不是几个教程,但最好的一个到目前为止已经是这一个,所以主要信誉和很多感谢:



http://www.laganiere.name/opencvCookbook/chap1s1_2.shtml



我不能强调这个教程帮助我多少,我正在编写本指南作为补充。大多数情况下,我提供更新的路径到编译器和库,并描述如何处理我一路走来的错误。使用食谱教程的图片和更详细的说明。



但是,我暗示,事情并不痛苦,并按照说明,所以我想我会共享我做了什么来解决问题,希望这将帮助某人。



注意:我不完全确定我在做一半的时间,当有疑问我只是倾向于遵循我的直觉,所以如果有更多的知识和经验的人发现不准确的东西,请告诉我,我会纠正它。这就是我做的,它已经为我做了,我现在建立opencv程序在qt creator 5使用C ++。



我使用以下路径:



Qt:
C:\software\Qt



OpenCV解压缩目录:
c:\software\opencv-win



OpenCV安装目录:
c:\software\opencvMinGW



下载



Ok,所以对于初学者,下载最新的qt库和创建者与MinGW(在我的例子5.0.1)



然后下载openCV,在我的例子是2.4。 4



下载CMake(目前版本为2.8.10.2)



安装:



安装Qt(这将需要一段时间)。



运行openCV exe,您需要的文件。如前所述,我使用C:\software\opencv-win作为解压缩位置。



安装CMake。确保选择将CMake添加到所有用户的系统路径(或类似)。



添加C:\software\qt\5.0.1\ mingw47_32 \bin(或等效的)到系统变量中的路径(如何做到这一点在我开头链接的指南中描述)



RESTART COMPUTER。 >

编译OpenCV:



启动Cmake-gui。
在源代码在哪里:您可以浏览到解压缩opencv(在我的情况下为C:\software\opencv-win)和在哪里构建二进制文件想要完成的库(我使用c:\\​​\\software\opencvMinGW),然后单击生成并创建目录。在弹出窗口中,选择MinGW makefile和指定本地编译器。在C,我的路径变为C:/software/qt/Tools/MinGW/bin/gcc.exe,对于C ++C:/ software / qt / Tools / MinGW / bin / g ++。exe



这是对我来说很奇怪的地方。我有一个错误说:


CMake错误:CMake无法找到一个对应
到MinGW Makefiles 。CMAKE_MAKE_PROGRAM没有设置你可能
需要选择一个不同的构建工具CMake错误:CMake无法
找到一个对应于MinGW Makefiles的构建程序
CMAKE_MAKE_PROGRAM未设置。你可能需要选择一个
不同的构建工具CMake错误:需要内部CMake
变量未设置,cmake可能不能正确构建缺少
变量是:CMAKE_CXX_COMPILER_ENV_VAR CMake错误:找不到
cmake模块
文件:C:/software/opencvMinGWblah/CMakeFiles/2.8.10.2/CMakeCXXCompiler.cmake
CMake错误:需要内部CMake变量未设置,cmake可能
不能正确构建缺少变量是:
CMAKE_C_COMPILER_ENV_VAR CMake错误:找不到cmake模块
文件:C:/software/opencvMinGWblah/CMakeFiles/2.8.10.2/CMakeCCompiler.cmake
配置不完整,出现错误!


我怀疑这与make程序有关。 Duh。但是如何解决呢?



通过选中高级按钮,找到CMAKE_MAKE_PROGRAM并指定路径C:/ software / qt / Tools / MinGW / bin / mingw32-make.exe



一切都很好。或者是吗?



检查分组按钮,打开WITH类别,选中WITH_QT。按配置。
另一大错误:


CMake警告在C:/software/CMake
2.8 / share / 2.8 / Modules / FindQt4.cmake:615(message):C:/software/qt/5.0.1/mingw47_32/bin/qmake.exe报告QT_INSTALL_LIBS
为C:/software/qt/5.0.1/ mingw47_32 / lib,但QtCore不能
。 Qt未正确安装目标构建
环境。调用堆栈(最近调用的第一个):

cmake / OpenCVFindLibsGUI.cmake:8(find_package)CMakeLists.txt:377
(include)


所以,可能从错误消息可能怀疑,程序找不到库。
我如下修正这个。展开categori QT,找到值QT_QTCORE_LIBRARY_DEBUG,输入



C:/software/qt/5.0.1/mingw47_32/bin/Qt5Cored.dll你会发现QT_QTCORE_LIBRARY_RELEASE,输入C:/software/qt/5.0.1/mingw47_32/bin/Qt5Core.dll现在,你可以按配置(希望),没有警告,然后你可以按生成,一切都将dandy你可以按照食谱教程。



Btw,这些是我添加到系统变量的附加路径变量。我不知道,也许他们中的几个是不必要的,但是我不会开始混乱他们,当一切终于工作。

  C:\software\qt\Tools\MinGW\bin; 
C:\software\Qt\Tools\MinGW;
C:\software\opencvMinGW\install\bin;

不要忘记,需要将DLL名称更改为244而不是231, :

  LIBS + = -LC:\\software\\opencvMinGW\\install\\ lib \ 
-lopencv_core244.dll \
-lopencv_highgui244.dll \
-lopencv_imgproc244.dll \
-lopencv_features2d244.dll \
-lopencv_calib3d244。 dll

我真的希望这可以帮助别人!


I have looked for a good guide for days but I can't find one for the latest releases of Qt and OpenCv. I heard that they are both very good so I would like to make a project with these two. I am a beginner with Qt and OpenCv, so can you tell me step by step?

解决方案

I've been struggling with this for quite a while, and got it working this morning. I figured I'd give back to this wonderful community (since it has helped me on numerous occations) by posting my findings. Enjoy!

I've spent a lot of time trying to get qt5 and opencv 2.4.3 to work (so long actually that they released opencv 2.4.4 before i got it to work.) I've been looking at not a few tutorials, but the best one by far has been this one, so major cred and a lot of thanks:

http://www.laganiere.name/opencvCookbook/chap1s1_2.shtml

I can not stress how much this tutorial helped me, and I'm writing this guide as a complement. Mostly I'm providing updated paths to the compilers and libraries and describe how to handle the errors I got along the way. Use the cookbook tutorial for pictures and more in-detail instructions.

But as I hinted, things were not painless and went according to instructions, so I figured I'd share what I did to solve the problems and hopefully this will help someone.

NOTE: I'm not completely sure what I'm doing half of the time, when in doubt I just tend to follow my gut, so if someone with more knowledge and experience spots something that's inaccurate, please tell me and I will correct it. This is simply what I did, and it has worked out for me, I'm now building openCV programs in qt creator 5 using C++.

I used the following paths:

Qt: C:\software\Qt

OpenCV unzip directory: c:\software\opencv-win

OpenCV installed directory: c:\software\opencvMinGW

Downloads:

Ok, so for starters, download the latest qt library and creator with MinGW (in my case 5.0.1)

Then download openCV, which in my case was 2.4.4

Download CMake (at this moment version 2.8.10.2)

Installations:

Install Qt (This will take quite a while).

Run the openCV exe which will extract all the files you need. As stated earlier, I used C:\software\opencv-win as the location to where to extract them.

Install CMake. Make sure to select "Add CMake to system path for all users" (or similar).

Add C:\software\qt\5.0.1\mingw47_32\bin (or equivalent) to path in System variables (How to do this is described in the guide I linked in the beginning)

RESTART COMPUTER.

Compiling OpenCV:

Start Cmake-gui. Under "Where is the source code:" You browse to where you unzipped opencv (in my case C:\software\opencv-win), and in "Where to build the binaries", you enter where you want the finished libraries (I used c:\software\opencvMinGW), then click generate and create directory. At the popup window, you choose "MinGW makefiles" and "Specify native compilers". At C, for me the path became "C:/software/qt/Tools/MinGW/bin/gcc.exe", and for C++ "C:/software/qt/Tools/MinGW/bin/g++.exe", you enter accordingly where you installed Qt.

Press configure.

This is where things got funky for me. I got an error saying:

"CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool. CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool. CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly. Missing variable is: CMAKE_CXX_COMPILER_ENV_VAR CMake Error: Could not find cmake module file:C:/software/opencvMinGWblah/CMakeFiles/2.8.10.2/CMakeCXXCompiler.cmake CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly. Missing variable is: CMAKE_C_COMPILER_ENV_VAR CMake Error: Could not find cmake module file:C:/software/opencvMinGWblah/CMakeFiles/2.8.10.2/CMakeCCompiler.cmake Configuring incomplete, errors occurred!"

I suspected this had to do with the make-program. Duh. But how to fix it?

I resolved it by checking the "Advanced" button, finding the entry CMAKE_MAKE_PROGRAM and specifying the path "C:/software/qt/Tools/MinGW/bin/mingw32-make.exe"

All is well that ends well. Or is it?

Check the "Grouped" button, open the WITH category, check "WITH_QT". Press configure. Another chunk of errors:

CMake Warning at C:/software/CMake 2.8/share/cmake-2.8/Modules/FindQt4.cmake:615 (message): C:/software/qt/5.0.1/mingw47_32/bin/qmake.exe reported QT_INSTALL_LIBS as "C:/software/qt/5.0.1/mingw47_32/lib" but QtCore could not be found there. Qt is NOT installed correctly for the target build environment. Call Stack (most recent call first):
cmake/OpenCVFindLibsGUI.cmake:8 (find_package) CMakeLists.txt:377 (include)

So, as one might suspect from the error message, the program can't find the libraries. I remedied this as follows. Expand the categori QT, find the value QT_QTCORE_LIBRARY_DEBUG, enter

"C:/software/qt/5.0.1/mingw47_32/bin/Qt5Cored.dll" and just below it you'll find QT_QTCORE_LIBRARY_RELEASE, enter "C:/software/qt/5.0.1/mingw47_32/bin/Qt5Core.dll" NOW, you can press configure (hopefully) without warnings and after that you can press Generate and everything will be dandy and you can follow the cookbook tutorial.

Btw, these are the additional path variables I added to System Variables. I dunno, maybe a couple of them are unneccesary but I'm not about to start messing with them when everything finally works.

C:\software\qt\Tools\MinGW\bin;
C:\software\Qt\Tools\MinGW;
C:\software\opencvMinGW\install\bin;

And don't forget that you need to change the DLL names to 244 instead of 231, like this:

LIBS += -LC:\\software\\opencvMinGW\\install\\lib \
    -lopencv_core244.dll \
    -lopencv_highgui244.dll \
    -lopencv_imgproc244.dll \
    -lopencv_features2d244.dll \
    -lopencv_calib3d244.dll

I really hope this helps someone!

这篇关于Qt creator 5.0.1与Windows上的OpenCv 2.3.4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆