Measuring energy consumption using a pulse-output electricity meter and reading data via RTSP with OpenCV
- Running RTSP server
- Electricity Meter π
- Python = 3.12.3
Note: If using Adafruit IO you need to create a feed with the name energy and pulses in your Adafruit IO account.
- Create python virtual environment named
env/ - Install Required pip packages
- Create
.envfile follow.env-sampleand change the value needed. - Run
main.py
- Note: Red appears at both low and high ends of the hue spectrum so you need to get both for wide range red detections.
π We need two masks for Red In the HSV (Hue, Saturation, Value) color model:
- Hue is represented as a circular value β typically from 0 to 360 degrees or 0 to 180 in OpenCV.
- Red appears at both low and high ends of the hue spectrum:
- Red starts near 0Β°
- And loops back around at ~360Β° , which maps to 0Β° again So in OpenCV, where hue values go from 0 to 179 , red spans two discontinuous regions:
- Lower red : ~[0β10] (dark reds)
- Upper red : ~[170β180] (magentas and bright reds)
Red β Orange β Yellow β Green β Blue β Purple β Magenta β Red ...
β ---------------------------------------------------------------- β
0Β°- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 180Β°
- GO
debug/folder - Run the
get_hsv_color.py - Adjust the slider to get the desired color.
- Get the value and update it in
.env