ouster.sdk.osf

Module contents

Copyright (c) 2021, Ouster, Inc. All rights reserved.

This module provides an API for working with OSF (Ouster Sensor Format) files. It includes tools for reading, writing, slicing, encoding, and modifying OSF files and their metadata.

Writer

class Writer(*args, **kwargs)

Simple writer interface for OSF file

All jobs are done with MetadataStore for adding metadata entries and stream interfaces that encodes messages and passes them to internal chunks writer.

Overloaded function.

  1. __init__(self: ouster.sdk._bindings.osf.Writer, file_name: str, chunk_size: int = 0) -> None

    Creates a Writer with specified chunk_size.

    Default chunk_size is 2 MB.

  2. __init__(self: ouster.sdk._bindings.osf.Writer, filename: str, info: ouster.sdk._bindings.client.SensorInfo, fields_to_write: list[str] = [], chunk_size: int = 0, encoder: ouster::sdk::osf::Encoder = None) -> None

    Creates a Writer with deafault STREAMING layout chunks writer.

    Using default chunk_size of 2MB.

    Args:

    filename (str): The filename to output to. info (SensorInfo): The sensor info vector to use for a multi stream OSF

    file.

    chunk_size (int): The chunk size in bytes to use for the OSF file. This arg

    is optional, and if not provided the default value of 2MB is used. If the current chunk being written exceeds the chunk_size, a new chunk will be started on the next call to save. This allows an application to tune the number of messages (e.g. lidar scans) per chunk, which affects the granularity of the message index stored in the StreamingInfo in the file metadata. A smaller chunk_size means more messages are indexed and a larger number of index entries. A more granular index allows for more precise seeking at the slight expense of a larger file.

    fields_to_write (List[str]): The fields from scans to

    actually save into the OSF. If not provided uses the fields from the first saved lidar scan for each stream. This parameter is optional.

  3. __init__(self: ouster.sdk._bindings.osf.Writer, filename: str, info: list[ouster.sdk._bindings.client.SensorInfo], fields_to_write: list[str] = [], chunk_size: int = 0, encoder: ouster::sdk::osf::Encoder = None) -> None

    Creates a Writer with specified chunk_size.

    Default chunk_size is 2MB.

    Args: filename (str): The filename to output to. info (List[SensorInfo]): The sensor info vector to use for a

    multi stream OSF file.

    fields_to_write (List[str]): The fields from scans to

    actually save into the OSF. If not provided uses the fields from the first saved lidar scan for each stream. This parameter is optional.

    chunk_size (int): The chunksize to use for the OSF file, this arg

    is optional.

__annotations__ = {}
__enter__(self: ouster.sdk._bindings.osf.Writer) ouster.sdk._bindings.osf.Writer

Allow Writer to work within with blocks.

__exit__(self: ouster.sdk._bindings.osf.Writer, arg0: object, arg1: object, arg2: object) None

Allow Writer to work within with blocks.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: ouster.sdk._bindings.osf.Writer, file_name: str, chunk_size: int = 0) -> None

    Creates a Writer with specified chunk_size.

    Default chunk_size is 2 MB.

  2. __init__(self: ouster.sdk._bindings.osf.Writer, filename: str, info: ouster.sdk._bindings.client.SensorInfo, fields_to_write: list[str] = [], chunk_size: int = 0, encoder: ouster::sdk::osf::Encoder = None) -> None

    Creates a Writer with deafault STREAMING layout chunks writer.

    Using default chunk_size of 2MB.

    Args:

    filename (str): The filename to output to. info (SensorInfo): The sensor info vector to use for a multi stream OSF

    file.

    chunk_size (int): The chunk size in bytes to use for the OSF file. This arg

    is optional, and if not provided the default value of 2MB is used. If the current chunk being written exceeds the chunk_size, a new chunk will be started on the next call to save. This allows an application to tune the number of messages (e.g. lidar scans) per chunk, which affects the granularity of the message index stored in the StreamingInfo in the file metadata. A smaller chunk_size means more messages are indexed and a larger number of index entries. A more granular index allows for more precise seeking at the slight expense of a larger file.

    fields_to_write (List[str]): The fields from scans to

    actually save into the OSF. If not provided uses the fields from the first saved lidar scan for each stream. This parameter is optional.

  3. __init__(self: ouster.sdk._bindings.osf.Writer, filename: str, info: list[ouster.sdk._bindings.client.SensorInfo], fields_to_write: list[str] = [], chunk_size: int = 0, encoder: ouster::sdk::osf::Encoder = None) -> None

    Creates a Writer with specified chunk_size.

    Default chunk_size is 2MB.

    Args: filename (str): The filename to output to. info (List[SensorInfo]): The sensor info vector to use for a

    multi stream OSF file.

    fields_to_write (List[str]): The fields from scans to

    actually save into the OSF. If not provided uses the fields from the first saved lidar scan for each stream. This parameter is optional.

    chunk_size (int): The chunksize to use for the OSF file, this arg

    is optional.

