forked from RicoJia/notes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopen3d_example.py
More file actions
28 lines (24 loc) · 921 Bytes
/
open3d_example.py
File metadata and controls
28 lines (24 loc) · 921 Bytes
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
#!/usr/bin/python3
# examples/Python/Basic/working_with_numpy.py
import copy
import numpy as np
import open3d as o3d
if __name__ == "__main__":
# generate some neat n times 3 matrix using a variant of sync function
x = np.linspace(-3, 3, 4)
mesh_x, mesh_y = np.meshgrid(x, x)
z = np.sinc((np.power(mesh_x, 2) + np.power(mesh_y, 2)))
# z_norm = (z - z.min()) / (z.max() - z.min())
z[0] = 10
z_norm = z
xyz = np.zeros((np.size(mesh_x), 3))
xyz[:, 0] = np.reshape(mesh_x, -1)
xyz[:, 1] = np.reshape(mesh_y, -1)
xyz[:, 2] = np.reshape(z_norm, -1)
print('xyz')
print(xyz)
# Pass xyz to Open3D.o3d.geometry.PointCloud and visualize
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(xyz)
mesh_frame = o3d.geometry.TriangleMesh.create_coordinate_frame(size=0.6, origin=[0,0,0])
o3d.visualization.draw_geometries([pcd, mesh_frame])