potree / PotreeConverter

Create multi res point cloud to use with potree
http://potree.org
BSD 2-Clause "Simplified" License
679 stars 423 forks source link

Add support for ply #2

Closed m-schuetz closed 9 years ago

m-schuetz commented 10 years ago

Try http://people.cs.kuleuven.be/~ares.lagae/libply/

m-schuetz commented 10 years ago

Added a rudimentary ply reader: https://github.com/potree/PotreeConverter/commit/2bc623cb4b0d105d19cd05040f98de9b38c5d504

Supports ply files in little endian format, and one "element vertex" definition at the beginning with following properties:

property float x
property float y
property float z
property uchar (r|red|diffuse_red)
property uchar (g|green|diffuse_green)
property uchar (b|blue|diffuse_blue)
[other properties will be ignored]

todo:

zekemas commented 9 years ago

Hi I've been playing around with this, in conjunction with point clouds created with the pcl tools. i.e. Create a pcd, then use the pcl_pcd2ply tool to convert to ply, then using this to convert that ply file for use with potree. I had a colleague setup a webgl server for viewing these files, but my converted binary type comes all black on a black screen.

I also have this problem where when I try to output LAS I get a segmentation fault. (I build the libLAS from git source mastered at https://github.com/libLAS/libLAS.git)

Any pointers for working with converted pcd files? (btw: The color data is stored in the pcd as an 888rgb type, that is to say each color only ranges from 0-255)

ashutoshkumarjha commented 9 years ago

I have the output genrate from PMVS2. The options-0000.ply is not getting converted using windows binaries. It is giving following out.

source[0]: output.nvm.cmvs\00\models\options-0000.ply outdir: .\potree spacing: 0.5 levels: 4 format: xyzrgb range: 255 output-format: BINARY

AABB: min: [3.40282e+038, 3.40282e+038, 3.40282e+038] max: [-3.40282e+038, -3.40282e+038, -3.40282e+038] size: [3.40282e+038, 3.40282e+038, 3.40282e+038]

0 points written duration: 0.002s closing writer duration: 0.048s

Though I am able to get the center-0000.ply converted.

m-schuetz commented 9 years ago

@zekemas Just recently noticed the las output does not work. Will try to fix this tomorrow. And sorry for the late reply, somehow I did not get/see a notification. The point cloud is black because the converter expects las files to have colors between 0 and 2^16. I'll add an option so that you can specify the range the color is in. In the meantime, you can use lastools to transform your 1byte colors to 2byte colors with something like:

las2las -i file.las -scale_rgb_up

@ashutoshkumarjha The converter already failed at calculating the bounding box. Can you give me a small sample of your ply file?

ashutoshkumarjha commented 9 years ago

@m-schuetz Please find the 2 sample files in ASCII here.

Sample 1. It is having three more column corresponding to the normal vector(nx,ny,nz).

ply format ascii 1.0 element vertex 640893 property float x property float y property float z property float nx property float ny property float nz property uchar diffuse_red property uchar diffuse_green property uchar diffuse_blue end_header -0.135468 -2.15953 3.04081 -0.00986222 0.412305 -0.910992 217 234 253 -0.132577 -2.15953 3.04078 -0.00993394 0.412305 -0.910992 216 233 252 -0.130244 -2.15953 3.04074 -0.0124776 -0.277694 -0.960588 216 233 252 -0.125541 -2.15909 3.04026 -0.0125476 -0.254037 -0.967113 216 233 252 -0.147413 -2.15006 3.033 -0.00676667 0.313743 -0.949484 217 233 252 -0.142532 -2.14964 3.03254 0.00763145 0.939778 -0.3417 216 234 252 -0.123058 -2.15489 3.03913 -0.0140841 0.352687 -0.935635 217 234 252 -0.120103 -2.15489 3.03909 -0.0140896 0.352687 -0.935635 217 235 252 -0.117863 -2.15501 3.03921 -0.0143385 0.146134 -0.989161 217 234 252 -0.115863 -2.15001 3.03366 -0.00764967 0.242114 -0.970218 218 235 252 -0.20394 -2.14965 3.03703 -0.00582301 0.519853 -0.854236 215 233 252 -0.187552 -2.1486 3.03405 0.0466513 0.636871 -0.769558 217 234 253 -0.180405 -2.15149 3.03585 -0.00677877 0.312079 -0.950032 214 232 251 -0.174411 -2.15149 3.03581 -0.00678813 0.312079 -0.950032 214 232 251 -0.168462 -2.15138 3.03564 -0.00641668 0.340512 -0.940218 216 233 251 ........... ..........

Sample2. If the input.ply file header is is having the additional lines such as commment(line 3) and property (line 13) just as below it fails.

ply format binary_little_endian 1.0 comment VCGLIB generated element vertex 639102 property float x property float y property float z property uchar red property uchar green property uchar blue property uchar alpha element face 0 property list uchar int vertex_indices end_header

m-schuetz commented 9 years ago

@zekemas fixed las/laz output: https://github.com/potree/PotreeConverter/commit/5996860e6a6f8e075eae8b192494b529ddc0f654

m-schuetz commented 9 years ago

@ashutoshkumarjha I tried to convert the 2 examples with the latest develop branch and both worked, when I set the element vertex option to the correct number of points. Maybe the problem is with binary ply files, not ascii files? Can you send me the file that did not work to mschuetz@potree.org ?

ashutoshkumarjha commented 9 years ago

@m-schuetz you are right the problem is with the binary file. I have sent you the sample file. Also will be it be possible to reorient the ply file coordinate system by passing the parameter. such as xyz to yxz .

m-schuetz commented 9 years ago

Flipping the y and z coordinates is done in the potree page, like this:

pointcloud.applyMatrix(new THREE.Matrix4().set(
    1,0,0,0,
    0,0,1,0,
    0,1,0,0,
    0,0,0,1
));