Open3D のインストール

概要

複数の写真から3次元の立体を構成する技術や,レーザー光線などで3次元の対象を直接計測する技術がある。これらでは,3次元点群(点の集まり)のデータが得られる。各点は x, y, z の 3 つの値を持つ。Open3D には,3次元点群について次の機能がある。

目次

関連する外部ページ

前準備

Build Tools for Visual Studio 2026 のインストール(Windows 上) [クリックして展開]

Build Tools for Visual Studio は,Visual Studio の IDE を含まない C/C++ コンパイラ,ライブラリ,ビルドツールなどのコマンドライン向け開発ツールセットである。インストール済みの場合,この手順は不要である。

管理者権限コマンドプロンプトを起動する (手順:Windowsキーまたはスタートメニュー → cmd と入力 → 右クリック → 「管理者として実行」)。

REM VC++ ランタイム
winget install --scope machine --id Microsoft.VCRedist.2015+.x64 -e --silent --disable-interactivity --force --accept-source-agreements --accept-package-agreements --override "/quiet /norestart"

REM Build Tools + Desktop development with C++(VCTools)+ 追加コンポーネント(一括)
winget list --id Microsoft.VisualStudio.BuildTools 2>nul | findstr /i "BuildTools" >nul 2>&1
if %ERRORLEVEL% EQU 0 (
    for /f "delims=" %P in ('"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -products * -property installationPath') do start /wait "" "C:\Program Files (x86)\Microsoft Visual Studio\Installer\setup.exe" modify --installPath "%P" --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Workload.MSBuildTools --add Microsoft.VisualStudio.Component.VC.CMake.Project --add Microsoft.VisualStudio.Component.VC.Llvm.Clang --add Microsoft.VisualStudio.Component.VC.Llvm.ClangToolset --add Microsoft.VisualStudio.Component.Windows11SDK.26100 --includeRecommended --quiet --norestart
) else (
    winget install --scope machine --id Microsoft.VisualStudio.BuildTools -e --silent --disable-interactivity --force --accept-source-agreements --accept-package-agreements --override "--quiet --wait --norestart --nocache --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --add Microsoft.VisualStudio.Workload.MSBuildTools --add Microsoft.VisualStudio.Component.VC.CMake.Project --add Microsoft.VisualStudio.Component.VC.Llvm.Clang --add Microsoft.VisualStudio.Component.VC.Llvm.ClangToolset --add Microsoft.VisualStudio.Component.Windows11SDK.26100"
)
REM  何らかの理由で BuildTools の動作がおかしくなった場合は,以下を実行すると,既存のインストールのファイル破損・欠損を修復し正常な状態に復元する効果がある。
REM "C:\Program Files (x86)\Microsoft Visual Studio\Installer\setup.exe" repair --installPath "C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools" --quiet --norestart
REM 以下で正常であることを確認する。パスが表示されれば正常である。
REM "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -products * -requires Microsoft.VisualStudio.Workload.VCTools -property installationPath

--add で追加されるコンポーネント

上記のコマンドでは,まず Build Tools 本体と Visual C++ 再頒布可能パッケージをインストールし,次に setup.exe を用いて以下のコンポーネントを追加している。

インストール完了の確認

winget list Microsoft.VisualStudio.BuildTools

上記以外の追加のコンポーネントが必要になった場合は Visual Studio Installer で個別にインストールできる。

Visual Studio の機能を必要とする場合は,追加インストールできる。

Python 3.12 のインストール(Windows 上) [クリックして展開]

以下のいずれかの方法で Python 3.12 をインストールする。Python がインストール済みの場合,この手順は不要である。

方法1:winget によるインストール

管理者権限コマンドプロンプトを起動する (手順:Windowsキーまたはスタートメニュー → cmd と入力 → 右クリック → 「管理者として実行」)。

winget install --id Python.Python.3.12 -e --scope machine --silent --accept-source-agreements --accept-package-agreements --override "/quiet InstallAllUsers=1 PrependPath=1 Include_test=0 Include_pip=1 Include_launcher=1 InstallLauncherAllUsers=1 TargetDir=\"C:\Program Files\Python312\""
powershell -Command "$p='C:\Program Files\Python312'; $s=\"$p\Scripts\"; $m=[Environment]::GetEnvironmentVariable('Path','Machine'); if($m -notlike \"*$s*\") { [Environment]::SetEnvironmentVariable('Path', \"$p;$s;$m\", 'Machine') }"

