Skip to content

Instantly share code, notes, and snippets.

@lorinma
Created December 5, 2015 08:19
Show Gist options
  • Save lorinma/36b3cd323c55e5b5bfec to your computer and use it in GitHub Desktop.
Save lorinma/36b3cd323c55e5b5bfec 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