__module__ = 'ouster.sdk._bindings.osf'
add_metadata(self: ouster.sdk._bindings.osf.Writer, m: object) int

Add metadata entry to a file

add_sensor(self: ouster.sdk._bindings.osf.Writer, info: ouster.sdk._bindings.client.SensorInfo, fields_to_write: list[str] = []) int

Add a sensor to the OSF file.

Parameters:
  • info (SensorInfo) – Sensor to add.

  • fields_to_write (List[str]) – The fields from scans to actually save into the OSF. If not provided uses the fields from the first saved lidar scan for each stream. This parameter is optional.

Returns (int):

The stream index to use to write scans to this sensor.

close(self: ouster.sdk._bindings.osf.Writer, fsync: bool = False) None

Finish OSF file and flush everything to disk.

filename(self: ouster.sdk._bindings.osf.Writer) str

Return the osf file name.

Returns (str):

The OSF filename.

is_closed(self: ouster.sdk._bindings.osf.Writer) bool

Return the closed status of the writer.

Returns (bool):

The closed status of the writer.

property meta_store

Returns the metadata store that gives an access to all metadata entries in the file.

metadata_id(self: ouster.sdk._bindings.osf.Writer) str

Return the metadata identifier string.

Returns (str):

The OSF metadata identifier string.

save(*args, **kwargs)

Overloaded function.

  1. save(self: ouster.sdk._bindings.osf.Writer, stream_index: int, scan: ouster.sdk._bindings.client.LidarScan) -> None

    Save a lidar scan to the OSF file.

    Args:
    stream_index (int): The index of the corresponding

    sensor_info to use.

    scan (LidarScan): The scan to save.

  2. save(self: ouster.sdk._bindings.osf.Writer, stream_index: int, scan: ouster.sdk._bindings.client.LidarScan, ts: int) -> None

    Save a lidar scan to the OSF file.

    Args:
    stream_index (int): The index of the corresponding

    sensor_info to use.

    scan (LidarScan): The scan to save. ts (int): The timestamp to index the scan with.

  3. save(self: ouster.sdk._bindings.osf.Writer, scan: ouster.sdk._bindings.client.LidarScanSet) -> None

    Save a set of lidar scans to the OSF file.

    Args:

    scans (LidarScanSet): The collation to save.

  4. save(self: ouster.sdk._bindings.osf.Writer, scans: list[ouster.sdk._bindings.client.LidarScan]) -> None

    Save a set of lidar scans to the OSF file.

    Args:
    scans (List[LidarScan]): The scans to save. This will correspond

    to the list of SensorInfos.

save_message(*args, **kwargs)

Overloaded function.

  1. save_message(self: ouster.sdk._bindings.osf.Writer, stream_id: int, receive_ts: int, sensor_ts: int, buffer: numpy.ndarray[numpy.uint8], type: str) -> None

    Low-level save message routine.

    Directly saves the message buffer with id and ts (ns) without any further checks.

  2. save_message(self: ouster.sdk._bindings.osf.Writer, stream_id: int, receive_ts: int, sensor_ts: int, buffer: Buffer, type: str) -> None

    Low-level save message routine.

    Directly saves the message buffer with id and ts (ns) without any further checks.

