ROI = top portion of the frame (your “current lane”). Adjust until it covers where the traffic light appears.
Tweak if lighting is tricky. We count pixels in the ROI whose HSV falls inside these ranges.
Red uses two hue bands near 0 and 180; yellow is around the center shown; green is roughly opposite yellow.
Upgrade path: Replace the color-based step with a detector (YOLO ONNX via onnxruntime-web) and then classify the crop or read class directly. Keep the ROI and announcement logic the same.