🛎️ A hobby involving collecting provisions includes monitoring passive
Bluetooth temperature, analyzing sound with PSD and FFT tools, and now adding
visual monitoring through a webcam focused on seven-segment indicators.
Why
The
previous project for detecting the on/off state of the kitchen refrigerator by sound analyses has been stopped. The built-in microphone’s sound quality was so poor and noisy that I decided to abandon it and switch to a more reliable method: visually monitoring the refrigerator’s power consumption by reading the amperage, with 00.0A indicating OFF and 00.7A or 00.8A indicating ON.
How
📼 Seven Segment Monitor is a computer vision and IoT tool that
continuously captures images from a USB or V4L2 camera, or static frames, of
seven-segment displays. It uses OpenCV to extract and recognize numeric
readouts, then stores the parsed readings in an SQLite database with automated
retention and cleanup.
 |
Example of a development result
|
 |
| A development laptop with sunglasses used as a pre-filter for the webcam to reduce lighting from seven-segment LED indicators on a surge voltage device. |
Features
- Multi-threaded Architecture:
-
Camera Producer: Captures frames asynchronously from a V4L2/USB camera or
loads them from disk for testing or simulation.
-
Vision Worker: Handles automatic rotation correction, color and brightness
filtering, shear de-skewing, digit box slicing, and segment state
recognition.
-
Database Writer Worker: Batches writes and saves timestamped readings and
alert/state statuses to SQLite.
-
Database Cleanup Worker: Purges records older than a configurable
retention period automatically.
- Multiple Color & Mask Extraction Algorithms:
-
WITHOUT_GREEN: Difference-based channel masking for red LED displays.
- RED: Dual-band HSV color masking.
-
RED_ADAPTIVE: Adaptive thresholding based on the green-to-red pixel ratio.
- Display Layout Customization:
-
Configurable rows and digits per row (NUM_DIGITS_ROWS,
NUM_DIGITS_PER_ROW).
-
Shear angle compensation for slanted italicized digits
(DIGIT_SHEAR_ANGLE).
- Digit density and segment activation threshold tuning.
- Deployment Ready:
- Run directly via Python CLI (sevensegmentmonitor).
-
Run containerized via headless Docker Compose with optional Grafana
integration.
Repositories: