-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_edit_2.py
44 lines (38 loc) · 1.41 KB
/
test_edit_2.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
import open3d as o3d
# TODO doesn't work
# class NewVis(o3d.visualization.VisualizerWithEditing,
# o3d.visualization.VisualizerWithKeyCallback):
# def __init__(self):
# super(NewVis).__init__()
class Test:
def __init__(self, pcd):
self.points = set()
self.pcd = pcd
self.pcd_tree = o3d.geometry.KDTreeFlann(pcd)
def __call__(self, vis):
psi = vis.get_picked_points()
for pi in psi:
if pi not in self.points:
print('New point {}'.format(pi))
print(self.pcd.points[pi])
print(self.pcd.colors[pi])
self.points.add(pi)
cs = self.pcd.points[pi]
r = 0.1
n, nsi, ds = self.pcd_tree.search_radius_vector_3d(cs, r)
print('n_neighbours: {}'.format(n))
for ni in nsi:
self.pcd.colors[ni] = [1, 0, 0]
self.pcd.colors[pi] = [0, 1, 0]
return False
if __name__ == "__main__":
file_path = 'cropped_1.ply'
pcd = o3d.io.read_point_cloud(file_path)
t = Test(pcd)
while True:
vis = o3d.visualization.VisualizerWithEditing()
vis.register_animation_callback(t)
vis.create_window(width=500, height=500, left=800, top=50)
vis.add_geometry(t.pcd)
vis.run()
vis.destroy_window()