开发者

Reading binary PLY file generates weird results

My task is to read vertex data from a binary little endian .ply file. Problem is that I cant find a way how to correctly extract data, starting after the end_header line.

PLY file:

ply
format binary_little_endian 1.0
element vertex 240753
property float x
property float y
property float z
property float nx
property float ny
property float nz
element face 477808
en开发者_StackOverflow社区d_header
(after the end header there is a A0 byte indicating the new line then, ...)
AC76A0C04301644163416a42 ...

I cant properly identify even first float. If I convert first 4 bytes using IEE754 representation of float, the result is -3.5047936775001176e-12, however first four bytes (= the first x coordinate of first vertex) should be -5.01449 (according to meshlab conversion from binary to ascii ply file).

I'm using c++ fread, fseek, ...

I tried to endian swap every 4 bytes but the result is also bad.

I think that I'm extracting the bytes in a wrong manner.


As described by @tinman:

If you already have the bytes that represent your float in an unsigned int variable then you can make a union of an unsigned int and float, assign the unsigned int you have to the unsigned int in the union and then read the float in the union.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