Windows环境VSCode配置OpenCV-环境搭建(一)

  1. 软件准备
    • OpenCV

    • cmake

    • MinGW-W64
      MinGW-W64要下载Windows环境VSCode配置OpenCV-环境搭建(一)_第1张图片
      否则后面编译出错:

        D:/openCV_win/opencv/sources/modules/core/include/opencv2/core/utility.hpp:719:29: error: 'Mutex' is not a member of 'cv'
         typedef std::lock_guard AutoLock;
                                     ^~~~~
        D:/openCV_win/opencv/sources/modules/core/include/opencv2/core/utility.hpp:719:29: note: suggested alternative: 'Matx'
         typedef std::lock_guard AutoLock;
                                     ^~~~~
                                     Matx
        D:/openCV_win/opencv/sources/modules/core/include/opencv2/core/utility.hpp:719:29: error: 'Mutex' is not a member of 'cv'
        D:/openCV_win/opencv/sources/modules/core/include/opencv2/core/utility.hpp:719:29: note: suggested alternative: 'Matx'
         typedef std::lock_guard AutoLock;
                                     ^~~~~
                                     Matx
        D:/openCV_win/opencv/sources/modules/core/include/opencv2/core/utility.hpp:719:34: error: template argument 1 is invalid
         typedef std::lock_guard AutoLock;
                                          ^
        [ 14%] Building CXX object CMakeFiles/ade.dir/3rdparty/ade/ade-0.1.1f/sources/ade/source/graph.cpp.obj
        minGW32-make[2]: *** [modules\core\CMakeFiles\opencv_core.dir\build.make:118: modules/core/CMakeFiles/opencv_core.dir/src/alloc.cpp.obj] Error 1
        [ 14%] Building C object 3rdparty/libpng/CMakeFiles/libpng.dir/pngget.c.obj
        [ 14%] Building C object 3rdparty/libtiff/CMakeFiles/libtiff.dir/tif_codec.c.obj
        In file included from D:\openCV_win\opencv\sources\modules\core\src\arithm.cpp:50:
        D:\openCV_win\opencv\sources\modules\core\src\precomp.hpp:369:5: error: 'Mutex' in namespace 'cv' does not name a type
         cv::Mutex& getInitializationMutex();
             ^~~~~
        D:\openCV_win\opencv\sources\modules\core\src\precomp.hpp:369:1: note: suggested alternative: 'Matx'
         cv::Mutex& getInitializationMutex();
         ^~
         Matx
      
  2. 配置环境变量
    在这里插入图片描述
  3. 打开Cmake下的bin目录下的cmake-gui.exe
    Windows环境VSCode配置OpenCV-环境搭建(一)_第2张图片
    第一行选择OpenCV sources目录,第三行选择编译输出路径,然后点击configure按下图配置
    Windows环境VSCode配置OpenCV-环境搭建(一)_第3张图片
    Windows环境VSCode配置OpenCV-环境搭建(一)_第4张图片
  4. finish后开始生成Makefiles文件配置,然后点击configure,完成后点击genrate
    Windows环境VSCode配置OpenCV-环境搭建(一)_第5张图片
  5. done后,进入输出目录执行minGW32-make -j8
    Windows环境VSCode配置OpenCV-环境搭建(一)_第6张图片
  6. 执行minGW32-make install
  7. 编译后的opencv添加到环境变量
    在这里插入图片描述

你可能感兴趣的:(windows,vscode,opencv)