robokudo.io.file_reader_interface

File-based data reading interface for RoboKudo.

This module provides interfaces for reading sensor data from the local filesystem. It supports reading:

  • RGB-D camera data (color and depth images)

  • Camera calibration information

  • Timestamped data sequences

The module is primarily used for:

  • Unit testing with recorded data

  • Simple demos and examples

  • Development and debugging

Classes

FileReaderInterface

A camera interface for reading stored data from the local filesystem.

RGBDFileReaderInterface

Specialized file reader interface for RGB-D camera data.

Module Contents

class robokudo.io.file_reader_interface.FileReaderInterface(camera_config)

Bases: robokudo.io.camera_interface.CameraInterface

A camera interface for reading stored data from the local filesystem.

This interface reads sensor data from files in a specified directory. Files must follow the naming convention: * rk_TIMESTAMP_color_image.jpg - Color image data * rk_TIMESTAMP_depth_image.png - Depth image data * rk_TIMESTAMP_cam_info.json - Camera calibration data

The ‘rk_’ prefix is configurable. Data types in filenames must match CASViews definitions.

Note

This interface is primarily for testing and demos. For production, use StorageReaderInterface instead.

Variables:
  • initialized – Whether the interface was successfully initialized

  • target_dir – Target directory path as string

  • target_dir_path – Target directory as Path object

  • filename_prefix – Prefix for data files, defaults to “rk_

  • loaded_paths – Dictionary mapping timestamps to file paths

  • loaded_data – Dictionary mapping timestamps to loaded data

  • data_reader – Iterator for accessing loaded data

class DictIteratorReader(data=dict(), data_sequence=[])

Helper class for iterating over dictionary data in sequence.

This class provides cursor-based iteration over dictionary data, maintaining the sequence order and supporting reset operations.

Variables:
  • index – Current position in the sequence

  • data – Dictionary containing the data

  • data_sequence – List defining iteration order

index = None
data
data_sequence = []
reset_cursor()

Reset the iterator to the beginning of the sequence.

Sets index to 0 if there is data, None otherwise.

cursor_has_data()

Check if there is more data to read.

Returns:

True if more data is available, False otherwise

Return type:

bool

get_next_data() dict | None

Get the next data item in the sequence.

Returns:

Next data item if available, None otherwise

Return type:

dict or None

initialized = False
loaded_paths
loaded_data
data_reader
has_new_data()

Check if new data is available to read.

Handles looping behavior based on camera configuration and maintains cursor position in the data sequence.

Returns:

True if new data is available, False otherwise

Return type:

bool

class robokudo.io.file_reader_interface.RGBDFileReaderInterface(camera_config)

Bases: FileReaderInterface

Specialized file reader interface for RGB-D camera data.

This class extends FileReaderInterface to handle the specific case of reading RGB-D camera data, including color images, depth images, and camera calibration information.

Inherits all instance variables from FileReaderInterface.

set_data(cas: robokudo.cas.CAS)

Set the next RGB-D data frame into the CAS.

This method: * Reads the next color and depth images * Applies any necessary fixes (e.g., Kinect height fix) * Sets camera calibration and transformation data * Updates the CAS with all loaded data

Parameters:

cas (robokudo.cas.CAS) – Common Analysis Structure to update