当前位置:   article > 正文

OpenCV 4.x API 详解与C++实例-OpenCV开发环境搭建_opencv + sfm 配置 eigen3_dir

opencv + sfm 配置 eigen3_dir

第二节 OpenCV开发环境搭建

1、硬件环境

CPU:Intel Core I7-9750H

GPU:Nvidia-Geforce RTX2060

OS:Windows 10 pro x64

硬盘:SSD 1TB

内存:32GB

2、开发工具

1)Visual Studio 2019 pro

2)Qt 5.15.2

3)CMake 3.19.1

4)Git for windows

5)Anoconda 3

6)JDK 8

7)Apache Ant

8)Visual Studio Code

下载并安装好上述工具

3、依赖库

1)TBB
2)Eigen
3)glog
4)gflags
5)Tesseract
6)leptonica
7)freetype2
8)harfbuzz
9)hdf5
10)Nvidia CUDA Toolkit 10.1
11)Nvidia CUDNN 7.6.1
12)VTK 8.2
13)OpenNI2

下载并编译好上述依赖库,或网上搜索已经编译好的库。

4、OpenCV源码下载

1)下载OpenCV源码:git clone https://github.com/opencv/opencv

2)下载OpenCV Contrib源码:git clone https://github.com/opencv/opencv_contrib

本文使用OpenCV版本为4.5.0。

5、OpenCV源码编译

定位到OpenCV源码目录,创建build文件夹,打开CMake gui,如下图

在这里插入图片描述

在这里插入图片描述

接下来逐个模块配置:

1)、关闭BUILD_PERF_TESTBUILD_TEST选项

2)、开启WITH_TBBWITH_CUDAWITH_OPENGLWITH_VTKOPENCV_ENABLE_NONFREE

3)、配置OPENCV_EXTRA_MODULES_PATH

再次点击CMake gui的configure按钮进行配置,然后配置各个依赖库:

1)glog库:GLOG_INCLUDE_DIRS、GLOG_LIBS、GLOG_LIBRARY

在这里插入图片描述

2)gflags库:gflags_DIR

3)TBB库:TBB_ENV_INCLUDE、TBB_ENV_LIB、TBB_VER_FILE

4)Tesseract库:Tesseract_INCLUDE_DIR、Tesseract_LIBRARY、Lept_LIBRARY

5)VTK库:VTK_DIR

6)Eigen库:EIGEN3_DIR

7)Java生成:ANT_EXECUTABLE

再次点击CMake gui的configure按钮,重新生成配置,最终结果如下:

General configuration for OpenCV 4.5.0 =====================================
  Version control:               unknown

  Extra modules:
    Location (extra):            D:/Develop/opensources/machine-vision/opencv_contrib-4.5.0/modules
    Version control (extra):     unknown

  Platform:
    Timestamp:                   2020-12-08T03:04:16Z
    Host:                        Windows 10.0.19042 AMD64
    CMake:                       3.19.1
    CMake generator:             Visual Studio 16 2019
    CMake build tool:            C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/MSBuild/Current/Bin/MSBuild.exe
    MSVC:                        1928

  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:                C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe  (ver 19.28.29333.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:                  C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.28.29333/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 nppicom.lib nppidei.lib nppif.lib nppig.lib nppim.lib nppist.lib nppisu.lib nppitc.lib npps.lib cublas.lib cudnn.lib cufft.lib -LIBPATH:C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1/lib/x64
    3rdparty dependencies:

  OpenCV modules:
    To be built:                 alphamat 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 freetype fuzzy gapi hdf hfs highgui img_hash imgcodecs imgproc intensity_transform java line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot python3 quality rapid reg rgbd saliency sfm shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab viz xfeatures2d ximgproc xobjdetect xphoto
    Disabled:                    world
    Disabled by dependency:      -
    Unavailable:                 cnn_3dobj cvv js julia matlab ovis python2
    Applications:                tests perf_tests apps
    Documentation:               NO
    Non-free algorithms:         YES

  Windows RT support:            NO

  GUI: 
    Win32 UI:                    YES
    OpenGL support:              YES (opengl32 glu32)
    VTK support:                 YES (ver 8.2.0)

  Media I/O: 
    ZLib:                        build (ver 1.2.11)
    JPEG:                        build-libjpeg-turbo (ver 2.0.5-62)
    WEBP:                        build (ver encoder: 0x020f)
    PNG:                         build (ver 1.6.37)
    TIFF:                        build (ver 42 - 4.0.10)
    JPEG 2000:                   build (ver 2.3.1)
    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
    Media Foundation:            YES
      DXVA:                      YES

  Parallel framework:            TBB (ver 2020.2 interface 11102)

  Trace:                         YES (with Intel ITT)

  Other third-party libraries:
    Intel IPP:                   2020.0.0 Gold [2020.0.0]
           at:                   D:/Develop/opensources/machine-vision/opencv-4.5.0/build/3rdparty/ippicv/ippicv_win/icv
    Intel IPP IW:                sources (2020.0.0)
              at:                D:/Develop/opensources/machine-vision/opencv-4.5.0/build/3rdparty/ippicv/ippicv_win/iw
    Lapack:                      NO
    Eigen:                       YES (ver 3.3.7)
    Custom HAL:                  NO
    Protobuf:                    build (3.5.1)

  NVIDIA CUDA:                   YES (ver 10.1, CUFFT CUBLAS)
    NVIDIA GPU arch:             30 35 37 50 52 60 61 70 75
    NVIDIA PTX archs:

  cuDNN:                         YES (ver 7.6.1)

  OpenCL:                        YES (NVD3D11)
    Include path:                D:/Develop/opensources/machine-vision/opencv-4.5.0/3rdparty/include/opencl/1.2
    Link libraries:              Dynamic load

  Python 3:
    Interpreter:                 C:/Users/jenson/Anaconda3/python.exe (ver 3.7.4)
    Libraries:                   C:/Users/jenson/Anaconda3/libs/python37.lib (ver 3.7.4)
    numpy:                       C:/Users/jenson/Anaconda3/lib/site-packages/numpy/core/include (ver 1.18.3)
    install path:                C:/Users/jenson/Anaconda3/Lib/site-packages/cv2/python-3.7

  Python (for build):            C:/Users/jenson/Anaconda3/python.exe

  Java:                          
    ant:                         E:/toolchain/apache-ant-1.10.7/bin/ant.bat (ver 1.10.7)
    JNI:                         C:/Program Files/Java/jdk1.8.0_181/include C:/Program Files/Java/jdk1.8.0_181/include/win32 C:/Program Files/Java/jdk1.8.0_181/include
    Java wrappers:               YES
    Java tests:                  YES

  Install to:                    D:/Develop/opensources/machine-vision/opencv-4.5.0/build/install
-----------------------------------------------------------------

Configuring done
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127

点击CMake gui的generate按钮,生成工程文件,然后再点击open project 按钮,打开工程并编译和安装。编译的结果如下:

在这里插入图片描述

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/119758?site
推荐阅读
相关标签
  

闽ICP备14008679号