Skip to content

Improve thermal camera library with community fixes#20

Closed
tdamsma wants to merge 29 commits into
stawel:masterfrom
CEAD-group:improve-thermal-library
Closed

Improve thermal camera library with community fixes#20
tdamsma wants to merge 29 commits into
stawel:masterfrom
CEAD-group:improve-thermal-library

Conversation

@tdamsma
Copy link
Copy Markdown
Collaborator

@tdamsma tdamsma commented Mar 24, 2026

Summary

Incorporates improvements from the ht301_hacklib community ecosystem into the CEAD fork.

Hot pixel detection + persistent calibration (irpythermal.py)

  • calibrate_raw() now detects both cold AND hot stuck pixels using a symmetric 5% threshold. Previously only cold/dead pixels were detected, leaving hot/stuck pixels uncorrected.
  • New save_calibration(path) / load_calibration(path) methods to persist reference frame and dead pixel mask as .npy files, surviving restarts without re-running shutter calibration.
  • Fix resource leak: find_device() now releases cameras that don't match supported resolutions
  • Replace bare except: with except Exception:

OpenCV int cast fix (utils.py)

  • Cast coordinates to int() in drawTemperature() — OpenCV rejects float coordinates from numpy
    • Source: uncommitted fix found on remote machine (/home/daniel/git/t2s/)

Remove skimage dependency (opencv.py)

  • Replace skimage.exposure.equalize_hist + rescale_intensity with cv2.normalize + cv2.equalizeHist
  • Same visual result, eliminates scikit-image (and its transitive deps) for simpler deployment

Build system (pyproject.toml)

  • Migrate from poetry to uv/PEP 621 format
  • Add missing runtime dependencies

References

Test plan

  • Deploy to Linux machine with T2S+ camera (ssh thijsd@172.16.88.136)
  • Run opencv.py — verify live view with temperature overlay
  • Verify hot pixel detection during calibrate_raw()
  • Test save_calibration / load_calibration round-trip
  • Confirm temperature readings are sane (compare with known reference)

diminDDL and others added 29 commits May 29, 2024 13:53
Added all changes to main
error was
```
cv2.error: OpenCV(4.10.0) 👎 error: (-5:Bad argument) in function 'inRange'
> Overload resolution failed:
> - upperb is not a numpy array, neither a scalar
> - Expected Ptr<cv::UMat> for argument 'upperb'
```
…ix ruff findings

Introduces an "AppState" as an intermediate solution for global variables. This makes
access to global stuff more visible, but should vanish step by step (by
more explicit dependency injection and data modelling)
Make project capable of running inside a virtual environment and format sources
irpythermal.py changes:
- calibrate_raw() now detects both cold AND hot stuck pixels using
  symmetric 5% threshold (previously only detected cold pixels)
  Source: diminDDL/IR-Py-Thermal PR stawel#4
  diminDDL#4

- Add save_calibration() and load_calibration() methods to persist
  reference frame and dead pixel mask as .npy files across restarts
  Source: MCMH2000/OpenHD_HT301_Driver noise_pattern_calibration.npy approach
  https://github.com/MCMH2000/OpenHD_HT301_Driver

- Fix resource leak in find_device(): release cameras that don't match
  supported resolutions instead of leaving them open

- Replace bare except with except Exception
Cast x, y, tx, ty coordinates to int() before passing to cv2.line()
and cv2.putText(). OpenCV requires integer coordinates and fails with
float values from numpy operations.

Source: uncommitted fix found on remote machine /home/daniel/git/t2s/
Replace skimage.exposure.equalize_hist + rescale_intensity with
cv2.normalize + cv2.equalizeHist. Same visual result, eliminates
the scikit-image dependency (and its transitive deps) making
deployment on headless Linux machines simpler.
Convert build system from poetry-core to uv/PEP 621 project format.
Add missing runtime dependencies (av, opencv-python, pyusb, imageio).
@tdamsma tdamsma closed this Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants