一、参考资料

VScode搭建OpenCV环境
OpenCV使用CMake和MinGW-w64的编译安装
win10下VSCode配置opencv4.4.0(超详细教程,亲测有效)
VSCODE中配置C++的OPENCV库
Windows10下Opencv4+CMake+MinGW64+VSC安装教程
CMake和minGW-64 编译安装 OpenCV3.4.11以供 Qt 使用
visual studio 2019 安装 opencv 详细图文流程
win10下使用Cmake的MinGW编译配置Opencv

二、步骤

1. vscode安装并配置

2. MinGW安装并配置

参考博客 【Windows版】配置C/C++开发环境

3. 官网下载OpenCV源码并安装

OpenCV官网

解压OpenCV源码
opencv-4.5.2-vc14_vc15.exe

##begin---------------------2021-06-22补充----------------------------##

OpenCV首页找不到链接,解决办法如下图:

##end---------------------2021-06-22补充----------------------------##

4. CMake安装并配置(配置编译选项)
安装CMake,参考博客 【Windows版】CMake安装教程

(1)打开 cmake-gui,设置源码路径和编译生成路径:
cmake-gui.exe的路径:D:\360Downloads\CMake\cmake-3.20.3-windows-x86_64\bin\cmake-gui.exe
Where is the source code: 
D:/360Downloads/Software/opencv/sources

Where to build the binaries: 
D:/360Downloads/Software/opencv/build/x64/MinGw

MinGw是新建的文件夹,用来存放编译好的OpenCV

(2)点击 Configure,设置编译器

配置好opencv的源码路径和编译生成路径,点击Configure即可触发配置,第一次配置需要输入编译器类型以及Makefile类型:

Compilers C: D:\360Downloads\MinGW\mingw64\bin\gcc.exe
Compilers C++: D:\360Downloads\MinGW\mingw64\bin\g++.exe

勾选 WITH_OPENGL
勾选 ENABLE_CXX11
不勾选 WITH_IPP
不勾选 ENABLE_PRECOMPILED_HEADERS

 第一次Configure,生成红色的,勾选对应的属性之后,再重新Configure。

CMake的 Configure要多点几次, 一直点到上面的配置项没有红色为止。

(3)勾选配置

勾选:
BUILD_opencv_world
WITH_OPENGL
BUILD_EXAMPLES
设置OPENCV_DOWNLOAD_PATH不勾选:
WITH_IPP
WITH_MSMF
ENABLE_PRECOMPILED_HEADERS
CPU_DISPATCH

如果要编译 opencv_contrib,则需要在 OPENCV_EXTRA_MODULES_PATH 把路径选择为解压的 opencv_contrib 文件中的“modules”文件夹。  再次点击Configure。

======================完整的参数配置=========================

---------------2021-06-04补充---------------

