pose_format.utils.reader module
Classes:
|
Class is used to read binary data from buffer |
|
Class hold collection of predefined struct formats to reuse |
- class pose_format.utils.reader.BufferReader(buffer)[source]
Bases:
objectClass 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
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
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
- 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:
objectClass hold collection of predefined struct formats to reuse
Attributes:
Struct format for two unsigned short integers
Struct format for floating-point number
Struct format for signed short integer,'<h'
Struct format for three unsigned short integers
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