--scope machine を指定することで,システム全体(全ユーザー向け)にインストールされる。このオプションの実行には管理者権限が必要である。インストール完了後,コマンドプロンプトを再起動すると PATH が自動的に設定される。

方法2:インストーラーによるインストール

  1. Python 公式サイト(https://www.python.org/downloads/)にアクセスし,Windows 用インストーラーをダウンロードする。
  2. ダウンロードしたインストーラーを実行する。
  3. 初期画面の下部に表示される「Add python.exe to PATH」に必ずチェックを入れてから「Customize installation」を選択する。このチェックを入れ忘れると,コマンドプロンプトから python コマンドを実行できない。
  4. 「Install Python 3.xx for all users」にチェックを入れ,「Install」をクリックする。

インストールの確認

コマンドプロンプトで以下を実行する。

python --version

バージョン番号(例:Python 3.12.x)が表示されればインストール成功である。「'python' は,内部コマンドまたは外部コマンドとして認識されていません。」と表示される場合は,インストールが正常に完了していない。

Git のインストール(Windows 上)

Git は,バージョン管理システムである。ソースコードの管理や複数人での共同作業に役立つ。

サイト内の関連ページWindows での Git のインストール: 別ページ »で説明

関連する外部ページGit の公式ページ: https://git-scm.com/

CMake のインストール(Windows 上) [クリックして展開]

管理者権限コマンドプロンプトを起動する (手順:Windowsキーまたはスタートメニュー → cmd と入力 → 右クリック → 「管理者として実行」)。

REM CMake をシステム領域にインストール
winget install --scope machine --id Kitware.CMake -e --silent --disable-interactivity --force --accept-source-agreements --accept-package-agreements --override "/qn /norestart ADD_CMAKE_TO_PATH=System"

Open3D のインストール(Windows 上)

http://www.open3d.org/docs/release/compilation.html に記載の手順による。

  1. 以下の手順を管理者権限コマンドプロンプトを起動して実行する (手順:Windowsキーまたはスタートメニュー → cmd と入力 → 右クリック → 「管理者として実行」)。
  2. pip を用いて,Open3D をインストールする。
    python -m pip install -U --no-user open3d
  3. バージョンの確認

    次のコマンドを実行し,「Version」の右に表示されるバージョンを確認する。

    python -m pip show open3d

    関連ファイルもインストールしたいので,以下の手順を続ける。

  4. Open3D 関連ファイルのインストール

    文字コードに起因するエラーを避けるため「/utf-8」を設定する。

    python -m pip install -U --no-user --ignore-installed numpy scikit-image
    cd /d c:%HOMEPATH%
    rmdir /s /q Open3D
    git clone --recursive https://github.com/isl-org/Open3D
    cd Open3D
    del CMakeCache.txt
    rmdir /s /q CMakeFiles
    cmake -A x64 -T host=x64 ^
      -DCMAKE_C_FLAGS="/DWIN32 /D_WINDOWS /W0 /utf-8" ^
      -DCMAKE_CXX_FLAGS="/DWIN32 /D_WINDOWS /GR /EHsc /W0 /utf-8" ^
      -DCMAKE_INSTALL_PREFIX="c:/Open3D" .
    cmake --build . --config Release --target ALL_BUILD
    cmake --build . --config Release --target INSTALL
  5. 確認のため Open3DViewer を起動してみる。起動できれば OK とする。
    %HOMEPATH%\Open3D\Open3D\Release\Open3DViewer.exe
  6. Open3D-ML 関連ファイルのインストール

    次のコマンドを実行する。

    cd /d c:%HOMEPATH%
    rmdir /s /q Open3D-ML
    git clone --recursive https://github.com/isl-org/Open3D-ML
    cd Open3D-ML
    python -m pip install -U --no-user -r requirements.txt
    python -m pip install -U --no-user -r requirements-torch.txt