Open3Dでのポイントクラウド

このページは以前のファームウェアリリースについて説明しています。 このページを最新リリースで読む
このページは自動翻訳されたもので、まだレビューされていません。内容に相違がある場合は、英語の原文が優先されます。 英語の原文を読む

センサーのポイントクラウドを Open3Dで表示します。 これらの例は Pythonライブラリを使用し、アプリケーションキーでサインインします。qb2-xxxxxxxxx をお使いのセンサーのホスト名またはIPアドレスに、application-key-for-qb2-xxxxxxxxx をキーのシークレットに置き換えてください。

まずOpen3Dをインストールします。

pip install open3d

ポイントクラウドフレームを取得します。

import blickfeld_qb2

token_factory = blickfeld_qb2.TokenFactory(application_key_secret="application-key-for-qb2-xxxxxxxxx")

# Open a secure and authenticated connection to the sensor
with blickfeld_qb2.Channel(fqdn_or_ip="qb2-xxxxxxxxx", token=token_factory) as channel:
    service = blickfeld_qb2.core_processing.services.PointCloud(channel)

    frame = service.get().frame

    # Print the frame ID
    print("Received frame with ID:", frame.id)

その frame の各ポイントの直交座標と強度を取得します。強度は0から1のグレー値になります。

import numpy as np
import open3d as o3d

# Create a point cloud object
pcd = o3d.geometry.PointCloud()

# Get the cartesian coordinates from the point cloud frame
pcd.points = o3d.utility.Vector3dVector(frame.binary.cartesian)

# Convert the intensity values to grey values, brightened and clipped to the range 0 to 1 of Open3D
grey = np.clip(frame.binary.photon_count / np.iinfo(np.uint16).max * 20, 0, 1)

# Open3D expects RGB colors, thus the same value is repeated for red, green and blue
pcd.colors = o3d.utility.Vector3dVector(np.repeat(grey, 3).reshape((-1, 3)))

ポイントクラウド pcd をファイルに保存して表示します。

# Save the point cloud to file
o3d.io.write_point_cloud("demo.pcd", pcd)

# Visualize the point cloud
o3d.visualization.draw_geometries([pcd])

ウィンドウ内の表示はマウスで回転できます。draw_geometries のパラメーター front、lookat、up、zoom は、ウィンドウが開く前のカメラを設定します。