open3d.visualization.VisualizerWithVertexSelection
是Open3D提供的用于渲染三维模型并支持交互式选点功能的类。其中的capture_depth_image
方法可以用于捕获深度图像。
深度图像是一种包含相机观察场景中每个点距离的图像。它可以用于姿态估计、三维重建、拓扑结构推导等计算机视觉任务中。
def capture_depth_image(self,
capture_params: Optional[open3d.visualization.VisualizerWithVertexSelection.DepthCaptureParams] = None
) -> Optional[np.ndarray]:
"""
Capture the depth image from the current viewport.
Returns:
np.ndarray: The depth image as a numpy array, or None if no depth information is available for the current
viewport. If available, the size of the depth image will match the viewport size.
"""
capture_params
:用于配置深度图像捕获的参数,类型为open3d.visualization.VisualizerWithVertexSelection.DepthCaptureParams
,非必须。默认值为None。np.ndarray
:如果当前视口有深度信息,则返回当前视口的深度图像作为numpy数组;否则返回None。import open3d as o3d
vis = o3d.visualization.VisualizerWithVertexSelection()
vis.create_window()
mesh = o3d.geometry.TriangleMesh.create_box()
vis.add_geometry(mesh)
depth_image = vis.capture_depth_image()
vis.destroy_window()