-
Notifications
You must be signed in to change notification settings - Fork 473
Expand file tree
/
Copy pathvisual.py
More file actions
71 lines (57 loc) · 2.17 KB
/
visual.py
File metadata and controls
71 lines (57 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from det3d.core.bbox.box_np_ops import center_to_corner_box3d
import open3d as o3d
import argparse
import pickle
def label2color(label):
colors = [[204/255, 0, 0], [52/255, 101/255, 164/255],
[245/255, 121/255, 0], [115/255, 210/255, 22/255]]
return colors[label]
def corners_to_lines(qs, color=[204/255, 0, 0]):
""" Draw 3d bounding box in image
qs: (8,3) array of vertices for the 3d box in following order:
7 -------- 4
/| /|
6 -------- 5 .
| | | |
. 3 -------- 0
|/ |/
2 -------- 1
"""
idx = [(1,0), (5,4), (2,3), (6,7), (1,2), (5,6), (0,3), (4,7), (1,5), (0,4), (2,6), (3,7)]
cl = [color for i in range(12)]
line_set = o3d.geometry.LineSet(
points=o3d.utility.Vector3dVector(qs),
lines=o3d.utility.Vector2iVector(idx),
)
line_set.colors = o3d.utility.Vector3dVector(cl)
return line_set
def plot_boxes(boxes, score_thresh):
visuals =[]
num_det = boxes['scores'].shape[0]
for i in range(num_det):
score = boxes['scores'][i]
if score < score_thresh:
continue
box = boxes['boxes'][i:i+1]
label = boxes['classes'][i]
corner = center_to_corner_box3d(box[:, :3], box[:, 3:6], box[:, -1])[0].tolist()
color = label2color(label)
visuals.append(corners_to_lines(corner, color))
return visuals
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="CenterPoint")
parser.add_argument('--path', help='path to visualization file', type=str)
parser.add_argument('--thresh', help='visualization threshold', type=float, default=0.3)
args = parser.parse_args()
with open(args.path, 'rb') as f:
data_dicts = pickle.load(f)
for data in data_dicts:
points = data['points']
detections = data['detections']
pcd = o3d.geometry.PointCloud()
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(points[:, :3])
visual = [pcd]
num_dets = detections['scores'].shape[0]
visual += plot_boxes(detections, args.thresh)
o3d.visualization.draw_geometries(visual)