sensor_info(*args, **kwargs)

Overloaded function.

  1. sensor_info(self: ouster.sdk._bindings.osf.Writer) -> list[ouster.sdk._bindings.client.SensorInfo]

    Return the sensor info list.

    Returns (List[SensorInfo]):

    The sensor info list.

  2. sensor_info(self: ouster.sdk._bindings.osf.Writer, stream_index: int) -> ouster.sdk._bindings.client.SensorInfo

    Return the sensor info of the specifed stream_index.

    Args:
    stream_index (in): The index of the sensor to return

    info about.

    Returns (SensorInfo):

    The correct sensor info

sensor_info_count(self: ouster.sdk._bindings.osf.Writer) int

Return the number of sensor_info objects.

Returns (int):

The number of sensor_info objects.

set_metadata_id(self: ouster.sdk._bindings.osf.Writer, arg0: str) None

Set the metadata identifier string.

AsyncWriter

class AsyncWriter(self: ouster.sdk._bindings.osf.AsyncWriter, filename: str, info: list[ouster.sdk._bindings.client.SensorInfo], fields_to_write: list[str] = [], chunk_size: int = 0, encoder: ouster::sdk::osf::Encoder = None)

Creates an AsyncWriter with specified chunk_size.

Default chunk_size is 2MB.

Parameters:
  • filename (str) – The filename to output to.

  • info (List[SensorInfo]) – The sensor info vector to use for a multi stream OSF file.

  • fields_to_write (List[str]) – The fields from scans to actually save into the OSF. If not provided uses the fields from the first saved lidar scan for each stream. This parameter is optional.

  • chunk_size (int) – The chunksize to use for the OSF file, this arg is optional.

  • encoder (Encoder) – an optional encoder instance, used to configure how writer encodes the OSF.

__annotations__ = {}
__enter__(self: ouster.sdk._bindings.osf.AsyncWriter) ouster.sdk._bindings.osf.AsyncWriter

Allow AsyncWriter to work within with blocks.

__exit__(self: ouster.sdk._bindings.osf.AsyncWriter, arg0: object, arg1: object, arg2: object) None

Allow AsyncWriter to work within with blocks.

__init__(self: ouster.sdk._bindings.osf.AsyncWriter, filename: str, info: list[ouster.sdk._bindings.client.SensorInfo], fields_to_write: list[str] = [], chunk_size: int = 0, encoder: ouster::sdk::osf::Encoder = None) None

Creates an AsyncWriter with specified chunk_size.

Default chunk_size is 2MB.

Parameters:
  • filename (str) – The filename to output to.

  • info (List[SensorInfo]) – The sensor info vector to use for a multi stream OSF file.

  • fields_to_write (List[str]) – The fields from scans to actually save into the OSF. If not provided uses the fields from the first saved lidar scan for each stream. This parameter is optional.

  • chunk_size (int) – The chunksize to use for the OSF file, this arg is optional.

  • encoder (Encoder) – an optional encoder instance, used to configure how writer encodes the OSF.

__module__ = 'ouster.sdk._bindings.osf'
close(self: ouster.sdk._bindings.osf.AsyncWriter, fsync: bool = False) None

Finish OSF file and flush everything to disk.

save(*args, **kwargs)

