-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathbin2pcd.py
More file actions
28 lines (24 loc) · 736 Bytes
/
bin2pcd.py
File metadata and controls
28 lines (24 loc) · 736 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
import numpy as np
import struct
import sys
import open3d as o3d
def bin_to_pcd(binFileName):
size_float = 4
list_pcd = []
with open(binFileName, "rb") as f:
byte = f.read(size_float * 4)
while byte:
x, y, z, intensity = struct.unpack("ffff", byte)
list_pcd.append([x, y, z])
byte = f.read(size_float * 4)
np_pcd = np.asarray(list_pcd)
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(np_pcd)
return pcd
def main(binFileName, pcdFileName):
pcd = bin_to_pcd(binFileName)
o3d.io.write_point_cloud(pcdFileName, pcd)
if __name__ == "__main__":
a = sys.argv[1]
b = sys.argv[2]
main(a, b)