Live View Module

Live View for Thermal Camera - Original Grayscale with Mouse Temperature

Displays real-time thermal imaging feed in original grayscale. Shows temperature at mouse cursor position. Press ‘t’ to toggle between YUYV view and 96x96 temperature view. Supports both live camera and recorded sequences using ThermalCapture.

class pythermal.live_view.ThermalLiveView(source: str | int | None = None, device_index: int | None = None, native_dir: str | None = None)[source]

Bases: object

Live view display for thermal camera - supports live and recorded sources

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

Initialize thermal live view.

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

  • 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.

initialize() bool[source]

Initialize thermal capture connection

calculate_temperature_from_pixel(x: int, y: int, min_temp: float, max_temp: float) float | None[source]

Calculate temperature at pixel position using raw temperature data from buffer

Parameters:
  • x – X coordinate (column, 0-239)

  • y – Y coordinate (row, 0-239)

  • min_temp – Minimum temperature from metadata

  • max_temp – Maximum temperature from metadata

Returns:

Temperature in Celsius, or None if invalid position or data unavailable

get_original_yuyv(yuyv_data: ndarray) ndarray[source]

Convert YUYV to grayscale BGR for original view

Parameters:

yuyv_data – YUYV frame data

Returns:

Grayscale BGR image

get_temperature_view(temp_array: ndarray, min_temp: float, max_temp: float) ndarray[source]

Convert temperature array to visualizable BGR image

Parameters:
  • temp_array – 96x96 array of 16-bit temperature values

  • min_temp – Minimum temperature for normalization

  • max_temp – Maximum temperature for normalization

Returns:

BGR image (240x240) with temperature data upscaled and colorized

draw_overlay(image: ndarray, min_temp: float, max_temp: float, avg_temp: float, seq: int, fps: float) ndarray[source]

Draw temperature and statistics overlay below the frame

Parameters:
  • image – BGR image to draw on (240x240)

  • min_temp – Minimum temperature

  • max_temp – Maximum temperature

  • avg_temp – Average temperature

  • seq – Frame sequence number

  • fps – Current FPS

Returns:

Extended image with text overlay below frame

calculate_fps() float[source]

Calculate current FPS

mouse_callback(event, x, y, flags, param)[source]

Mouse callback to track mouse position - uses x/y from window coordinates

run()[source]

Main loop for live view

cleanup()[source]

Cleanup resources

pythermal.live_view.main()[source]

Main entry point