3
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

WindowsでのOpenCV, PCL(その他いくつか)環境構築メモ (2017/04版)

Last updated at Posted at 2017-04-26

2019/04版の記事を公開しています

2018/04版の記事を公開しています

はじめに

WindowsでのQtとVTK(with Qt)有効な開発環境構築の記録用メモです.CUDAも使えそうなら使う方針で.
主にOpenCV, PCLが使える環境を目指しています.
ライブラリはC:\lib以下に配置することにしました.

今回の環境構築には http://unanancyowen.com/pcl18/ (PCL 1.8.0), http://qiita.com/bodyscrap/items/68b38f58f492bc645da5 (OpenCV3.2+Tensorflow1.0.1) を大いに参考にさせて頂きました.ありがとうございます.

本記事での > 何かコマンド は,PowerShell上での操作の意味です.

システム構成

要素 スペック
CPU Intel Xeon E5-2630v4 x2
RAM 64GB
OS Windows 10 Pro (64bit)
GPU NVIDIA GeForce GT 730

グラボが貧弱なのは予算の都合.
三次元センサとしてEnsensoを使用(予定).

導入するもの

  • 今回の構築で導入
    • TensorFlow 1.0.1
    • Keras 2.0.3
    • Boost 1.64.0
    • Eigen 3.3.3
    • VTK 7.1.1
    • FLANN 1.9.1
    • QHull 2015.2 (7.2.0)
    • OpenCV 3.2.0
    • PCL 1.8.0
    • Bullet 2.86
  • 事前に導入 (後ろ2つは必要に応じて)
    • VS Community 2015 Update 3 (Visual C++を含める)
    • CMake 3.8.0
    • Git for Windows 2.12.2.2
    • Mercurial (tortoisehg-4.1.2)
    • Anaconda 3-4.2.0 (Python 3.5.2)
    • Cuda Tool Kit 8.0.61
    • cuDNN v6.0
    • Qt 5.8
    • HDF5 1.8.18
    • Microsoft MPI 7.0.12437.6
    • Microsoft MPI SDK 7.0.12437.6
    • OpenNI 2.2.0.33 Beta
    • (MATLAB 2016b)
    • (Ensenso SDK 2.0.101)

実際の手順

前準備

事前に導入するものをそれぞれダウンロードしてインストールしておく

TensorFlow 1.0.1, Keras 2.0.3

