如何使用 C++、Visual Studio 2017 安装/配置 OpenCV3.2.0?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43786856/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I install/configure OpenCV3.2.0 with C++, Visual Studio 2017?
提问by Vijay Nirmal
I want to use OpenCV in Visual Studio 2017 to do c++ program.
我想在 Visual Studio 2017 中使用 OpenCV 来做 C++ 程序。
To do it, I followed Setting Up OpenCV in Visual Studiovideo. In that, he said vc14 should be set as environmental variables for VS2015. There is no vc16 for VS2017. So how do I do it for VS2017? And are there any other video instruction changes to be made if I am to use VS2017?
为此,我按照在 Visual Studio视频中设置 OpenCV 进行操作。在那,他说 vc14 应该设置为 VS2015 的环境变量。VS2017 没有 vc16。那么我如何为 VS2017 做到这一点呢?如果我要使用 VS2017,是否还有其他视频指令需要更改?
回答by ΦXoc? ? Пepeúpa ツ
Since the Doc from official OpenCV tutorial is outdated, I will suggest:
由于官方 OpenCV 教程中的 Doc 已经过时,我建议:
get VS-2017with full compiler like:
get the newest CMake(uninstall older versions)
get from github the sourceCode hereand hereand place those in C:/openCV folder, create a BUILD folder there too
open Cmake, select the opencv master folder... in the build write the build directory like:
- click configure, select visual studio 15 2017 and leave selected "use default native compilers", then press "finish"...
- 单击配置,选择 Visual Studio 15 2017 并选择“使用默认本机编译器”,然后按“完成”...
6.1 now you should see cmake doing its job :)
6.1 现在你应该看到 cmake 完成它的工作:)
once configuration is done set the opencv extra modules path and click configure again, and when is done click generate! :)
when generation is done click "open project", this will open a huge project in visual studio named "opencv", now you can close cmake, we dont need that anymore.
now, when the solution is ready, be sure you are in "debug" conf and do right click on "ALL_BUILD" and then "build" (that can take a while) once build succeed change to "release" config and do right click on "ALL_BUILD" and then "build" again.
now,be sure you are in "debug" conf and do right click on "INSTALL" and then "build" (that can take a while) once build succeed change to "release" config and do right click on "INSTALL" and then "build" again.
回答by Martin Zikmund
Additonal tip to the accepted answer - if you get an error like this:
已接受答案的附加提示 - 如果您收到这样的错误:
Invalid escape sequence \ o
无效的转义序列 \o
when you copy and paste the filesystem paths, make sure you use forward slash ( /) instead of backward slash, so
复制和粘贴文件系统路径时,请确保使用正斜杠 ( /) 而不是反斜杠,因此
C:\openCV\opencv_contrib-3.2.0\modules
Must be
必须是
C:/openCV/opencv_contrib-3.2.0/modules
Instead. Otherwise, you will get errors that escape sequence \o
does not exist.
反而。否则,您将收到转义序列\o
不存在的错误。
回答by globalex
Previous post is just perfect. VS 2017 has lib version VS141.
上一篇文章简直完美。VS 2017 有 VS141 的 lib 版本。
Just extension of previous.
只是以前的扩展。
8 Step. After the cmake generate the Opencv.sln in build folder. Open this project in VS 2017
8 步。cmake 在 build 文件夹中生成 Opencv.sln 后。在 VS 2017 中打开这个项目
I am using approach first, just DEBUG x64 version
我首先使用方法,只是 DEBUG x64 版本
The output looks like this
输出看起来像这样
After Debug, switch to Release and Build whole solution again. Same for 32 bit version. Your final solution is under install location under build folder. With contrib libs whole process took almost 30 minutes on I7. Just shaking with CMAKE until the zero defects, include what ever FFMPEG, Contrib and other path. Final build in VS 2017.
调试后,再次切换到发布和构建整个解决方案。32 位版本相同。您的最终解决方案位于构建文件夹下的安装位置。使用 contrib libs 整个过程在 I7 上花费了将近 30 分钟。只用 CMAKE 摇晃直到零缺陷,包括任何 FFMPEG、Contrib 和其他路径。VS 2017 中的最终版本。
The whole approach and install of built libs you can find on my blog Here
整个逼近并安装内置库,你可以在我的博客找到这里