REAL-TIME DETECTION RUNNING IN YOUR BROWSER

AI-Based Fire Alarm System

A computer-vision fire alarm that watches a camera feed, detects flames and raises the alarm β€” no smoke-sensor hardware needed. The detection below runs live, frame by frame, right here.

by Muhammad Haseeb Β· Roll No. 050

πŸ”¬ 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.

Press play to start
β€” alarm log ready β€”

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.

1

Colour Segmentation

Each frame goes to HSV colour space; red→orange→yellow pixels that are bright and saturated are extracted as flame candidates.

2

Noise Cleanup

Morphological open/close removes speckles. Only blobs above a minimum area count β€” tiny glints are ignored.

3

Flicker Check

Real flames dance. The flame area must jitter frame-to-frame β€” this rejects static orange objects like lamps or posters.

4

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.

TestExpectedResult
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