Last active
May 19, 2016 16:32
-
-
Save micuat/fba57e724c5922f7bd587d47707e8f6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import sys | |
from liblas import file | |
# usage | |
# $ python las2ply > output.ply | |
# http://stackoverflow.com/questions/5574702/how-to-print-to-stderr-in-python | |
def eprint(*args, **kwargs): | |
print(*args, file=sys.stderr, **kwargs) | |
# input file | |
f = file.File('defi1.las',mode='r') | |
count = f.header.count | |
eprint(count) | |
print ("""ply | |
format ascii 1.0 | |
comment VCGLIB generated | |
element vertex %d | |
property float x | |
property float y | |
property float z | |
property uchar red | |
property uchar green | |
property uchar blue | |
element face 0 | |
property list uchar int vertex_indices | |
end_header""" % count) | |
count = 0 | |
for p in f: | |
print ("%f %f %f %d %d %d" % (p.x, p.y, p.z, p.color.red, p.color.green, p.color.blue)) | |
if count % 1000000 == 0: | |
eprint(count) | |
count += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment