mkazhdan / PoissonRecon

Poisson Surface Reconstruction
MIT License
1.59k stars 431 forks source link

Issue About Output file and PCL #221

Closed AlvinRey closed 2 years ago

AlvinRey commented 2 years ago

Hi,Professor, In my project, I want the input point cloud to be processed by PoissonRecon (v13.7) and SurfaceTrimmer (v13.7) to output the mesh with normals.

However, in the output .ply file, "property list uchar int vertex_indices" becomes "property list int int vertex_indices", which causes the PCL (Point Cloud Library) to report an error which is "parse error: unknown list size type" when reading the output file.

I would like to ask you how to solve this problem, thank you very much!

mkazhdan commented 2 years ago

Out of curiosity, if you open the file in an editor and change "uchar" to "char", does that fix the problem?

AlvinRey commented 2 years ago

I just tried your suggestion and it doesn't seem to work. When I changed ”uchar“ to ”char“, the size of the file changed and PCL doesn't read it correctly anymore. Even though I changed it back, it doesn't read correctly as well.

note: What I change here is the data in "A.ply", because there is no ”uchar“ in B.ply

=============================================== It's my fault, I don't seem to have phrased the problem clearly.

I have two files, let's call them "A.ply“ and ”B.ply“.

A.ply was generated with PoissonRecon and SurfaceTrimmer in version 6.1. It can be read correctly by PCL. However, the file does not contain normals, so it cannot be used in my project.

B.ply was generated with PoissonRecon and SurfaceTrimmer in version 13.7. The file contains normals, but can't be read correctly by PCL.

The difference between the file headers of the two files is in the "property list". The "property list" of A.ply is "uchar int vertex_indices". The "property list" of B.ply is "int int vertex_indices".

So I guess that the file cannot be read correctly because "uchar" becomes to "int"

mkazhdan commented 2 years ago

The short answer is that I think it is a bug with PCL. A workable, but somewhat ugly, answer is to run the reconstruction with the --ascii flag. Then change "int" to "uchar". (The downside is that since the output is not in binary, it will be large.)

mkazhdan commented 2 years ago

A note of warning, however, if you are outputting polygons instead of triangles in the reconstruction, it is theoretically possible for polygons to have more than 255 vertices. In that case representing the number of vertices in the polygons with an unsigned char will lead to overflow. (That explains the switch from uchar to int between V6.1 and 13.7.

AlvinRey commented 2 years ago

Thank you very much for your suggestion, it solved my problem. The file size problem can be solved by reading the file in PCL and then writing it in binary.