在 Windows 10 Visual Studio 2015 上安装 OpenCV 和额外模块

Installing OpenCV and Extra modules on Windows 10 Visual Studio 2015

我一直在尝试安装 OpenCV 额外模块以使用跟踪算法。我已经按照本教程下载了所有文件和 CMake https://putuyuwono.wordpress.com/2015/04/23/building-and-installing-opencv-3-0-on-windows-7-64-bit/

但是,我开始在 CMake-gui 中进行配置,但出现了一个我不太明白的错误。

The CXX compiler identification is unknown
    The C compiler identification is unknown
    Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
    CMake Error: Generator: execution of make failed. Make command was: "MSBuild.exe" "cmTC_8cf7a.vcxproj" "/p:Configuration=Debug" "/p:VisualStudioVersion=15.0"
    Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- broken
    CMake Error at C:/Program Files/CMake/share/cmake-3.8/Modules/CMakeTestCXXCompiler.cmake:44 (message):
      The C++ compiler "C:/Program Files (x86)/Microsoft Visual Studio
      14.0/VC/bin/cl.exe" is not able to compile a simple test program.

      It fails with the following output:

       Change Dir: C:/opencv-3.0/build/CMakeFiles/CMakeTmp



      Run Build Command:"MSBuild.exe" "cmTC_8cf7a.vcxproj"
      "/p:Configuration=Debug" "/p:VisualStudioVersion=15.0"



      Generator: execution of make failed.  Make command was: "MSBuild.exe"
      "cmTC_8cf7a.vcxproj" "/p:Configuration=Debug" "/p:VisualStudioVersion=15.0"





      CMake will not be able to correctly generate this project.
    Call Stack (most recent call first):
      CMakeLists.txt:127 (project)


    Configuring incomplete, errors occurred!
    See also "C:/opencv-3.0/build/CMakeFiles/CMakeOutput.log".
    See also "C:/opencv-3.0/build/CMakeFiles/CMakeError.log".

不太明白什么意思? 谁能告诉我如何解决这个问题?

干杯

我经常在 Visual C++ 2015 和 2017 中使用 OpenCV。 我直接从源代码构建 OpenCV,而没有遵循您发布的 link。 我建议您从 git

克隆 OpenCV 和 OpenCV Extra Modules

您需要以下工具:git、cmake(我使用的是 3.8.2 版)、Visual C++ 2015 或 Visual C++ 2017

cd projects
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git

打开cmake到你的projects/opencv,设置构建目录,例如build-vc140,select Visual C++ 14 (for visual c++ 2015) or Visual C++ 15 (for visual c++ 2017) 和 运行 配置。 设置 opencv_controlib/modules 的路径,同时设置安装库设置的路径 CMAKE_INSTALL_PREFIX.

生成、打开解决方案并构建 install 目标

要在您的项目中包含该库,只需将 OpenCV_DIR 设置为安装路径