A Python interface module for accessing shared memory buffers containing stereo camera frames, AI model outputs and IMU data. This class provides methods to initialize the memory interface, retrieve frame, AI output and IMU data and get stereo camera calibration parameters.
getMemoryConfiguration
Config
Return the memory configuration as a dictionary.
def getMemoryConfiguration(self)
Returns
| Type |
Description |
dict |
Configuration containing frame dimensions, BPP, and buffer sizes. |
load_calibration
Config
Loads stereo calibration data from a YAML file.
def load_calibration(self, calib_file='<optional>')
Parameters
| Name |
Type |
Description |
calib_file |
str |
Optional - Path to the stereo calibration YAML file. |
Returns
| Type |
Description |
list |
Loaded calibration data structures. |
load_rectification
Config
Loads rectification maps from an NPZ file.
def load_rectification(self, recti_file='<optional>')
Parameters
| Name |
Type |
Description |
recti_file |
str |
Optional - Path to the rectification maps NPZ file. |
Returns
| Type |
Description |
list |
Loaded rectification map arrays. |
init
Lifecycle
Initialize shared memory interface.
def init(self)
Returns
| Type |
Description |
bool |
True if successful, False otherwise. |
isInitialized
State
Check if the shared memory interface was initialized.
def isInitialized(self)
Returns
| Type |
Description |
bool |
True if initialized, False otherwise. |
getDataFrame
Data
Checks indices and returns the latest frame if available.
def getDataFrame(self)
Returns
| Type |
Description |
tuple |
frame_data is numpy array (2, height, width, bpp) or None. |
Raises
RuntimeError: If shared memory is not initialized.
getDataFrameImu
Data
Checks indices and return frame and frame's IMU data, if new data is available.
def getDataFrameImu(self)
Returns
| Type |
Description |
tuple |
(frame_data, frame_imu_data):
frame_data (int): numpy array (2, height, width, bpp) or None
frame_imu_data (dict): Dictionary containing IMU measurements with the following keys:
'accel_x', 'accel_y', 'accel_z' (float): Last Linear acceleration components in g (gravitational units)
'gyro_x', 'gyro_y', 'gyro_z' (float): Accumulated Angular velocity components in °/s (degrees per second)
'temp' (float): Sensor temperature in °C
'timestamp' (float): Sample acquisition timestamp in seconds (floating-point representation)
'isValid' (bool): Validity of the IMU data
|
Raises
RuntimeError: If shared memory is not initialized.
getDataRawImu
Data
Get the latest raw IMU data from the ring buffer.
def getDataRawImu(self)
Returns
| Type |
Description |
tuple |
(imu_data, current_imu_index):
imu_data (dict): Dictionary containing IMU measurements with the following keys:
'accel_x', 'accel_y', 'accel_z' (float): Linear acceleration components in g (gravitational units)
'gyro_x', 'gyro_y', 'gyro_z' (float): Angular velocity components in °/s (degrees per second)
'temp' (float): Sensor temperature in °C
'fsyncAgo' (int): Time elapsed since last FSYNC pulse in microseconds
'timestamp' (float): Sample acquisition timestamp in seconds (floating-point representation)
current_imu_index (int): Monotonically increasing index identifying the current IMU sample in the acquisition sequence
|
Raises
RuntimeError: If shared memory is not initialized.
getDataAi
Data
Retrieves AI processed data.
def getDataAi(self, timeout=5)
Parameters
| Name |
Type |
Description |
timeout |
int |
Timeout in seconds to wait for data. |
Returns
| Type |
Description |
dict |
Dictionary containing AI processing results with the following keys:
'data' (numpy.ndarray or similar): Processed AI output data (e.g., inference results, feature vectors, or model predictions)
'header' (dict or structured object): Metadata/header information associated with the AI output, including timing, sequence numbers, or processing parameters
'input_frame_right' (numpy.ndarray or buffer): Right camera frame that was processed by the AI model
'input_frame_left' (numpy.ndarray or buffer): Left camera frame that was processed by the AI model
'success' (bool): Boolean flag indicating whether AI processing completed successfully (True for success, False for failure)
|
forceFunctionStop
Internal
Call this from another thread to cancel blocking AI data acquistion calls.
def forceFunctionStop(self)
cleanup
Lifecycle
Clean up shared memory resources. (Note: Shared memory itself is not cleaned up by Python).
def cleanup(self)