LoginSignup
22
18

More than 5 years have passed since last update.

Visual Studio 2013/2015によるOpenCV3.1のコンパイル

Last updated at Posted at 2015-12-31

リンク

Visual Studio2015を使ったOpenCV3.2に関する最新の情報はこちら

はじめに

OpenCV3.1拡張機能(contrib)をgithubからダウンロードして,ソースからcmakeでslnを作ってVisual Studio2013/2015でコンパイルしたときのメモ.主要な外部ライブラリも組み込み済み.

実行環境は以下のとおり.

  • OS: Windows 7 64 bit
  • コンパイラ: Visual Studio2013/2015
  • 外部ライブラリ
    • Qt5.4.2,
    • VTK6.2.0
    • Eigen3.2.6
    • CUDA 7.5

特記事項

  • 新たに追加されたsfmモジュールは,現状,公式にWindowsではコンパルできない.詳細は公式のドキュメント
  • Visual Studio 2015の場合はCuda関連モジュールがコンパイルできない.

Visual Studio 2013の場合

OpenCV3.0の前回と同じ流れで必要ファイルを用意して,cmakeでコンパイル.

OpenCVのcmakeの詳しいやりかたはこちら

変更点として,TBBは現在のVisual Studio環境ではあまり効果的では無いのでVisual StudioデフォルトのConcurrencyを使うことにした(参考記事).

cmake関係

  • with Qtにチェック
    • QtのGUIがないとまともな開発がつらいので必須.ズームできたり,画像の保存がクリックが出来たり,トラックバーがコンパクトになったり,デフォルトと比べて格段に使いやすい.
  • with Eigenにチェック
    • calib3d周りの関数でEigenの関数を使うようになる.(これまでは,EigenとOpenCVのMatrix形式変換くらいしか関数が無かった)
  • GPUのcapabilityを限定する
    • 必要なcapabilityだけを指定できればコンパイル時間が減らせる.(参考記事)

Visual Studio 2015の場合

  • CUDAなしは2013と同様に実行して成功
  • CUDAありは失敗.現在(2016/01/01),最新のCUDA7.5はVisual Studio2015に対応していないため,with CUDAでコンパイルできない.
  • VTKとQtは2013でコンパイルしたlibとdllをそのまま使った.Visual Studio2013のランタイムライブラリが入っていれば動く.

環境を変えるときのチェックリスト

  1. CUDAの確認
  2. Qtの確認.自力コンパイルを避けるためにQt with OpenGLがダウンロードできるか確認
  3. VTKの確認.上記でコンパイルできるかどうか.(現状,自分はVTKが無くても困らない)
  4. TBBの確認(Visual StudioデフォルトのConcurrencyで十分なため無くてもOK)

cmakeの出力

2015の例.※ただしCUDAは失敗する.

found IPP (ICV version): 9.0.1 [9.0.1]
at: C:/opencv-3.1.0/3rdparty/ippicv/unpack/ippicv_win
CUDA detected: 7.5
CUDA NVCC target flags: -gencode;arch=compute_30,code=sm_30;-gencode;arch=compute_30,code=compute_30
To enable PlantUML support, set PLANTUML_JAR environment variable or pass -DPLANTUML_JAR=<filepath> option to cmake
Could NOT find PythonInterp: Found unsuitable version "2.7.5", but required is at least "3.4" (found C:/Python27/python.exe)
Could NOT find PythonInterp: Found unsuitable version "2.7.5", but required is at least "3.2" (found C:/Python27/python.exe)
Could NOT find JNI (missing:  JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) 
Could NOT find Matlab (missing:  MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_ROOT_DIR MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN) 
Found VTK ver. 6.2.0 (usefile: C:/VTK/lib/cmake/vtk-6.2/UseVTK.cmake)
Caffe:   NO
Protobuf:   NO
Glog:   NO
Could NOT find HDF5 (missing:  HDF5_LIBRARIES HDF5_INCLUDE_DIRS) 
Checking SFM deps... TRUE
CERES support is disabled. Ceres Solver for reconstruction API is required.
Tesseract:   NO
Could NOT find PROTOBUF (missing:  PROTOBUF_LIBRARY PROTOBUF_INCLUDE_DIR) 
Build libprotobuf from sources:
    libprotobuf not found into system
    The protocol buffer compiler not found
Tesseract:   NO
CMake Warning (dev) in modules/cvv/CMakeLists.txt:
  Policy CMP0020 is not set: Automatically link Qt executables to qtmain
  target on Windows.  Run "cmake --help-policy CMP0020" for policy details.
  Use the cmake_policy command to set the policy and suppress this warning.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) in modules/highgui/CMakeLists.txt:
  Policy CMP0020 is not set: Automatically link Qt executables to qtmain
  target on Windows.  Run "cmake --help-policy CMP0020" for policy details.
  Use the cmake_policy command to set the policy and suppress this warning.