Overloaded function.

  1. save(self: ouster.sdk._bindings.osf.AsyncWriter, stream_index: int, scan: ouster.sdk._bindings.client.LidarScan) -> FutureWrapper

    Save a lidar scan to the OSF file.

    Args:
    stream_index (int): The index of the corresponding

    SensorInfo to use.

    scan (LidarScan): The scan to save.

    Returns: a future.

  2. save(self: ouster.sdk._bindings.osf.AsyncWriter, stream_index: int, scan: ouster.sdk._bindings.client.LidarScan, ts: int) -> FutureWrapper

    Save a lidar scan to the OSF file.

    Args:
    stream_index (int): The index of the corresponding

    SensorInfo to use.

    scan (LidarScan): The scan to save. ts (int): The timestamp to index the scan with.

    Returns: a future.

  3. save(self: ouster.sdk._bindings.osf.AsyncWriter, scan: list[ouster.sdk._bindings.client.LidarScan]) -> list[FutureWrapper]

    Save a set of lidar scans to the OSF file.

    Args:
    scans (List[LidarScan]): The scans to save. This will correspond

    to the list of SensorInfos.

    Returns: a list of futures.

OsfScanSource

class OsfScanSource(self: ouster.sdk._bindings.osf.OsfScanSource, file: str, **kwargs)
__annotations__ = {}
__init__(self: ouster.sdk._bindings.osf.OsfScanSource, file: str, **kwargs) None
__module__ = 'ouster.sdk._bindings.osf'
property is_collated

Encoder

class Encoder(self: ouster.sdk._bindings.osf.Encoder, lidar_scan_encoder: ouster.sdk._bindings.osf.LidarScanEncoder)

Used by the Writer class to encode LidarScans, depending on configuration.

__annotations__ = {}
__init__(self: ouster.sdk._bindings.osf.Encoder, lidar_scan_encoder: ouster.sdk._bindings.osf.LidarScanEncoder) None
__module__ = 'ouster.sdk._bindings.osf'

PngLidarScanEncoder

class PngLidarScanEncoder(self: ouster.sdk._bindings.osf.PngLidarScanEncoder, compression_amount: int)

Used by the Writer class to encode LidarScans using PNG compression.

__annotations__ = {}
__init__(self: ouster.sdk._bindings.osf.PngLidarScanEncoder, compression_amount: int) None
__module__ = 'ouster.sdk._bindings.osf'

ZPngLidarScanEncoder

class ZPngLidarScanEncoder(self: ouster.sdk._bindings.osf.ZPngLidarScanEncoder, compression_amount: int)

Used by the Writer class to encode LidarScans using ZPNG compression.

__annotations__ = {}
__init__(self: ouster.sdk._bindings.osf.ZPngLidarScanEncoder, compression_amount: int) None
__module__ = 'ouster.sdk._bindings.osf'

slice_and_cast

slice_and_cast(*args, **kwargs)

Overloaded function.

  1. slice_and_cast(lidar_scan: ouster.sdk._bindings.client.LidarScan, field_types: list[ouster.sdk._bindings.client.FieldType]) -> ouster.sdk._bindings.client.LidarScan

Copies LidarScan with new field types

  1. slice_and_cast(lidar_scan: ouster.sdk._bindings.client.LidarScan, field_types: dict[str, object]) -> ouster.sdk._bindings.client.LidarScan

Copies LidarScan with new field types

dump_metadata

dump_metadata(file: str, full: bool = True) str

Dump OSF metadata/session info in JSON format. (aka osf-metadata)

File:

OSF file path

Returns:

JSON formatted string of OSF metadata + header info

backup_osf_file_metablob

backup_osf_file_metablob(file: str, backup_file_name: str) int

Backup the metadata blob in an OSF file.

File:

OSF file path (v1/v2)

Backup_file_name:

Backup path

restore_osf_file_metablob

restore_osf_file_metablob(file: str, backup_file_name: str) int

Restore an OSF metadata blob from a backup file.

File:

OSF file path (v1/v2)

Backup_file_name:

The backup to use

osf_file_modify_metadata

osf_file_modify_metadata(file_name: str, new_metadata: list[ouster.sdk._bindings.client.SensorInfo]) int

Modify an OSF files sensor_info metadata.

File_name:

The OSF file to modify.

New_metadata:

Array containing sensor infos to write to the file.

Returns:

The number of the bytes written to the OSF file.