Skip to content

Instantly share code, notes, and snippets.

@omair18
Forked from lorinma/pts2pcd
Created July 24, 2016 13:54
Show Gist options
  • Save omair18/f3b85a7085b5b006c5ba919269f1db3c to your computer and use it in GitHub Desktop.
Save omair18/f3b85a7085b5b006c5ba919269f1db3c to your computer and use it in GitHub Desktop.
convert pts file to pcd file
filename="DamagedBeam.pts"
from numpy import loadtxt
from numpy import savetxt
lines = loadtxt(filename,skiprows=1)
size=str(lines[:,0].size)
header = "VERSION .7\nFIELDS x y z\nSIZE 4 4 4\nTYPE F F F\nCOUNT 1 1 1\nWIDTH "+size+"\nHEIGHT 1\nVIEWPOINT 0 0 0 1 0 0 0\nPOINTS "+size+"\nDATA ascii"
pcd=lines[:,[0,1,2]]
savetxt("DamagedBeam.pcd", pcd, fmt="%f",header=header,comments='')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment