一组在Windows、Linux和macOS上跨平台支持的3D数据序列可视化和交互工具,可用于 smpl 类型文件的标注任务 。github:https://github.com/eth-ait/aitviewer/tree/main
任务:增加x,y,z正视角移动按钮
1.插入 修改视角逻辑
"aitviewer-main\aitviewer\scene\camera.py"
def change_xyz(self, keys):
# 确定当前相机 距离物体的距离
pos_s = max(abs(self.position))
# 定义每个视角的 position up
dicts = {'x':[[0,0,pos_s],[0,1,0]],
'x-':[[0, 0, -pos_s], [0, 1, 0]],
'y':[[pos_s, 0, 0], [0, 1, 0]],
'y-': [[-pos_s, 0, 0], [0, 1, 0]],
'z': [[0, pos_s,0], [0,0, -1]],
'z+': [[0, pos_s,0], [0,0, 1]],
'z-': [[0, -pos_s ,0], [0, 0, -1]],
'z-+': [[0, -pos_s ,0], [0, 0, 1]],
}
self.position = dicts[keys][0]
self.up = dicts[keys][1]
self.target = [ 0.00083879,-0.30330688 , 0.02280509]
2.加入 窗口及按钮
在 __init__ 在增加
self.xyz_zu = True
self.xyz_zd = True
"aitviewer-main\aitviewer\viewer.py"
def gui_xyz(self):
# 定义窗口位置及大小信息
imgui.set_next_window_position(50, 100 + self.window_size[1] * 0.7, imgui.FIRST_USE_EVER)
imgui.set_next_window_size(self.window_size[0] * 0.1, self.window_size[1] * 0.1, imgui.FIRST_USE_EVER)
# 定义窗口名
expanded, _ = imgui.begin("XYZ", None)
# 定义按钮名
if expanded:
if imgui.button('X'):
self.reset_camera()
self.scene.camera.change_xyz('x')
elif imgui.button('-X'):
self.reset_camera()
self.scene.camera.change_xyz('x-')
elif imgui.button('Y'):
self.reset_camera()
self.scene.camera.change_xyz('y')
elif imgui.button('-Y'):
self.reset_camera()
self.scene.camera.change_xyz('y-')
elif imgui.button('Z'):
if self.xyz_zu:
z_u = 'z'
else:
z_u = 'z+'
self.xyz_zu = not self.xyz_zu
self.reset_camera()
self.scene.camera.change_xyz(z_u)
elif imgui.button('-Z'):
if self.xyz_zd:
z_d = 'z-'
else:
z_d = 'z-+'
self.xyz_zd = not self.xyz_zd
self.reset_camera()
self.scene.camera.change_xyz(z_d)
imgui.end()
3.添加完成