# beastwithin/ht203u-thermal architecture

> Architecture diagram of the GitHub repository beastwithin/ht203u-thermal, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/beastwithin/ht203u-thermal
- Repository: https://github.com/beastwithin/ht203u-thermal

## Overview

HT-203U thermal viewer is a dual-platform USB thermal-camera viewer. Users start the desktop Python viewer or Android app, which acquire camera frames, decode the temperature data, and present a colour-mapped view with temperature readouts. The desktop also supports one-frame PNG/CSV exports and Linux virtual-camera streaming. Android’s frame-processing and colour-map layers are explicit in source; Python responsibilities share one script, and some orchestration details are documented rather than visible in the excerpt.

Main entry points: [`android/app/src/main/java/com/beastin/ht203u/MainActivity.kt`](https://github.com/beastwithin/ht203u-thermal/blob/main/android/app/src/main/java/com/beastin/ht203u/MainActivity.kt) (Android activity), [`thermal.py`](https://github.com/beastwithin/ht203u-thermal/blob/main/thermal.py) (Python viewer), [`android/app/src/main/java/com/beastin/ht203u/ThermalProcessor.kt`](https://github.com/beastwithin/ht203u-thermal/blob/main/android/app/src/main/java/com/beastin/ht203u/ThermalProcessor.kt) (Thermal processor), [`android/app/src/main/java/com/beastin/ht203u/Colormap.kt`](https://github.com/beastwithin/ht203u-thermal/blob/main/android/app/src/main/java/com/beastin/ht203u/Colormap.kt) (Inferno colour map)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop viewer"]
  node_python_app["Python viewer<br/>[thermal.py]"]
  node_desktop_capture["Camera capture<br/>[thermal.py]"]
  node_latest_frame["Latest frame<br/>[thermal.py]"]
end

subgraph group_android["Android viewer"]
  node_android_activity["Android activity<br/>[MainActivity.kt]"]
  node_uvc_library["UVC camera library"]
  node_android_display["Thermal display<br/>[MainActivity.kt]"]
end

subgraph group_processing["Frame processing"]
  node_temperature_decode["Temperature decode<br/>[thermal.py]"]
  node_desktop_render["Thermal rendering<br/>[thermal.py]"]
  node_thermal_processor["Thermal processor"]
  node_android_colormap["Inferno colour map<br/>[Colormap.kt]"]
end

subgraph group_outputs["Desktop outputs"]
  node_frame_export["PNG / CSV export<br/>[thermal.py]"]
  node_virtual_stream["Virtual webcam<br/>[thermal.py]"]
end

node_desktop_user(("Desktop user"))
node_ffmpeg["ffmpeg"]
node_loopback["v4l2loopback device"]
node_android_user(("Android user"))
node_usb_camera["HT-203U camera"]

node_desktop_user -->|"starts"| node_python_app
node_python_app -->|"opens stream"| node_desktop_capture
node_desktop_capture -->|"reads camera"| node_ffmpeg
node_desktop_capture -->|"publishes frames"| node_latest_frame
node_latest_frame -->|"provides frame"| node_temperature_decode
node_temperature_decode -->|"produces temperatures"| node_desktop_render
node_python_app -->|"saves frame"| node_frame_export
node_python_app -->|"runs stream"| node_virtual_stream
node_virtual_stream -->|"reads newest frame"| node_latest_frame
node_virtual_stream -->|"renders frame"| node_desktop_render
node_virtual_stream -->|"writes video"| node_ffmpeg
node_ffmpeg -->|"streams output"| node_loopback
node_android_user -->|"opens app"| node_android_activity
node_usb_camera -->|"streams frames"| node_uvc_library
node_android_activity -->|"opens camera"| node_uvc_library
node_uvc_library -->|"delivers frames"| node_android_activity
node_android_activity -->|"processes frames"| node_thermal_processor
node_thermal_processor -->|"uses lookup table"| node_android_colormap
node_android_activity -->|"updates image and readout"| node_android_display

click node_python_app "https://github.com/beastwithin/ht203u-thermal/blob/main/thermal.py"
click node_desktop_capture "https://github.com/beastwithin/ht203u-thermal/blob/main/thermal.py"
click node_latest_frame "https://github.com/beastwithin/ht203u-thermal/blob/main/thermal.py"
click node_temperature_decode "https://github.com/beastwithin/ht203u-thermal/blob/main/thermal.py"
click node_desktop_render "https://github.com/beastwithin/ht203u-thermal/blob/main/thermal.py"
click node_frame_export "https://github.com/beastwithin/ht203u-thermal/blob/main/thermal.py"
click node_virtual_stream "https://github.com/beastwithin/ht203u-thermal/blob/main/thermal.py"
click node_android_activity "https://github.com/beastwithin/ht203u-thermal/blob/main/android/app/src/main/java/com/beastin/ht203u/MainActivity.kt"
click node_thermal_processor "https://github.com/beastwithin/ht203u-thermal/blob/main/android/app/src/main/java/com/beastin/ht203u/ThermalProcessor.kt"
click node_android_colormap "https://github.com/beastwithin/ht203u-thermal/blob/main/android/app/src/main/java/com/beastin/ht203u/Colormap.kt"
click node_android_display "https://github.com/beastwithin/ht203u-thermal/blob/main/android/app/src/main/java/com/beastin/ht203u/MainActivity.kt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_python_app,node_desktop_capture,node_latest_frame,node_desktop_user,node_android_user toneBlue
class node_android_activity,node_uvc_library,node_android_display toneAmber
class node_temperature_decode,node_desktop_render,node_thermal_processor,node_android_colormap toneMint
class node_frame_export,node_virtual_stream toneRose
class node_ffmpeg,node_loopback,node_usb_camera toneIndigo
```

## Components

### Desktop viewer

- [Python viewer](https://github.com/beastwithin/ht203u-thermal/blob/main/thermal.py): `thermal.py`
- [Camera capture](https://github.com/beastwithin/ht203u-thermal/blob/main/thermal.py): `thermal.py`
- [Latest frame](https://github.com/beastwithin/ht203u-thermal/blob/main/thermal.py): `thermal.py`

### Android viewer

- [Android activity](https://github.com/beastwithin/ht203u-thermal/blob/main/android/app/src/main/java/com/beastin/ht203u/MainActivity.kt): `android/app/src/main/java/com/beastin/ht203u/MainActivity.kt`
- **UVC camera library**
- [Thermal display](https://github.com/beastwithin/ht203u-thermal/blob/main/android/app/src/main/java/com/beastin/ht203u/MainActivity.kt): `android/app/src/main/java/com/beastin/ht203u/MainActivity.kt`

### Frame processing

- [Temperature decode](https://github.com/beastwithin/ht203u-thermal/blob/main/thermal.py): `thermal.py`
- [Thermal rendering](https://github.com/beastwithin/ht203u-thermal/blob/main/thermal.py): `thermal.py`
- [Thermal processor](https://github.com/beastwithin/ht203u-thermal/blob/main/android/app/src/main/java/com/beastin/ht203u/ThermalProcessor.kt): `android/app/src/main/java/com/beastin/ht203u/ThermalProcessor.kt`
- [Inferno colour map](https://github.com/beastwithin/ht203u-thermal/blob/main/android/app/src/main/java/com/beastin/ht203u/Colormap.kt): `android/app/src/main/java/com/beastin/ht203u/Colormap.kt`

### Desktop outputs

- [PNG / CSV export](https://github.com/beastwithin/ht203u-thermal/blob/main/thermal.py): `thermal.py`
- [Virtual webcam](https://github.com/beastwithin/ht203u-thermal/blob/main/thermal.py): `thermal.py`

### Other components

- **Desktop user**
- **ffmpeg**
- **v4l2loopback device**
- **Android user**
- **HT-203U camera**

## Connections

- Desktop user → Python viewer: starts (evidence: `README.md`)
- Python viewer → Camera capture: opens stream (evidence: `thermal.py`)
- Camera capture → ffmpeg: reads camera (evidence: `thermal.py`)
- Camera capture → Latest frame: publishes frames (evidence: `thermal.py`)
- Latest frame → Temperature decode: provides frame (evidence: `thermal.py`)
- Temperature decode → Thermal rendering: produces temperatures (evidence: `thermal.py`)
- Python viewer → PNG / CSV export: saves frame (evidence: `thermal.py`)
- Python viewer → Virtual webcam: runs stream (evidence: `thermal.py`)
- Virtual webcam → Latest frame: reads newest frame (evidence: `thermal.py`)
- Virtual webcam → Thermal rendering: renders frame (evidence: `thermal.py`)
- Virtual webcam → ffmpeg: writes video (evidence: `thermal.py`)
- ffmpeg → v4l2loopback device: streams output (evidence: `README.md`)
- Android user → Android activity: opens app (evidence: `README.md`)
- HT-203U camera → UVC camera library: streams frames (evidence: `README.md`)
- Android activity → UVC camera library: opens camera (evidence: `android/app/src/main/java/com/beastin/ht203u/MainActivity.kt`)
- UVC camera library → Android activity: delivers frames (evidence: `android/app/src/main/java/com/beastin/ht203u/MainActivity.kt`)
- Android activity → Thermal processor: processes frames (evidence: `android/app/src/main/java/com/beastin/ht203u/MainActivity.kt`)
- Thermal processor → Inferno colour map: uses lookup table (evidence: `android/app/src/main/java/com/beastin/ht203u/ThermalProcessor.kt`)
- Android activity → Thermal display: updates image and readout (evidence: `android/app/src/main/java/com/beastin/ht203u/MainActivity.kt`)
