-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvisualizepc.py
More file actions
40 lines (31 loc) · 1 KB
/
visualizepc.py
File metadata and controls
40 lines (31 loc) · 1 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
import open3d as o3d
from typing import Union
import argparse
import os
def visualizeo3d(pc: Union[str, o3d.geometry.PointCloud, o3d.t.geometry.PointCloud]):
"""
Visualizes pointcloud
Parameters
----------
pc
May be string with path to pointcloud, or o3d.(t) PointCloud object
"""
# check type
if isinstance(pc, str):
if not os.path.exists(pc):
print(f"Can't find file at location {pc}")
return
pcd = o3d.io.read_point_cloud(pc)
elif isinstance(pc, o3d.geometry.PointCloud) or isinstance(pc, o3d.t.geometry.PointCloud):
pcd = pc
# Visualize point clouds
o3d.visualization.draw_geometries([pcd])
return
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-p", "--pointcloud", type=str, required=True)
args = parser.parse_args()
if not os.path.exists(args.pointcloud):
print("couldnt find pointcloud")
os._exit(1)
visualizeo3d(args.pointcloud)