General configuration for OpenCV 4.5.2 =====================================Version control:               unknownExtra modules:Location (extra):            D:/360Downloads/opencv/opencv_contrib-4.5.2/modulesVersion control (extra):     unknownPlatform:Timestamp:                   2021-06-04T01:58:13ZHost:                        Windows 10.0.17763 AMD64CMake:                       3.20.3CMake generator:             Visual Studio 16 2019CMake build tool:            D:/360Downloads/VisualStudio2019/2019/Professional/MSBuild/Current/Bin/MSBuild.exeMSVC:                        1929Configuration:               Debug ReleaseCPU/HW features:Baseline:                    SSE SSE2 SSE3requested:                 SSE3Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKXrequested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKXSSE4_1 (17 files):         + SSSE3 SSE4_1SSE4_2 (2 files):          + SSSE3 SSE4_1 POPCNT SSE4_2FP16 (1 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVXAVX (5 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVXAVX2 (31 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2AVX512_SKX (7 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKXC/C++:Built as dynamic libs?:      YESC++ standard:                11C++ Compiler:                D:/360Downloads/VisualStudio2019/2019/Professional/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64/cl.exe  (ver 19.29.30037.0)C++ flags (Release):         /DWIN32 /D_WINDOWS /W4 /GR  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise     /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP  /MD /O2 /Ob2 /DNDEBUG C++ flags (Debug):           /DWIN32 /D_WINDOWS /W4 /GR  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise     /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP  /MDd /Zi /Ob0 /Od /RTC1 C Compiler:                  D:/360Downloads/VisualStudio2019/2019/Professional/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64/cl.exeC flags (Release):           /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise     /MP   /MD /O2 /Ob2 /DNDEBUG C flags (Debug):             /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise     /MP /MDd /Zi /Ob0 /Od /RTC1 Linker flags (Release):      /machine:x64  /INCREMENTAL:NO Linker flags (Debug):        /machine:x64  /debug /INCREMENTAL ccache:                      NOPrecompiled headers:         YESExtra dependencies:          opengl32 glu32 cudart_static.lib nppc.lib nppial.lib nppicc.lib nppidei.lib nppif.lib nppig.lib nppim.lib nppist.lib nppisu.lib nppitc.lib npps.lib cublas.lib cudnn.lib cufft.lib -LIBPATH:D:/360Downloads/CUDA11.3/NVIDIA GPU Computing Toolkit/CUDA/v11.3/lib/x643rdparty dependencies:OpenCV modules:To be built:                 aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dnn_objdetect dnn_superres dpm face features2d flann fuzzy gapi hdf hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot python3 quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab wechat_qrcode xfeatures2d ximgproc xobjdetect xphotoDisabled:                    worldDisabled by dependency:      -Unavailable:                 alphamat cnn_3dobj cvv freetype java julia matlab ovis python2 sfm vizApplications:                tests perf_tests examples appsDocumentation:               NONon-free algorithms:         YESWindows RT support:            NOGUI: Win32 UI:                    YESOpenGL support:              YES (opengl32 glu32)VTK support:                 NOMedia I/O: ZLib:                        build (ver 1.2.11)JPEG:                        build-libjpeg-turbo (ver 2.0.6-62)WEBP:                        build (ver encoder: 0x020f)PNG:                         build (ver 1.6.37)TIFF:                        build (ver 42 - 4.2.0)JPEG 2000:                   build (ver 2.4.0)OpenEXR:                     build (ver 2.3.0)HDR:                         YESSUNRASTER:                   YESPXM:                         YESPFM:                         YESVideo I/O:DC1394:                      NOFFMPEG:                      YES (prebuilt binaries)avcodec:                   YES (58.91.100)avformat:                  YES (58.45.100)avutil:                    YES (56.51.100)swscale:                   YES (5.7.100)avresample:                YES (4.0.0)GStreamer:                   NODirectShow:                  YESParallel framework:            ConcurrencyTrace:                         YES (with Intel ITT)Other third-party libraries:Lapack:                      NOEigen:                       NOCustom HAL:                  NOProtobuf:                    build (3.5.1)NVIDIA CUDA:                   YES (ver 11.3, CUFFT CUBLAS)NVIDIA GPU arch:             35 37 50 52 60 61 70 75 80 86NVIDIA PTX archs:cuDNN:                         YES (ver 8.2.0)OpenCL:                        YES (NVD3D11)Include path:                D:/360Downloads/opencv/sources/3rdparty/include/opencl/1.2Link libraries:              Dynamic loadONNX:                          NOPython 3:Interpreter:                 D:/360Downloads/Anaconda3/python.exe (ver 3.8.8)Libraries:                   D:/360Downloads/Anaconda3/libs/python38.lib (ver 3.8.8)numpy:                       D:/360Downloads/Anaconda3/lib/site-packages/numpy/core/include (ver 1.20.1)install path:                D:/360Downloads/Anaconda3/Lib/site-packages/cv2/python-3.8Python (for build):            D:/360Downloads/Anaconda3/python.exeJava:                          ant:                         NOJNI:                         NOJava wrappers:               NOJava tests:                  NOInstall to:                    D:/360Downloads/opencv/build/x64/MinGw/install
-----------------------------------------------------------------Configuring done

(4)生成的配置信息,并生成MakeFiles文件

Detected processor: AMD64
Could NOT find PythonInterp: Found unsuitable version "2.7.16", but required is at least "3.2" (found D:/Anaconda2/python.exe)
Looking for ccache - not found
AVX_512F is not supported by C++ compiler
AVX512_COMMON is not supported by C++ compiler
AVX512_SKX is not supported by C++ compiler
Dispatch optimization AVX512_SKX is not available, skipped
Cleaning INTERNAL cached variable: ZLIB_LIBRARY
Cleaning INTERNAL cached variable: ZLIB_INCLUDE_DIR
Found ZLIB: D:/Anaconda2/Library/lib/z.lib (found suitable version "1.2.11", minimum required is "1.2.3")
libjpeg-turbo: VERSION = 2.0.6, BUILD = opencv-4.5.2-libjpeg-turbo
Cleaning INTERNAL cached variable: TIFF_LIBRARY
Cleaning INTERNAL cached variable: TIFF_INCLUDE_DIR
Found TIFF: D:/Anaconda2/Library/lib/tiff.lib (found version "4.0.10")
Cleaning INTERNAL cached variable: WEBP_LIBRARY
Cleaning INTERNAL cached variable: WEBP_INCLUDE_DIR
Could NOT find OpenJPEG (minimal suitable version: 2.0, recommended version >= 2.3.1). OpenJPEG will be built from sources
OpenJPEG: VERSION = 2.4.0, BUILD = opencv-4.5.2-openjp2-2.4.0
OpenJPEG libraries will be built from sources: libopenjp2 (version "2.4.0")
Cleaning INTERNAL cached variable: PNG_LIBRARY
Cleaning INTERNAL cached variable: PNG_INCLUDE_DIR
Found ZLIB: D:/Anaconda2/Library/lib/z.lib (found version "1.2.11")
Found PNG: D:/Anaconda2/Library/lib/libpng.lib (found version "1.6.37")
Looking for D:/Anaconda2/Library/include/libpng/png.h
Looking for D:/Anaconda2/Library/include/libpng/png.h - not found
Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
Could NOT find BLAS (missing: BLAS_LIBRARIES)
Could NOT find LAPACK (missing: LAPACK_LIBRARIES) Reason given by package: LAPACK could not be found because dependency BLAS could not be found.Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
OpenCV Python: during development append to PYTHONPATH: D:/360Downloads/Software/opencv/build/x64/MinGw/python_loader
Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
Consider adding OPENCV_ALLOCATOR_STATS_COUNTER_TYPE=int/int64_t according to your build configuration
Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.avx512_skx.cpp
Excluding from source files list: <BUILD>/modules/core/test/test_intrin256.avx512_skx.cpp
Excluding from source files list: <BUILD>/modules/core/test/test_intrin512.avx512_skx.cpp
Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': D:/360Downloads/Software/opencv/sources/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
opencv_dnn: filter out ocl4dnn source code
opencv_dnn: filter out cuda4dnn source code
Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx512_skx.cpp
Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
OpenCL samples are skipped: OpenCL SDK is required
SYCL/OpenCL samples are skipped: SYCL SDK is required- check configuration of SYCL_DIR/SYCL_ROOT/CMAKE_MODULE_PATH- ensure that right compiler is selected from SYCL SDK (e.g, clang++): CMAKE_CXX_COMPILER=D:/360Downloads/Software/MinGW/mingw64/bin/g++.exe
CMake Warning at cmake/OpenCVGenSetupVars.cmake:54 (message):CONFIGURATION IS NOT SUPPORTED: validate setupvars script in installdirectory
Call Stack (most recent call first):CMakeLists.txt:1010 (include)General configuration for OpenCV 4.5.2 =====================================Version control:               unknownPlatform:Timestamp:                   2021-04-09T02:59:22ZHost:                        Windows 10.0.18363 AMD64CMake:                       3.20.1CMake generator:             MinGW MakefilesCMake build tool:            D:/360Downloads/Software/MinGW/mingw64/bin/mingw32-make.exeConfiguration:               ReleaseCPU/HW features:Baseline:                    SSE SSE2 SSE3requested:                 SSE3Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKXSSE4_1 (17 files):         + SSSE3 SSE4_1SSE4_2 (2 files):          + SSSE3 SSE4_1 POPCNT SSE4_2FP16 (1 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVXAVX (5 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVXAVX2 (31 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2C/C++:Built as dynamic libs?:      YESC++ standard:                11C++ Compiler:                D:/360Downloads/Software/MinGW/mingw64/bin/g++.exe  (ver 8.1.0)C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUGC++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUGC Compiler:                  D:/360Downloads/Software/MinGW/mingw64/bin/gcc.exeC flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUGC flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUGLinker flags (Release):      -Wl,--gc-sections  Linker flags (Debug):        -Wl,--gc-sections  ccache:                      NOPrecompiled headers:         NOExtra dependencies:3rdparty dependencies:OpenCV modules:To be built:                 calib3d core dnn features2d flann gapi highgui imgcodecs imgproc ml objdetect photo stitching ts video videoioDisabled:                    python2 worldDisabled by dependency:      -Unavailable:                 java python3Applications:                tests perf_tests examples appsDocumentation:               NONon-free algorithms:         NOWindows RT support:            NOGUI: Win32 UI:                    YESVTK support:                 NOMedia I/O: ZLib:                        D:/Anaconda2/Library/lib/z.lib (ver 1.2.11)JPEG:                        build-libjpeg-turbo (ver 2.0.6-62)WEBP:                        build (ver encoder: 0x020f)PNG:                         D:/Anaconda2/Library/lib/libpng.lib (ver 1.6.37)TIFF:                        D:/Anaconda2/Library/lib/tiff.lib (ver 42 / 4.0.10)JPEG 2000:                   build (ver 2.4.0)OpenEXR:                     build (ver 2.3.0)HDR:                         YESSUNRASTER:                   YESPXM:                         YESPFM:                         YESVideo I/O:DC1394:                      NOFFMPEG:                      YES (prebuilt binaries)avcodec:                   YES (58.91.100)avformat:                  YES (58.45.100)avutil:                    YES (56.51.100)swscale:                   YES (5.7.100)avresample:                YES (4.0.0)GStreamer:                   NODirectShow:                  YESParallel framework:            noneTrace:                         YES (with Intel ITT)Other third-party libraries:Lapack:                      NOEigen:                       NOCustom HAL:                  NOProtobuf:                    build (3.5.1)OpenCL:                        YES (no extra features)Include path:                D:/360Downloads/Software/opencv/sources/3rdparty/include/opencl/1.2Link libraries:              Dynamic loadPython (for build):            D:/Anaconda2/python.exeJava:                          ant:                         NOJNI:                         NOJava wrappers:               NOJava tests:                  NOInstall to:                    D:/360Downloads/Software/opencv/build/x64/MinGw/install
-----------------------------------------------------------------Configuring done
Generating done

5. 编译OpenCV
进入MakeFiles所在文件夹

>>> cd  D:\360Downloads\opencv\build\x64\MinGw

使用多线程编译,编译时间5-10分钟,根据电脑性能有差异

>>> minGW32-make -j 8

6. 安装OpenCV

minGW32-make install

D:/360Downloads/Software/opencv/build/x64/MinGw/install/x64/mingw/bin 目录下有两个dll文件:

libopencv_world452.dll
opencv_videoio_ffmpeg452_64.dll

7. 测试OpenCV是否安装成功 

findContours_demo.cpp

/*** @function findContours_Demo.cpp* @brief Demo code to find contours in an image* @author OpenCV team*/#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include <iostream>using namespace cv;
using namespace std;Mat src_gray;
int thresh = 100;
RNG rng(12345);/// Function header
void thresh_callback(int, void* );/*** @function main*/
int main( int argc, char** argv )
{/// Load source imageCommandLineParser parser( argc, argv, "{@input | HappyFish.jpg | input image}" );Mat src = imread( samples::findFile( parser.get<String>( "@input" ) ) );if( src.empty() ){cout << "Could not open or find the image!\n" << endl;cout << "Usage: " << argv[0] << " <Input image>" << endl;return -1;}/// Convert image to gray and blur itcvtColor( src, src_gray, COLOR_BGR2GRAY );blur( src_gray, src_gray, Size(3,3) );/// Create Windowconst char* source_window = "Source";namedWindow( source_window );imshow( source_window, src );const int max_thresh = 255;createTrackbar( "Canny thresh:", source_window, &thresh, max_thresh, thresh_callback );thresh_callback( 0, 0 );waitKey();return 0;
}/*** @function thresh_callback*/
void thresh_callback(int, void* )
{/// Detect edges using CannyMat canny_output;Canny( src_gray, canny_output, thresh, thresh*2 );/// Find contoursvector<vector<Point> > contours;vector<Vec4i> hierarchy;findContours( canny_output, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE );/// Draw contoursMat drawing = Mat::zeros( canny_output.size(), CV_8UC3 );for( size_t i = 0; i< contours.size(); i++ ){Scalar color = Scalar( rng.uniform(0, 256), rng.uniform(0,256), rng.uniform(0,256) );drawContours( drawing, contours, (int)i, color, 2, LINE_8, hierarchy, 0 );}/// Show in a windowimshow( "Contours", drawing );
}

三、注意事项

(1)在操作cmake-gui前,如果没有翻过墙的话,在C:\Windows\System32\drivers\etc\hosts文件最后追加:

151.101.72.133 raw.githubusercontent.com

因为cmake-gui会下载一些文件,这些文件都在raw.githubusercontent.com上,如果不修改一下hosts,许多文件很可能会下载失败

四、可能存在的问题

(1)编译OpenCV出现错误

如果报错可查阅下面的网址帮助:

https://blog.huihut.com/2018/07/31/CompiledOpenCVWithMinGW64/

一般问题都是可以通过 勾选 和 去勾选 解决的,重新Configure,重新编译即可。

错误原因:
在配置MinGw信息的时候,勾选信息错误

解决办法:

参考上文步骤4,第(3)勾选配置

(2)找不到libopencv_core452

错误原因:

没有把编译好的OpenCV添加到环境变量中

解决办法:

添加环境变量
D:\360Downloads\Software\opencv\build\x64\MinGw\bin

(3)无法找到入口
无法定位程序输入点_ZNSt6thread15_M_start_threadESt10unique_ptrINS_6_StateESt14default_deleteIS1_EEPFvvE

huihut/OpenCV-MinGW-Build
https://github.com/huihut/OpenCV-MinGW-Build/issues/18

错误原因:
anaconda 中的 LIBSTDC++-6.DLL 与 MinGW64 的LIBSTDC++-6.DLL 冲突所导致的,在配置环境变量时将 MinGW64 的 bin 路径移到高于 anaconda 的 mingw-w64/bin 路径更高优先级的位置就可以了

解决办法:

(4)CMake Warning at cmake/OpenCVDownload.cmake:202 (message):
FFMPEG: Download failed: 6;"Couldn't resolve host name"
错误原因:下载ffmpeg失败,需要翻墙
解决办法:见上文【三、注意事项】

(5)如果opencv编译失败,删除目录 D:\360Downloads\Software\opencv\build\x64\MinGw 里的所有文件,重头开始

(6)gcc: error: long: No such file or directory

参考资料:
使用CMake+Qt自带的MinGW编译OpenCV
gcc: error: long: No such file or directory

错误原因:在CMake的configure配置文件勾选中,勾选错误
解决办法:

  1. 在CMake中找到OPENCV_ENABLE_ALLOCATOR_STATS这项,取消勾选
  2. 重新Configure,重新Generate
  3. 重新mingw32-make编译

(7)ImportError: DLL load failed while importing cv2

参考资料:

opencv cuda加速编译后调用python接口后报错ImportError: DLL load failed while importing cv2记录

错误原因:在CMake源码安装了C++版本的Opencv,但没有安装python版本的Opencv
解决办法:

>>> cd PATH\TO\python_loader
>>> python setup.py install  # 安装python版本的Opencv

(8)recursion is detected during loading of cv2 binary extensions

(9)在vs2015中配置Opencv,无法找到源文件"opencv2/opencv.hpp" 

参考资料:在vs2015中配置Opencv,无法找到源文件"opencv2/opencv.hpp"
解决办法:VS2019中x86改为x64

五、其他

(1)opencv 和opencv_contrib配置
参考博客 【Windows版】opencv 和opencv_contrib配置

(2)修改python版本

在cmake-gui中修改

(3)ubuntu编译OpenCV

从源码安装OpenCV,使用python

(4)用Visual studio编译OpenCV

Windows下 Cmake + VS 编译 OpenCV (+ opencv_contribute)源码

windows+vscode+opencv源码安装配置相关推荐

  1. windows mysql源码安装配置_windows下MySQL5.6版本安装及配置过程附有截图和具体介绍...

    随着MYSQL版本的升级以及电脑系统的变化,我们给大家整理了种种电脑环境下安装MYSQL的图解过程,希望我们整理的内容能够帮助到大家:mysql安装图解总结 https://www.in68.com/ ...

  2. OpenCV源码安装教程(兼容CUDA)

    简介 OpenCV是计算机视觉领域应用非常广泛的工具库.而OpenCV Contrib库是第三方非官方开发的扩充库,这个库可以使用一些特殊算法,如物体跟踪.和英伟达的CUDA配合,OpenCV可以更加 ...

  3. 在Centos7下源码安装配置Redis

    1.安装前准备开发环境 安装pcre开发包: yum install -y pcre-devel  安装编译源码所需的工具和库:yum install gcc gcc-c++ ncurses-deve ...

  4. 小狐狸ChatGPT付费创作系统1.6.8独立开源版 + 公众号H5+小程序+VUE源码安装配置详细教程

    小狐狸GPT付费体验系统最新版系统是一款基于ThinkPHP框架开发的AI问答小程序,是基于国外很火的ChatGPT进行开发的Ai智能问答小程序.接口模型升级至GTP3.5,播播资源网整体测试下来非常 ...

  5. mysql源码安装配置_MySQL源码安装及配置

    目录 --cmake下载安装 http://cmake.org/download/ # wgethttp://cmake.org/files/v3.3/cmake-3.3.2.tar.gz # tar ...

  6. nginx1.10.2源码安装配置参数参考

    [root@localhost nginx-1.10.2]# ./configure --help--help print this message--prefix=PATH set installa ...

  7. mysql5.0源码安装_linux小白 mysql5.0源码安装配置

    安装mysql-5.0.45.tar.gz(该软件包下载地址:http://www.filewatcher.com/m/mysql-5.0.45.tar.gz.24433261-0.html) # g ...

  8. php源码安装配置,php源码安装时configure配置参数 | 学步园

    在Linux下安装PHP,源代码方式安装,总需要配置很多参数.这里列出常用配置参数,并详细用中文解释说明了. 给大家一些参考./configure –prefix=/usr/local/PHP     ...

  9. Windows下strongswan-5.5.3源码安装

    Windows 下strongswan源码安装 网上没有一个完整版本的安装教程,只能看官方英文文档,折腾数周,成功编译.现附上安装历程供大家参考.有问题可以互相讨论. windows支持strongs ...

最新文章

  1. 直接可以拿去用的正则验证表达式
  2. 全面解读WEB 2.0
  3. PX4原生固件SPI驱动动编写与IMU传感器替换
  4. 天鹅给癞蛤蟆的回信[转贴]
  5. 生产力提升! 自己动手自定义Visual Studio 2019的 类创建模板,制作简易版Vsix安装包...
  6. MySQL之慢查询日志和连接管理
  7. iPhone 14 Pro太空黑渲染图曝光:感叹号挖孔+直角边框
  8. selenium基础自学七(获取超链接)
  9. 黑产用“未来武器”破解验证码
  10. 2020.2.19作业单
  11. 安装win10 找不到固态硬盘
  12. 计算机网络笔记(油管FreeCodeCamp)Computer Networking
  13. 英语在线听力翻译器_英语听力翻译app下载-英语听力翻译官方版v2.1.4-upan
  14. 处理数据时,对数据取对数的意义
  15. 北斗时钟同步服务器(卫星授时)应用智慧路灯系统
  16. TMS320F2812中文资料介绍
  17. C#编程学习35:对MDB数据库的操作
  18. 【图像处理】——Python+opencv实现图像的hu不变矩特征提取(含原理、推导过程、应用、代码等)
  19. Scala语言学习-02-实现十进制转换为二进制(Int类型数据)
  20. MacOS下载服务器的文件/文件夹到本地、上传本地文件到服务器

热门文章

  1. 【青水评级】Ultrain超脑链项目分析
  2. 制作镜像实例之healthcheck
  3. c语言整点报时,C语言编写一个简单整点报时工具源代码
  4. Kotlin Flow | SharedFlow和StateFlow详解
  5. impala经验之谈
  6. 小程序上传文字和图片到服务器并保存在数据库
  7. 华为一、二、三面面经
  8. [Ansible系列]ansible tag介绍
  9. svga文件预览_SVGA文件格式——SVGA动画制作和文件转换
  10. 手机能运行linux系统吗,老外继续折腾iPhone 7,成功运行Linux