-
Notifications
You must be signed in to change notification settings - Fork 0
/
convertToPCD.py
38 lines (30 loc) · 1.29 KB
/
convertToPCD.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
import open3d as o3d
from array import array
import numpy as np
import sys
import json
def returnPCD(name, pathToStore):
mesh = o3d.io.read_triangle_mesh(name)
vertices = mesh.vertices
kk = o3d.geometry.PointCloud()
kk.points = vertices
kk.estimate_normals(search_param=o3d.geometry.KDTreeSearchParamHybrid(radius=0.1, max_nn=30))
kk.orient_normals_towards_camera_location(camera_location=np.array([0., 0., 0.]))
nameToStore = pathToStore + '/labels.instances.colored.normals.pcd'
print (nameToStore, "created")
o3d.io.write_point_cloud(nameToStore, kk)
if __name__ == '__main__':
with open('3RScan.json') as json_file:
data = json.load(json_file)
for item in data:
if (item['type'] == 'validation'):
for data_item in item['scans']:
removed = np.asarray(data_item['removed'])
ref = item['reference']
dd = data_item['reference']
pathS = sys.path[0] + '/' + ref
pathR = sys.path[0] + '/' + dd
nameR = pathS + '/mesh.refined.obj'
nameRescan = pathR + '/mesh.refined.align.trimesh.obj'
returnPCD(nameR,pathS)
returnPCD(nameRescan,pathR)