open3dのインストールではまったこと

やること

pythonでopen3dをインストールすること

open3dとは?

pythonでPoint Cloudを扱うのに便利なアプリケーション

www.open3d.org

最近話題なので使ってみようと思います。

はまったこと

  • wsl ubuntu16.04LTSでopen3dをインストールするとsegmentation faultが起きる
  • wsl ubuntu16.04LTSでopen3dをインストールするとAttribute errorが出る

google colabratoryではpip install open3dでOKでした

手順

ここからは作業メモになります。
pipでインストールが上手くいかなかったので、makeしようと思います。

git clone --recursive https://github.com/intel-isl/Open3D
~/Open3D/util/scripts/install-deps-ubuntu.sh

コンパイルに必要なモジュールがインストールされる

cd ~/Open3d
mkdir builld
cd build
cmake ..
make -j$(nproc)
make install-pip-package

最後のmakeの出力結果

[  1%] Built target EncodeShader
[  1%] Built target ShaderFileTarget
[  5%] Built target ext_turbojpeg
Custom target build_all_3rd_party_libs reached.
[  5%] Built target build_all_3rd_party_libs
[ 20%] Built target Visualization
[ 27%] Built target qhullstatic_r
[ 29%] Built target tinyobjloader
[ 39%] Built target qhullcpp
[ 41%] Built target jsoncpp
[ 43%] Built target tinyfiledialogs
[ 44%] Built target Camera
[ 46%] Built target ColorMap
[ 60%] Built target Geometry
[ 62%] Built target Integration
[ 63%] Built target Odometry
[ 67%] Built target Registration
[ 70%] Built target Utility
[ 84%] Built target IO
[ 86%] Built target Open3D
[100%] Built target open3d
Scanning dependencies of target python-package
[100%] Built target python-package
Scanning dependencies of target pip-package
running bdist_wheel
running build
running build_py
creating build
creating build/lib
creating build/lib/open3d
copying open3d/__init__.py -> build/lib/open3d
copying open3d/j_visualizer.py -> build/lib/open3d
running egg_info
creating open3d.egg-info
writing dependency_links to open3d.egg-info/dependency_links.txt
writing open3d.egg-info/PKG-INFO
writing top-level names to open3d.egg-info/top_level.txt
writing requirements to open3d.egg-info/requires.txt
writing manifest file 'open3d.egg-info/SOURCES.txt'
reading manifest file 'open3d.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'open3d/open3d*.pyd'
warning: no files found matching 'open3d/*depthengine*'
warning: no files found matching 'open3d/*k4a*'
warning: no files found matching 'open3d/*libstdc*'
warning: no files found matching '*.*' under directory 'open3d/static'
warning: no previously-included files matching '*.py[co]' found anywhere in distribution
writing manifest file 'open3d.egg-info/SOURCES.txt'
copying open3d/open3d.cpython-35m-x86_64-linux-gnu.so -> build/lib/open3d
installing to build/bdist.linux-x86_64/wheel
running install
running install_lib
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/wheel
creating build/bdist.linux-x86_64/wheel/open3d-0.9.0.0.data
creating build/bdist.linux-x86_64/wheel/open3d-0.9.0.0.data/purelib
creating build/bdist.linux-x86_64/wheel/open3d-0.9.0.0.data/purelib/open3d
copying build/lib/open3d/__init__.py -> build/bdist.linux-x86_64/wheel/open3d-0.9.0.0.data/purelib/open3d
copying build/lib/open3d/j_visualizer.py -> build/bdist.linux-x86_64/wheel/open3d-0.9.0.0.data/purelib/open3d
copying build/lib/open3d/open3d.cpython-35m-x86_64-linux-gnu.so -> build/bdist.linux-x86_64/wheel/open3d-0.9.0.0.data/purelib/open3d
running install_data
creating build/bdist.linux-x86_64/wheel/open3d-0.9.0.0.data/data
creating build/bdist.linux-x86_64/wheel/open3d-0.9.0.0.data/data/share
creating build/bdist.linux-x86_64/wheel/open3d-0.9.0.0.data/data/share/jupyter
creating build/bdist.linux-x86_64/wheel/open3d-0.9.0.0.data/data/share/jupyter/nbextensions
creating build/bdist.linux-x86_64/wheel/open3d-0.9.0.0.data/data/share/jupyter/nbextensions/open3d
creating build/bdist.linux-x86_64/wheel/open3d-0.9.0.0.data/data/etc
creating build/bdist.linux-x86_64/wheel/open3d-0.9.0.0.data/data/etc/jupyter
creating build/bdist.linux-x86_64/wheel/open3d-0.9.0.0.data/data/etc/jupyter/nbconfig
creating build/bdist.linux-x86_64/wheel/open3d-0.9.0.0.data/data/etc/jupyter/nbconfig/notebook.d
copying enable_jupyter_extension.json -> build/bdist.linux-x86_64/wheel/open3d-0.9.0.0.data/data/etc/jupyter/nbconfig/notebook.d
running install_egg_info
Copying open3d.egg-info to build/bdist.linux-x86_64/wheel/open3d-0.9.0.0.data/purelib/open3d-0.9.0.0-py3.5.egg-info
running install_scripts
creating build/bdist.linux-x86_64/wheel/open3d-0.9.0.0.dist-info/WHEEL
pip wheel created at /home/shosuke/Open3D/build/lib/python_package/pip_package
[100%] Built target pip-package
Scanning dependencies of target install-pip-package
[100%] Built target install-pip-package

makeが完了し、インストールが終わったように見える。
確認のため以下のコマンドを実行する。

python3 -c "import open3d"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named 'open3d'

インストールできてない?ビルドは成功してそうなのに。。。
とにかく動かしたいので、強硬手段!!

pip3 show pip

でアプリケーションがどこに保存されるか確認し、/usr/lib/python3/dist-packages /にあることが判明。
また、~/Open3D/build/lib/Pythonopen3d.cpython-35m-x86_64-linux-gnu.soといういかにもビルド結果っぽいものを発見。
コピーして直接入れたら使えるのでは??
(pipで管理されないのであんまりよくないと思うけど。。。)
で、コピーしてみました。
すると、、、

python3 -c "import open3d"

を入力して無事に終了しました!
案の定、pip3 list | grep open3dを入力しても出てきませんでした。
~/Open3D/examples/Python/Basic/file_io.pyを実行してみると

Testing IO for point cloud ...
Format = auto
Extension = pcd
geometry::PointCloud with 113662 points.
Testing IO for meshes ...
geometry::TriangleMesh with 1440 points and 2880 triangles.
Testing IO for textured meshes ...
geometry::TriangleMesh with 8 points and 12 triangles, and textures of size (320, 320)
geometry::TriangleMesh with 8 points and 12 triangles, and textures of size (320, 320)
Testing IO for images ...
Image of size 512x512, with 3 channels.
Use numpy.asarray to access buffer data.

無事に実行できました。