Point clouds with Open3D
This page documents an earlier firmware release. Read this page for the latest release
Show a point cloud of the sensor in Open3D.
The examples use the Python library and sign in with an application key. Replace qb2-xxxxxxxxx with the hostname or IP address of your sensor and application-key-for-qb2-xxxxxxxxx with the secret of your key.
Install Open3D first:
pip install open3d
Fetch a point cloud frame:
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)
Take the Cartesian coordinates and the intensity of each point of that frame. The intensity becomes a grey value from 0 to 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)))
Save the point cloud pcd to a file and show it:
# Save the point cloud to file
o3d.io.write_point_cloud("demo.pcd", pcd)
# Visualize the point cloud
o3d.visualization.draw_geometries([pcd])
Turn the view in the window with the mouse. The parameters front, lookat, up and zoom of draw_geometries set the camera before the window opens.