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

Jam*_*lly 1 c++ opencv cmake-gui

我一直在尝试安装 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".
Run Code Online (Sandbox Code Playgroud)

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

干杯

elv*_*kaj 5

我定期将 OpenCV 与 Visual C++ 2015 和 2017 一起使用。我直接从源代码构建 OpenCV,而不遵循您发布的链接。我建议你从 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
Run Code Online (Sandbox Code Playgroud)

打开 cmake 到您的projects/opencv,设置构建目录,例如build-vc140,选择 Visual C++ 14(对于 Visual C++ 2015)或 Visual C++ 15(对于 Visual C++ 2017)并运行配置。设置路径opencv_controlib/modules,同时设置安装库设置的路径CMAKE_INSTALL_PREFIX

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

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