Search code examples
javascriptpoint-cloud-librarypoint-clouds

How to parse binary_compressed point cloud?


I want to parse binary_compressed point cloud file in javascript.

I found, that in writeBinaryCompressed() points are 'Convert the XYZRGBXYZRGB structure to XXYYZZRGBRGB to aid compression', but I don't understand what does in mean. Also, I found that in parsing method points 'Unpack the xxyyzz to xyz'.

What does it mean? How to parse points after decompression?


Solution

  • In PCL, point clouds are represented as an array of structures (AoS), meaning that all fields of a point go one after another in the memory, followed by the fields of the next point, and so on. This is in contrast to the structure of arrays (SoA) layout, where first all x coordinates of each point are written, then all y coordinates, and so on. You can find more information and motivation for these layouts in a Wikipedia article.

    That being said, I have an implementation of a PCD file loader for three.js that can handle binary compressed format, you may find it here. Specifically, decompression and unpacking happens in lines 96-112.