-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvis_data_vispy.py
72 lines (55 loc) · 1.67 KB
/
vis_data_vispy.py
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
72
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 9 20:28:39 2018
@author: Isaac
"""
# -*- coding: utf-8 -*-
# vispy: gallery 10
# Copyright (c) Vispy Development Team. All Rights Reserved.
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
""" Demonstrates use of visual.Markers to create a point cloud with a
standard turntable camera to fly around with and a centered 3D Axis.
"""
import numpy as np
import vispy.scene
from vispy.scene import visuals
import h5py
#
# Make a canvas and add simple view
#
canvas = vispy.scene.SceneCanvas(keys='interactive', show=True)
view = canvas.central_widget.add_view()
# generate data
point_cloud = np.load('./data/vkitti3d_dataset_v1.0/01/0001_00000.npy') # shape: (401326, 7)
data1 = point_cloud[:,:6]
label1 = point_cloud[:,-1]
print(data1.shape, label1.shape)
#%%
# create scatter object and fill in the data
scatter = visuals.Markers()
ind = 15
rgb_codes = [[255,0,0],
[255,255,0],
[255,0,255],
[0,0,255],
[0,255,0],
[0,255,255],
[100,100,100],
[255,30,50],
[25,180,60],
[5,220,100],
[25,100,200],
[105,60,90],
[150,0,190]]
color = np.zeros((label1.shape[0], 3))
for i in range(label1.shape[0]):
color[i,:] = [code/255 for code in rgb_codes[int(label1[i])]]
scatter.set_data(data1[:,:3], edge_color=None, face_color=color, size=5)
view.add(scatter)
view.camera = 'turntable' # or try 'arcball'
# add a colored 3D axis for orientation
axis = visuals.XYZAxis(parent=view.scene)
if __name__ == '__main__':
import sys
if sys.flags.interactive != 1:
vispy.app.run()