bodycompress#

BodyCompress is for compressing and decompressing nonparametric human representations, i.e. keypoints like mesh vertices and joints.

Classes#

BodyCompressor

Compresses body data to a file using xz compression.

BodyDecompressor

Decompresses body data from a file compressed using BodyCompressor.

Package Contents#

class BodyCompressor(path, metadata=None, quantization_mm=0.5, n_threads=0)[source]#

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)[source]#

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()[source]#

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

__exit__(exc_type, exc_value, traceback)[source]#

Close the file and remove it if an exception occurred.

class BodyDecompressor(path)[source]#

Bases: contextlib.AbstractContextManager, collections.abc.Iterator

Decompresses body data from a file compressed using BodyCompressor.

The data is decompressed using xz, deserialized using msgpack_numpy, difference decoded and unquantized.

Parameters:

path – path to the compressed file

__next__()[source]#

Read the next frame and decode it from the file.

Return type:

dict

close()[source]#

Terminate the decompression process and close the file.

__exit__(*args)[source]#

Close the decompressor.