11"""
22# Created: 2023-11-29 21:22
33# Copyright (C) 2023-now, RPL, KTH Royal Institute of Technology
4- # Author: Kin ZHANG (https://kin-zhang.github.io/)
4+ # Author: Qingwen Zhang (https://kin-zhang.github.io/)
55#
66# This work is licensed under the terms of the MIT license.
77# For a copy, see <https://opensource.org/licenses/MIT>.
2222
2323VIEW_FILE = f"{ BASE_DIR } /assets/view/av2.json"
2424
25+ def check_flow (
26+ data_dir : str = "/home/kin/data/av2/preprocess/sensor/mini" ,
27+ flow_mode : str = "flow" , # "flow", "flow_est"
28+ start_id : int = - 1 ,
29+ point_size : float = 3.0 ,
30+ ):
31+ dataset = HDF5Data (data_dir , vis_name = flow_mode , flow_view = True )
32+ o3d_vis = MyVisualizer (view_file = VIEW_FILE , window_title = f"view { 'ground truth flow' if flow_mode == 'flow' else f'{ flow_mode } flow' } , `SPACE` start/stop" )
33+
34+ opt = o3d_vis .vis .get_render_option ()
35+ opt .background_color = np .asarray ([80 / 255 , 90 / 255 , 110 / 255 ])
36+ opt .point_size = point_size
37+
38+ for data_id in (pbar := tqdm (range (0 , len (dataset )))):
39+ # for easy stop and jump to any id, and save same id always from 0.
40+ if data_id < start_id and start_id != - 1 :
41+ continue
42+ data = dataset [data_id ]
43+ now_scene_id = data ['scene_id' ]
44+ pbar .set_description (f"id: { data_id } , scene_id: { now_scene_id } , timestamp: { data ['timestamp' ]} " )
45+ gm0 = data ['gm0' ]
46+ pc0 = data ['pc0' ][~ gm0 ]
47+
48+ pcd = o3d .geometry .PointCloud ()
49+ pcd .points = o3d .utility .Vector3dVector (pc0 [:, :3 ])
50+ pcd .paint_uniform_color ([1.0 , 0.0 , 0.0 ]) # red: pc0
51+
52+ pc1 = data ['pc1' ]
53+ pcd1 = o3d .geometry .PointCloud ()
54+ pcd1 .points = o3d .utility .Vector3dVector (pc1 [:, :3 ][~ data ['gm1' ]])
55+ pcd1 .paint_uniform_color ([0.0 , 1.0 , 0.0 ]) # green: pc1
56+
57+ pcd2 = o3d .geometry .PointCloud ()
58+ # pcd2.points = o3d.utility.Vector3dVector(pc0[:, :3] + pose_flow) # if you want to check pose_flow
59+ pcd2 .points = o3d .utility .Vector3dVector (pc0 [:, :3 ] + data [flow_mode ][~ gm0 ])
60+ pcd2 .paint_uniform_color ([0.0 , 0.0 , 1.0 ]) # blue: pc0 + flow
61+ o3d_vis .update ([pcd , pcd1 , pcd2 , o3d .geometry .TriangleMesh .create_coordinate_frame (size = 2 )])
62+
2563def vis (
2664 data_dir : str = "/home/kin/data/av2/preprocess/sensor/mini" ,
2765 flow_mode : str = "flow" , # "flow", "flow_est"
@@ -38,14 +76,13 @@ def vis(
3876 opt .point_size = point_size
3977
4078 for data_id in (pbar := tqdm (range (0 , len (dataset )))):
79+ # for easy stop and jump to any id, and save same id always from 0.
80+ if data_id < start_id and start_id != - 1 :
81+ continue
4182 data = dataset [data_id ]
4283 now_scene_id = data ['scene_id' ]
4384 pbar .set_description (f"id: { data_id } , scene_id: { now_scene_id } , timestamp: { data ['timestamp' ]} " )
4485
45- # for easy stop and jump to any id
46- if data_id < start_id and start_id != - 1 :
47- continue
48-
4986 pc0 = data ['pc0' ]
5087 gm0 = data ['gm0' ]
5188 pose0 = data ['pose0' ]
@@ -69,5 +106,6 @@ def vis(
69106
70107if __name__ == '__main__' :
71108 start_time = time .time ()
109+ # fire.Fire(check_flow)
72110 fire .Fire (vis )
73111 print (f"Time used: { time .time () - start_time :.2f} s" )
0 commit comments