This warning is for project developers.  Use -Wno-dev to suppress it.


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

  Platform:
    Host:                        Windows 6.1.7601 AMD64
    CMake:                       3.4.0-rc1
    CMake generator:             Visual Studio 14 2015 Win64
    CMake build tool:            C:/Program Files (x86)/MSBuild/14.0/bin/MSBuild.exe
    MSVC:                        1900

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe  (ver 19.0.23506.0)
    C++ flags (Release):         /DWIN32 /D_WINDOWS /W4 /GR /EHa  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /wd4251 /wd4324 /wd4275 /wd4589 /MP24  /MD /O2 /Ob2 /D NDEBUG  /Zi
    C++ flags (Debug):           /DWIN32 /D_WINDOWS /W4 /GR /EHa  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /wd4251 /wd4324 /wd4275 /wd4589 /MP24  /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1 
    C Compiler:                  C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/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    /MP24  /MD /O2 /Ob2 /D NDEBUG  /Zi
    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    /MP24  /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1 
    Linker flags (Release):      /machine:x64  /INCREMENTAL:NO  /debug
    Linker flags (Debug):        /machine:x64  /debug /INCREMENTAL 
    Precompiled headers:         YES
    Extra dependencies:          comctl32 gdi32 ole32 setupapi ws2_32 Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Test Qt5::Concurrent Qt5::OpenGL vfw32 vtkRenderingOpenGL vtkImagingHybrid vtkIOImage vtkCommonDataModel vtkCommonMath vtkCommonCore vtksys vtkCommonMisc vtkCommonSystem vtkCommonTransforms vtkCommonExecutionModel vtkDICOMParser vtkIOCore vtkzlib vtkmetaio vtkjpeg vtkpng vtktiff vtkImagingCore vtkRenderingCore vtkCommonColor vtkFiltersExtraction vtkFiltersCore vtkFiltersGeneral vtkCommonComputationalGeometry vtkFiltersStatistics vtkImagingFourier vtkalglib vtkFiltersGeometry vtkFiltersSources vtkInteractionStyle vtkRenderingLOD vtkFiltersModeling vtkIOPLY vtkIOGeometry vtkjsoncpp vtkFiltersTexture vtkRenderingFreeType vtkfreetype vtkftgl vtkIOExport vtkRenderingAnnotation vtkImagingColor vtkRenderingContext2D vtkRenderingGL2PS vtkRenderingContextOpenGL vtkgl2ps vtkRenderingLabel glu32 opengl32 cudart nppc nppi npps cufft -LC:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v7.5/lib/x64
    3rdparty dependencies:       libprotobuf zlib libjpeg libwebp libpng libtiff libjasper IlmImf

  OpenCV modules:
    To be built:                 cudev core cudaarithm flann imgproc ml reg surface_matching video viz cudabgsegm cudafilters cudaimgproc cudawarping dnn fuzzy imgcodecs photo shape videoio cudacodec highgui objdetect plot ts xobjdetect xphoto bgsegm bioinspired dpm face features2d line_descriptor saliency text calib3d ccalib cudafeatures2d cudalegacy cudaobjdetect cudaoptflow cudastereo cvv datasets rgbd stereo structured_light superres tracking videostab xfeatures2d ximgproc aruco optflow stitching
    Disabled:                    contrib_world python2 sfm world
    Disabled by dependency:      -
    Unavailable:                 hdf java matlab python3

  Windows RT support:            NO

  GUI: 
    QT 5.x:                      YES (ver 5.4.2)
    QT OpenGL support:           YES (Qt5::OpenGL 5.4.2)
    OpenGL support:              YES (glu32 opengl32)
    VTK support:                 YES (ver 6.2.0)

  Media I/O: 
    ZLib:                        build (ver 1.2.8)
    JPEG:                        build (ver 90)
    WEBP:                        build (ver 0.3.1)
    PNG:                         build (ver 1.6.19)
    TIFF:                        build (ver 42 - 4.0.2)
    JPEG 2000:                   build (ver 1.900.1)
    OpenEXR:                     build (ver 1.7.1)
    GDAL:                        NO

  Video I/O:
    Video for Windows:           YES
    DC1394 1.x:                  NO
    DC1394 2.x:                  NO
    FFMPEG:                      YES (prebuilt binaries)
      codec:                     YES (ver 56.41.100)
      format:                    YES (ver 56.36.101)
      util:                      YES (ver 54.27.100)
      swscale:                   YES (ver 3.1.101)
      resample:                  NO
      gentoo-style:              YES
    GStreamer:                   NO
    OpenNI:                      NO
    OpenNI PrimeSensor Modules:  NO
    OpenNI2:                     NO
    PvAPI:                       NO
    GigEVisionSDK:               NO
    DirectShow:                  YES
    Media Foundation:            NO
    XIMEA:                       NO
    Intel PerC:                  NO

  Parallel framework:            Concurrency

  Other third-party libraries:
    Use IPP:                     9.0.1 [9.0.1]
         at:                     C:/opencv-3.1.0/3rdparty/ippicv/unpack/ippicv_win
    Use IPP Async:               NO
    Use Eigen:                   YES (ver 3.2.6)
    Use Cuda:                    YES (ver 7.5)
    Use OpenCL:                  YES
    Use custom HAL:              NO

  NVIDIA CUDA
    Use CUFFT:                   YES
    Use CUBLAS:                  NO
    USE NVCUVID:                 NO
    NVIDIA GPU arch:             30
    NVIDIA PTX archs:            30
    Use fast math:               NO

  OpenCL:
    Version:                     dynamic
    Include path:                C:/opencv-3.1.0/3rdparty/include/opencl/1.2 C:/Program Files (x86)/AMD/clAmdFft/include C:/Program Files (x86)/AMD/clAmdBlas/include
    Use AMDFFT:                  YES
    Use AMDBLAS:                 YES

  Python 2:
    Interpreter:                 C:/Python27/python.exe (ver 2.7.5)

  Python 3:
    Interpreter:                 NO

  Python (for build):            C:/Python27/python.exe

  Java:
    ant:                         NO
    JNI:                         NO
    Java wrappers:               NO
    Java tests:                  NO

  Matlab:                        Matlab not found or implicitly disabled

  Documentation:
    Doxygen:                     C:/Program Files/doxygen/bin/doxygen.exe (ver 1.8.10)
    PlantUML:                    NO

  Tests and samples:
    Tests:                       YES
    Performance tests:           YES
    C/C++ Examples:              NO

  Install path:                  C:/opencv-3.1.0/build/install

  cvconfig.h is in:              C:/opencv-3.1.0/build
-----------------------------------------------------------------
22
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22
18