(参考: http://qiita.com/bodyscrap/items/68b38f58f492bc645da5)

管理者権限で > pip install tensorflow-gpu keras

bzip2 1.0.6 (ソースだけ)

  1. C:\lib\bzip2を作成
  2. http://www.bzip.org/downloads.html からソースをダウンロードしてC:\lib\bzip2\srcに解凍

zlib 1.2.11 (ソースだけ)

  1. C:\lib\zlibを作成
  2. http://zlib.net/ からソースをダウンロードしてC:\lib\zlib\srcに解凍

Boost 1.64.0

(参考: https://gist.github.com/UnaNancyOwen/d879a41710e9c05025f8)

  1. C:\lib\boost\を作成

  2. http://www.boost.org/users/download/ からソースをダウンロード,C:\lib\boost\srcに解凍

  3. C:\lib\boost\srcに移動

  4. https://github.com/boostorg/mpi/pull/39 を参考に次のファイルを書き換え

    • include/boost/mpi/detail/mpi_datatype_primitive.hpp
    • include/boost/mpi/detail/packed_iprimitive.hpp
    • include/boost/mpi/detail/packed_oprimitive.hpp
  5. > bootstrap.bat

  6. project-config.jamに以下を追記

    using mpi ;
    
  7. > ./b2.exe toolset=msvc-14.0 address-model=64 --build-dir="C:\lib\boost\build" -s BZIP2_SOURCE="C:\lib\bzip2\src" -s ZLIB_SOURCE="C:\lib\zlib\src" -j38
    (-jで並列数指定,コア数より少なく設定する)

  8. > ./b2.exe toolset=msvc-14.0 address-model=64 --build-dir="C:\lib\boost\build" install --prefix="C:\lib\boost\install"

  9. project-config.jamの

    using mpi ;
    

    を削除し以下を追記

    using python : 3.5 : "C:\\Program Files\\Anaconda3" : "C:\\Program Files\\Anaconda3\\include" : "C:\\Program Files\\Anaconda3\\libs" : ;
    
  10. > ./b2.exe toolset=msvc-14.0 address-model=64 --build-dir="C:\lib\boost\build" -j38

  11. > ./b2.exe toolset=msvc-14.0 address-model=64 --build-dir="C:\lib\boost\build" install --prefix="C:\lib\boost\install"

  12. 環境変数 %BOOST_ROOT% を C:\lib\boost\install に設定

Eigen 3.3.3

(参考: https://gist.github.com/UnaNancyOwen/08e5a9b8f5979ed0077c)

  1. C:\lib\eigen\を作成し移動
  2. > hg clone https://bitbucket.org/eigen/eigen/ src
  3. CMake
    • src: C:\lib\eigen\src
    • build: C:\lib\eigen\build
  4. Configure (変更点のみ.各自の環境に合わせて確認する)
    • CMAKE_INSTALL_PREFIX: C:/lib/eigen/install/
  5. Generate & Open Project
  6. DebugでALL_BUILD, INSTALLを順にビルド
  7. ReleaseでALL_BUILD, INSTALLを順にビルド
  8. 環境変数 %EIGEN_ROOT% を C:\lib\eigen\install に設定

VTK 7.1.1

(参考: https://gist.github.com/UnaNancyOwen/9d16060714ba9b28f90e)

  1. C:\lib\vtk\を作成し移動

  2. > git clone https://github.com/Kitware/VTK.git src

  3. > cd src

  4. > git checkout v7.1.1

  5. build\GUISupport\Qt\PluginInstall.cmake の5行目を

    IF(BUILD_TYPE MATCHES Debug)
      SET(VTK_INSTALL_QT_PLUGIN_FILE "QVTKWidgetPlugin-gd.dll")
    ELSE()
      SET(VTK_INSTALL_QT_PLUGIN_FILE "QVTKWidgetPlugin.dll")
    ENDIF()
    

    に書き換え.
    (参考: https://gist.github.com/UnaNancyOwen/77d61f9f21376c9b59fc#build)

  6. CMake

    • src: C:\lib\vtk\src
    • build: C:\lib\vtk\build
  7. Configure (変更点のみ.各自の環境に合わせて確認する)

    • CMAKE_DEBUG_POSTFIX: _d
    • BUILD_TESTING: no
    • CMAKE_CXX_MP_FLAG: yes
    • CMAKE_INSTALL_PREFIX: C:/lib/vtk/install
    • VTK_RENDERING_BACKEND: OpenGL
    • VTK_PYTHON_VERSION: 3
    • VTK_GROUP_Qt: yes
    • VTK_WRAP_PYTHON: yes
    • VTK_QT_VERSION: 5
    • QT_QMAKE_EXECUTABLE: C:/Qt/5.8/msvc2015_64/bin/qmake.exe
    • Qt5_*: C:/Qt/5.8/msvc2015_64/lib/cmake/*
  8. Generate & Open Project

  9. DebugでALL_BUILD, INSTALLを順にビルド

  10. ReleaseでALL_BUILD, INSTALLを順にビルド

  11. 環境変数 %VTK_DIR% を C:\lib\vtk\install に設定

  12. Pathに C:\lib\vtk\install\bin を追加

FLANN 1.9.1

(参考: https://gist.github.com/UnaNancyOwen/1e3fced09e4430ad0b7b/revisions)

  1. C:\lib\flann\ を作成し移動
  2. > git clone git://github.com/mariusmuja/flann.git src
  3. > cd src
  4. > git checkout 1.9.1
  5. CMake
    src: C:\lib\flann\src
    build: C:\lib\flann\build
  6. Configure (変更点のみ.各自の環境に合わせて確認する)
    • CMAKE_DEBUG_POSTFIX: _d
    • CMAKE_INSTALL_PREFIX: C:/lib/flann/install
    • BUILD_MATLAB_BINDINGS: no
    • BUILD_PYTHON_BINDINGS: no
    • BUILD_EXAMPLES: no
  7. Generate & Open Project
  8. DebugでALL_BUILD, INSTALLを順にビルド
  9. ReleaseでALL_BUILD, INSTALLを順にビルド
  10. 環境変数 %FLANN_ROOT% を C:\lib\flann\install に設定
  11. Pathに C:\lib\flann\install を追加

QHull 2015.2 (7.2.0)

(参考: https://gist.github.com/UnaNancyOwen/ffbe6b05ee0101620d3c)

  1. C:\lib\qfull\ を作成し移動
  2. > git clone https://github.com/qhull/qhull.git src
  3. > cd src
  4. > git checkout 5a79a0009454c86e9848646b3c296009125231bf (2015.2 (7.2.0)), tagなどがないのでHash値で指定
  5. CMake
    • src: C:\lib\qfull\src
    • build: C:\lib\qfull\build
  6. Configure (変更点のみ.各自の環境に合わせて確認する)
    • CMAKE_DEBUG_POSTFIX: _d
    • CMAKE_INSTALL_PREFIX: C:/lib/qfull/install
  7. Generate & Open Project
  8. DebugでALL_BUILD, INSTALLを順にビルド
  9. ReleaseでALL_BUILD, INSTALLを順にビルド
  10. 環境変数%QHULL_ROOT%: C:\lib\qfull\install
  11. PathにC:\lib\qhull\install\binを追加

OpenCV 3.2.0

(参考: http://qiita.com/bodyscrap/items/68b38f58f492bc645da5)
(参考: http://qiita.com/emakryo/items/5e2c79c2a18e60dd212f)

  1. C:\lib\opencv\ を作成し移動
  2. > git clone https://github.com/Itseez/opencv.git src
  3. > cd src
  4. > git checkout 3.2.0
  5. > cd ..
  6. > git clone https://github.com/Itseez/opencv_contrib.git src_contrib
  7. > git checkout 3.2.0
  8. opencv\src_contrib\modules\cvv\src\stfl\stringutils.cpp の77行目-79行目のウムラウト文字を適当に置き換え or コメントアウト (参考: http://qiita.com/fukushima1981/items/fae7d40123bfdf426624)
  9. CMake
    • src: C:\lib\opencv\src
    • build: C:\lib\opencv\build
  10. Configure (変更点のみ.各自の環境に合わせて確認する)
    • CMAKE_DEBUG_POSTFIX: _d
    • CMAKE_INSTALL_PREFIX: C:/lib/opencv/install
    • CUDA_ARCH_BIN: 3.5
    • BUILD_PERF_TESTS no
    • TBB_ENV_INCLUDE: C:\lib\tbb\install\include
    • TBB_ENV_LIB: C:\lib\tbb\install\lib\intel64\vc14\tbb.lib
    • TBB_ENV_LIB_DEBUG: C:\lib\tbb\install\lib\intel64\vc14\tbb_debug.lib
    • TBB_VER_FILE: C:\lib\tbb\install\include\tbb\tbb_stddef.h
    • WITH_CUDA yes
    • WITH_EIGEN yes
    • WITH_TBB yes
    • WITH_QT yes
    • WITH_OPENNI2 yes
    • OPENCV_EXTRAMODELUES_PATH: C:\lib\opencv\src_contrib\modules
    • Qt5*_DIR: C:/Qt/5.8/msvc2015_64/lib/cmake/*
    • EIGEN_INCLUDE_PATH: C:/lib/eigen/install/include/eigen3
  11. Generate & Open Project
  12. DebugでALL_BUILD, INSTALLを順にビルド
  13. ReleaseでALL_BUILD, INSTALLを順にビルド (必要なら管理者権限でVisual Studioを起動)
  14. 環境変数 %OPENCV_DIR% を C:\lib\opencv\install に設定
  15. Pathに C:\lib\opencv\install\bin と C:\lib\opencv\install\x64\vc14\bin を追加

PCL 1.8.0

  1. C:\lib\pcl\を作成し移動
  2. > git clone https://github.com/PointCloudLibrary/pcl.git src
  3. > cd src
  4. > git checkout pcl-1.8.1
    %1. C:\lib\pcl\src\surface\include\pcl\surface\impl\bilateral_upsampling.hpp 119行目を以下に変更(以前のバージョンでの記述)
    %
    % % float val_exp_rgb = expf (- d_color * d_color / (2.0f * sigma_color_ * sigma_color_)); % ```` % %1. io/src/ensenso_grabber.cppの464行目と509行目の `uint` を `unsigned int` に変更 %1. visualization/src/pcl_visualizer.cppに対して %https://github.com/PointCloudLibrary/pcl/commit/8710ee9b6c3ef236a84450ab9fd1f8f167c87a56 を適用 %1. registration\include\pcl\registration\impl\ndt_2d.hppの361行目に以下を追加 (参考: http://www.pcl-users.org/Compiling-PCL-1-8-with-visual-studio-2013-td4043387.html) % %
    % typedef double Literal;
    % % %1. gpu\people\src\cuda\nvidia\NPP_staging.cu 2073行目を以下に変更 %(参考: https://github.com/PointCloudLibrary/pcl/issues/1674) % %
    % #if ((defined CUDA_ARCH) && (CUDA_ARCH < 200))
    % % %1. PCLConfig.cmake.inの89行目を以下に変更 %(参考: https://github.com/PointCloudLibrary/pcl/pull/1856) % %
    % "@Boost_MAJOR_VERSION@.@Boost_MINOR_VERSION@.@Boost_SUBMINOR_VERSION@" %"@Boost_MAJOR_VERSION@.@Boost_MINOR_VERSION@"
    % "1.64.0" "1.64" "1.63.0" "1.63" "1.62.0" "1.62" "1.61.0" "1.61" "1.60.0" "1.60"
    % "1.59.0" "1.59" "1.58.0" "1.58" "1.57.0" "1.57" "1.56.0" "1.56" "1.55.0" "1.55"
    % "1.54.0" "1.54" "1.53.0" "1.53" "1.52.0" "1.52" "1.51.0" "1.51"
    % "1.50.0" "1.50" "1.49.0" "1.49" "1.48.0" "1.48" "1.47.0" "1.47")
    % ```
    %
  5. CMake
    • src: C:\lib\pcl\src
    • build: C:\lib\pcl\build
  6. Configure (変更点のみ.各自の環境に合わせて確認する)
    • CMAKE_DEBUG_POSTFIX: _d
    • CMAKE_INSTALL_PREFIX: C:/lib/pcl/install
    • WITH_ENSENSO: yes
    • WITH_QT: yes
    • Qt5*_DIR: C:/Qt/5.8/msvc2015_64/lib/cmake/*
    • BUILD_CUDA: yes
    • BUILD_GPU: yes
    • BUILD_apps: yes
    • BUILD_examples: yes
    • BUILD_cuda_apps: yes
    • BUILD_cuda_io: yes
    • BUILD_gpu_kinfu: yes
    • BUILD_gpu_kinfu_large_scale: yes
    • BUILD_gpu_people: yes
    • BUILD_gpu_surface: yes
    • BUILD_gpu_tracking: yes
    • BUILD_apps_modeler: yes
    • BUILD_apps_point_cloud_editor: yes
    • BUILD_apps_cloud_composer: no
    • BUILD_apps_3d_rec_framework: no
    • BUILD_apps_in_hand_scanner: no
    • BUILD_apps_optronic_viewer: no
    • CUDA_ARCH_BIN: 3.5
  7. Generate & Open Project
  8. DebugでALL_BUILD, INSTALLを順にビルド
  9. ReleaseでALL_BUILD, INSTALLを順にビルド
  10. 環境変数 %PCL_ROOT% を C:\lib\pcl\install に設定
  11. Pathに C:\lib\pcl\install\bin を追加

Bullet 2.86

  1. C:\lib\bullet\を作成し移動
  2. > git clone https://github.com/bulletphysics/bullet3.git src
  3. > cd src
  4. > git checkout 2.86.1
  5. CMake
    • src: C:\lib\bullet\src
    • build: C:\lib\bullet\build
  6. Configure
    • CMAKE_INSTALL_PREFIX: C:/lib/bullet/install
    • INSTALL_LIBS: yes
    • INSTALL_EXTRA_LIBS: yes
    • USE_MSVC_RUNTIME_LIBRARY_DLL: yes
  7. Generate & Open Project
  8. DebugでALL_BUILD, INSTALLを順にビルド
  9. ReleaseでALL_BUILD, INSTALLを順にビルド
  10. 環境変数 %BULLET_ROOT% を C:\lib\bullet\install に設定
3
5
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
3
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?