Thermal Capture Module

Thermal Capture - Unified Interface

Provides a unified interface for thermal camera capture (live or recorded). Similar to cv2.VideoCapture, accepts file paths for recorded sequences or 0/None/empty string for live camera.

Provides the same interface as ThermalSharedMemory, allowing detection modules to work with both live and recorded data without modification.

class pythermal.core.capture.ThermalCapture(source: str | int | None = None, device_index: int | None = None, native_dir: str | None = None)[source]

Bases: object

Unified interface for thermal camera capture (live or recorded)

Similar to cv2.VideoCapture, accepts: - File path (str): Opens recorded .tseq file - 0, None, or empty string: Uses live camera

Provides the same interface as ThermalSharedMemory, allowing detection modules to work with both live and recorded data without modification.

__init__(source: str | int | None = None, device_index: int | None = None, native_dir: str | None = None)[source]

Initialize thermal capture from source

Parameters:
  • source – File path for recorded .tseq file, or 0/None/empty string for live camera If None, defaults to live camera (0)

  • device_index – Index of the USB device to use (0 for first device, 1 for second, etc.). Default is 0. Only used for live camera. Each device uses a separate shared memory segment.

  • native_dir – Optional path to native directory containing pythermal-recorder. If None, uses default package location. Only used for live camera.

Raises:
property is_recorded: bool

Check if source is a recorded file

property is_live: bool

Check if source is live camera

get_metadata() FrameMetadata | None[source]

Get current frame metadata

Returns:

FrameMetadata named tuple, or None if no frame available

has_new_frame() bool[source]

Check if a new frame is available

Returns:

True if new frame available, False otherwise

read() tuple[bool, ndarray | None][source]

Read next frame (VideoCapture-like interface)

Returns:

Tuple of (success, frame) where frame is BGR image (240x240x3)

get_yuyv_frame() ndarray | None[source]

Get current YUYV frame (ThermalSharedMemory interface)

Returns:

YUYV frame array (240x240x2), or None if no frame available

get_temperature_array() ndarray | None[source]

Get current temperature array (ThermalSharedMemory interface)

Returns:

Temperature array (96x96) with uint16 values, or None if no frame available

mark_frame_read()[source]

Mark current frame as read (ThermalSharedMemory interface)

set(prop: int, value: float) bool[source]

Set property (VideoCapture-like interface)

Parameters:
  • prop – Property ID (e.g., cv2.CAP_PROP_POS_FRAMES)

  • value – Property value

Returns:

True if successful, False otherwise

get(prop: int) float[source]

Get property (VideoCapture-like interface)

Parameters:

prop – Property ID (e.g., cv2.CAP_PROP_POS_FRAMES, cv2.CAP_PROP_FRAME_COUNT)

Returns:

Property value

isOpened() bool[source]

Check if capture is opened (VideoCapture-like interface)

Returns:

True if opened, False otherwise

is_initialized() bool[source]

Check if capture is initialized

release()[source]

Release resources (VideoCapture-like interface)