python api 官方手册:http://www.open3d.org/docs/release/
可视化:http://www.open3d.org/docs/release/tutorial/visualization/visualization.html
python-vis 参考代码:https://github.com/isl-org/Open3D/tree/master/examples/python/visualization
Open3D-ML:https://github.com/isl-org/Open3D-ML # 基于open3d搞的一个ml项目,可以做一些预测结果&数据的可视化
Visualization 的一些快捷键
鼠标视图控制
- 左键+拖动 # 旋转
- ctrl + 左键+拖动 # 上下左右平移
- shift + 左键+拖动 # 绕垂直屏幕轴玄幻
- 滚轮 # 放大,缩小
键盘控制
- R # 重置view-point,回到打开的初始状态
- ctrl + c # 复制当前的view状态,存到剪切板中
- ctrl + v # 回到剪切板中的view
- Q, Esc # 退出窗口
H : Print help message.
P, PrtScn : Take a screen capture.
D : Take a depth capture.
O : Take a capture of current rendering settings.
ViewControl
python
# init visualizer first
self.o3d_visualizer = o3d.visualization.Visualizer()
self.o3d_visualizer.create_window(visible=False)
mesh_frame = geometry.TriangleMesh.create_coordinate_frame(
size=1, origin=[0, 0, 0]) # create coordinate frame
self.o3d_visualizer.add_geometry(mesh_frame)
# get ViewControl
ctr = self.o3d_visualizer.get_view_control()
# set ViewControl
# refer to http://www.open3d.org/html/python_api/open3d.visualization.ViewControl.html#
# 改变内参来达到缩放的目的, 参考: https://github.com/isl-org/Open3D/issues/828
# get
param = vis.get_view_control().convert_to_pinhole_camera_parameters()
# modify
# ... do something with param, e.g. zoom with changing the intrinsics
# param.intrinsic.intrinsic_matrix # 3x3
# param.extrinsic.view() # 4x4
# 在所有的add_geometry之后做
# 放大2倍
zoom = 0.5
intrinsics = param.intrinsic.intrinsic_matrix.copy()
intrinsics[0] /= zoom
intrinsics[1] /= zoom
intrinsics[0, 2] = 1920 // 2 - 0.5 # 1920, 1080 是 create_window 的尺寸
intrinsics[1, 2] = 1080 // 2 - 0.5
param.intrinsic.intrinsic_matrix = intrinsics
# init_param.extrinsic = self.extrinsics # 如果传入了外参,就是前视图了
# set
ctr.convert_from_pinhole_camera_parameters(param)
ctr.set_zoom(zoom) # 这两个需要绑定才行
self.o3d_visualizer.update_renderer() # 更新渲染器
set_zoom # 缩放
rotate(self, x, y, xo=0.0, yo=0.0) # 鼠标沿着x,y轴移动的距离. x,y为正表示沿着对应的轴正方向移动, 反正沿着负方向移动. 适当的值可以得到立体感。
不打开窗口保存渲染的图片
python
def show(self, save_path=None):
"""Visualize the points cloud.
Args:
save_path (str): path to save image. Default: None.
"""
# self.o3d_visualizer.run()
if save_path is not None:
# self.o3d_visualizer.capture_screen_image(save_path)
self.o3d_visualizer.capture_screen_image(save_path, do_render=True)
self.o3d_visualizer.destroy_window()
return