pose_format.utils.reader module

Classes:

BufferReader(buffer)

Class is used to read binary data from buffer

ConstStructs([float, short, ushort, ...])

Class hold collection of predefined struct formats to reuse

class pose_format.utils.reader.BufferReader(buffer)[source]

Bases: object

Class is used to read binary data from buffer

Parameters:
  • buffer (bytes) – buffer from which to read data

  • read_offset (int) – current read offset in buffer

Methods:

advance(s[, times])

Updates read_offset by number of times and size of given struct -> advances read offset in buffer

bytes_left()

gives number of bytes left to read from buffer

unpack(s)

Unpacks data from the buffer using a given struct format.

unpack_f(s_format)

unpacks data from buffer using given struct format

unpack_numpy(s, shape)

unpacks data from buffer into a numpy array using struct format and shape

unpack_str()

Unpacks a string from the buffer.

unpack_tensorflow(s, shape)

Unpacks into a tensorflow tensor using struct format and shape

unpack_torch(s, shape)

unpacks data from buffer into a torch tensor using struct format and shape

advance(s, times=1)[source]

Updates read_offset by number of times and size of given struct -> advances read offset in buffer

Parameters:
  • s (struct.Struct) – The struct format that determines the data size.

  • times (int, optional) – The number of times to advance the read offset. Default is 1.

bytes_left()[source]

gives number of bytes left to read from buffer

Returns:

The number of bytes left to read.

Return type:

int

unpack(s)[source]

Unpacks data from the buffer using a given struct format.

Parameters:

s (struct.Struct) – The struct format to use for unpacking data.

Return type:

Unpacked data as specified by the struct format.

unpack_f(s_format)[source]

unpacks data from buffer using given struct format

Parameters:

s_format (str) – The struct format to use for unpacking data.

Return type:

Unpacked data as specified by the struct format.

unpack_numpy(s, shape)[source]

unpacks data from buffer into a numpy array using struct format and shape

Parameters:
  • s (struct.Struct) – The struct format to use.

  • shape (Tuple[int, ...]) – The shape of the NumPy array.

Returns:

The unpacked NumPy array.

Return type:

np.ndarray

unpack_str()[source]

Unpacks a string from the buffer.

Returns:

The unpacked string, encoded in UTF-8.

Return type:

str

unpack_tensorflow(s, shape)[source]

Unpacks into a tensorflow tensor using struct format and shape

Parameters:
  • s (struct.Struct) – The struct format to use.

  • shape (Tuple[int, ...]) – The shape of the TensorFlow tensor.

Returns:

The unpacked TensorFlow tensor.

Return type:

tensorflow.Tensor

unpack_torch(s, shape)[source]

unpacks data from buffer into a torch tensor using struct format and shape

Parameters:
  • s (struct.Struct) – The struct format to use.

  • shape (Tuple[int, ...]) – The shape of the PyTorch tensor.

Returns:

The unpacked PyTorch tensor.

Return type:

torch.Tensor

class pose_format.utils.reader.ConstStructs(float=<Struct object>, short=<Struct object>, ushort=<Struct object>, double_ushort=<Struct object>, triple_ushort=<Struct object>)[source]

Bases: object

Class hold collection of predefined struct formats to reuse

Attributes:

double_ushort

Struct format for two unsigned short integers

float

Struct format for floating-point number

short

Struct format for signed short integer,'<h'

triple_ushort

Struct format for three unsigned short integers

ushort

Struct format for unsigned short integer

Parameters:
  • float (Struct) –

  • short (Struct) –

  • ushort (Struct) –

  • double_ushort (Struct) –

  • triple_ushort (Struct) –

double_ushort: Struct = <Struct object>

Struct format for two unsigned short integers

float: Struct = <Struct object>

Struct format for floating-point number

short: Struct = <Struct object>

Struct format for signed short integer,’<h’

triple_ushort: Struct = <Struct object>

Struct format for three unsigned short integers

ushort: Struct = <Struct object>

Struct format for unsigned short integer