赞
踩
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安装并配置
3. 官网下载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: unknown
-
- Extra modules:
- Location (extra): D:/360Downloads/opencv/opencv_contrib-4.5.2/modules
- Version control (extra): unknown
-
- Platform:
- Timestamp: 2021-06-04T01:58:13Z
- Host: Windows 10.0.17763 AMD64
- CMake: 3.20.3
- CMake generator: Visual Studio 16 2019
- CMake build tool: D:/360Downloads/VisualStudio2019/2019/Professional/MSBuild/Current/Bin/MSBuild.exe
- MSVC: 1929
- Configuration: Debug Release
-
- CPU/HW features:
- Baseline: SSE SSE2 SSE3
- requested: SSE3
- Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
- requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
- SSE4_1 (17 files): + SSSE3 SSE4_1
- SSE4_2 (2 files): + SSSE3 SSE4_1 POPCNT SSE4_2
- FP16 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
- AVX (5 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
- AVX2 (31 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
- AVX512_SKX (7 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
-
- C/C++:
- Built as dynamic libs?: YES
- C++ standard: 11
- C++ 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.exe
- C 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: NO
- Precompiled headers: YES
- Extra 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/x64
- 3rdparty 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 xphoto
- Disabled: world
- Disabled by dependency: -
- Unavailable: alphamat cnn_3dobj cvv freetype java julia matlab ovis python2 sfm viz
- Applications: tests perf_tests examples apps
- Documentation: NO
- Non-free algorithms: YES
-
- Windows RT support: NO
-
- GUI:
- Win32 UI: YES
- OpenGL support: YES (opengl32 glu32)
- VTK support: NO
-
- Media 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: YES
- SUNRASTER: YES
- PXM: YES
- PFM: YES
-
- Video I/O:
- DC1394: NO
- FFMPEG: 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: NO
- DirectShow: YES
-
- Parallel framework: Concurrency
-
- Trace: YES (with Intel ITT)
-
- Other third-party libraries:
- Lapack: NO
- Eigen: NO
- Custom HAL: NO
- Protobuf: build (3.5.1)
-
- NVIDIA CUDA: YES (ver 11.3, CUFFT CUBLAS)
- NVIDIA GPU arch: 35 37 50 52 60 61 70 75 80 86
- NVIDIA PTX archs:
-
- cuDNN: YES (ver 8.2.0)
-
- OpenCL: YES (NVD3D11)
- Include path: D:/360Downloads/opencv/sources/3rdparty/include/opencl/1.2
- Link libraries: Dynamic load
-
- ONNX: NO
-
- Python 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.8
-
- Python (for build): D:/360Downloads/Anaconda3/python.exe
-
- Java:
- ant: NO
- JNI: NO
- Java wrappers: NO
- Java tests: NO
-
- Install 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 install
- directory
- Call Stack (most recent call first):
- CMakeLists.txt:1010 (include)
-
-
-
- General configuration for OpenCV 4.5.2 =====================================
- Version control: unknown
-
- Platform:
- Timestamp: 2021-04-09T02:59:22Z
- Host: Windows 10.0.18363 AMD64
- CMake: 3.20.1
- CMake generator: MinGW Makefiles
- CMake build tool: D:/360Downloads/Software/MinGW/mingw64/bin/mingw32-make.exe
- Configuration: Release
-
- CPU/HW features:
- Baseline: SSE SSE2 SSE3
- requested: SSE3
- Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2
- requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
- SSE4_1 (17 files): + SSSE3 SSE4_1
- SSE4_2 (2 files): + SSSE3 SSE4_1 POPCNT SSE4_2
- FP16 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
- AVX (5 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
- AVX2 (31 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
-
- C/C++:
- Built as dynamic libs?: YES
- C++ standard: 11
- C++ 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 -DNDEBUG
- C++ 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_DEBUG
- C Compiler: D:/360Downloads/Software/MinGW/mingw64/bin/gcc.exe
- 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 -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 -DNDEBUG
- C 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_DEBUG
- Linker flags (Release): -Wl,--gc-sections
- Linker flags (Debug): -Wl,--gc-sections
- ccache: NO
- Precompiled headers: NO
- Extra dependencies:
- 3rdparty dependencies:
-
- OpenCV modules:
- To be built: calib3d core dnn features2d flann gapi highgui imgcodecs imgproc ml objdetect photo stitching ts video videoio
- Disabled: python2 world
- Disabled by dependency: -
- Unavailable: java python3
- Applications: tests perf_tests examples apps
- Documentation: NO
- Non-free algorithms: NO
-
- Windows RT support: NO
-
- GUI:
- Win32 UI: YES
- VTK support: NO
-
- Media 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: YES
- SUNRASTER: YES
- PXM: YES
- PFM: YES
-
- Video I/O:
- DC1394: NO
- FFMPEG: 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: NO
- DirectShow: YES
-
- Parallel framework: none
-
- Trace: YES (with Intel ITT)
-
- Other third-party libraries:
- Lapack: NO
- Eigen: NO
- Custom HAL: NO
- Protobuf: build (3.5.1)
-
- OpenCL: YES (no extra features)
- Include path: D:/360Downloads/Software/opencv/sources/3rdparty/include/opencl/1.2
- Link libraries: Dynamic load
-
- Python (for build): D:/Anaconda2/python.exe
-
- Java:
- ant: NO
- JNI: NO
- Java wrappers: NO
- Java tests: NO
-
- Install 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 image
- CommandLineParser 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 it
- cvtColor( src, src_gray, COLOR_BGR2GRAY );
- blur( src_gray, src_gray, Size(3,3) );
-
- /// Create Window
- const 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 Canny
- Mat canny_output;
- Canny( src_gray, canny_output, thresh, thresh*2 );
-
- /// Find contours
- vector<vector<Point> > contours;
- vector<Vec4i> hierarchy;
- findContours( canny_output, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE );
-
- /// Draw contours
- Mat 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 window
- imshow( "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配置文件勾选中,勾选错误
解决办法:
(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
(4)用Visual studio编译OpenCV
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。