Thermal Shared Memory Module
Thermal Shared Memory Reader
Provides a reusable class for reading thermal camera data from shared memory. Handles YUYV frame data, temperature arrays, and metadata.
- pythermal.core.thermal_shared_memory.get_shm_name(device_index: int = 0) → str[source]
Generate shared memory name based on device index.
- Parameters:
device_index – Device index (0 for first device, 1 for second, etc.)
- Returns:
Shared memory file path
- class pythermal.core.thermal_shared_memory.FrameMetadata(seq: int, flag: int, width: int, height: int, min_temp: float, max_temp: float, avg_temp: float)[source]
Bases:
NamedTupleFrame metadata structure
- class pythermal.core.thermal_shared_memory.ThermalSharedMemory(shm_name: str = '/dev/shm/yuyv240_shm')[source]
Bases:
objectReader for thermal camera shared memory
Provides methods to read YUYV frames, temperature arrays, and metadata from the shared memory buffer created by the C++ thermal capture system.
- __init__(shm_name: str = '/dev/shm/yuyv240_shm')[source]
Initialize thermal shared memory reader
- Parameters:
shm_name – Path to shared memory file (default: /dev/shm/yuyv240_shm)
- initialize() → bool[source]
Initialize shared memory connection
- Returns:
True if successful, False otherwise
- get_metadata() → FrameMetadata | None[source]
Read frame metadata from shared memory
- Returns:
FrameMetadata named tuple, or None if not initialized
- has_new_frame() → bool[source]
Check if a new frame is available
- Returns:
True if flag is set (new frame available), False otherwise
- get_yuyv_frame() → ndarray | None[source]
Read YUYV frame data from shared memory
- Returns:
numpy array of shape (HEIGHT, WIDTH, 2) with YUYV data, or None if not initialized
- get_temperature_array() → ndarray | None[source]
Read raw temperature array (96x96) from shared memory
- Returns:
numpy array of shape (TEMP_HEIGHT, TEMP_WIDTH) with uint16 temperature values, or None if not initialized
- get_temperature_map_celsius() → ndarray | None[source]
Get temperature map in Celsius (96x96)
Converts the raw temperature array to actual Celsius values using the metadata min/max temperatures for calibration.
- Returns:
numpy array of shape (TEMP_HEIGHT, TEMP_WIDTH) with float32 Celsius values, or None if not initialized or metadata unavailable