π¬ Live Detection Lab
Press play β the AI analyses every frame live: flame colours (HSV), flicker check, temporal alarm. Switch scenarios to see it catch fire and stay silent on a safe room.
Same algorithm as the Python system: HSV segmentation β flicker gate β 5-of-10 temporal alarm.
βοΈ How It Works
Four stages, from pixels to alarm β pure computer vision, no training data, runs on CPU.
Colour Segmentation
Each frame goes to HSV colour space; redβorangeβyellow pixels that are bright and saturated are extracted as flame candidates.
Noise Cleanup
Morphological open/close removes speckles. Only blobs above a minimum area count β tiny glints are ignored.
Flicker Check
Real flames dance. The flame area must jitter frame-to-frame β this rejects static orange objects like lamps or posters.
Temporal Alarm
Fire must be confirmed in 5 of the last 10 frames before the alarm fires; 15 quiet frames reset it. No single-frame false alarms.
β Test Results
Measured on real video β the same numbers the Python system produced.
| Test | Expected | Result |
|---|---|---|
| Real fireplace clip (246 frames) | Alarm | β PASS β alarm at 0.3 s |
| Lab fire video (8 s fire + 4 s calm) | Alarm, then clear | β PASS β alarm on, auto-clears |
| Safe room + static orange lamp (90 frames) | Silent | β PASS β flicker gate rejects lamp |
| Unit tests (pytest) | 6/6 | β 6/6 passed |
π» Code & Report
Full Python system β detector, CLI app, tests and report.
fire-alarm/ βββ fire_detector.py # FireDetector: HSV + flicker + temporal alarm βββ main.py # CLI: video file / webcam β annotated output + siren βββ make_synth_fire.py # synthetic fire test-video generator βββ tests/ # 6 unit tests + 3 test videos βββ README.md