BodyCompressor#

class bodycompress.BodyCompressor(path, metadata=None, quantization_mm=0.5, n_threads=0)#

Bases: contextlib.AbstractContextManager

Compresses body data to a file using xz compression.

The data is quantized, difference encoded, serialized using msgpack_numpy then compressed using xz and written to the file.

Parameters:
  • path (str) – path to the output file

  • metadata – metadata to be stored in the beginning of the file

  • quantization_mm (float) – quantization level for the vertices and joints in millimeters. Coordinates are rounded to the nearest multiple of this value.

  • n_threads (int)

append(**kwargs)#

Append data for frame to the file.

Parameters:
  • **kwargs

    data to be stored. Supported keys are

    • vertices: (N, 3) float32 array of vertices in millimeters

    • joints: (N, 3) float32 array of joints in millimeters

    • vertex_uncertainties: (N,) float32 array of vertex uncertainties in meters

    • joint_uncertainties: (N,) float32 array of joint uncertainties in meters

    • camera: cameralib.Camera object or dict with camera parameters

  • allowed (Other keys are also)

  • quantized. (but they will not be)

close()#

Wait for the currently pending compression to finish then close the file.

__exit__(exc_type, exc_value, traceback)#

Close the file and remove it if an exception occurred.