A small Python tool that reads an .mp4 of a storm, scans it frame
by frame, and spits out the exact moments a bolt fired. No machine learning,
no cloud — a laptop and OpenCV.
Adapted from the original idea by lukse.lt. MIT licensed.
Point a camera at the storm. Long continuous video of the night sky,
most frames near-black.
Diff consecutive frames. OpenCV reads the video frame by frame and
computes the brightness delta between each frame and the one before it.
Threshold the spike. A bolt is a sudden, massive jump in total
brightness. When the diff crosses a threshold, that frame is a strike.
The threshold is the noise filter — crank it up to kill false positives
from sensor grain, car headlights, etc.
Log to CSV. Every frame's diff value is written out, so you can
plot the signal and tune the threshold against real data.
Cut the clips. Detected windows get sliced out into the short
loops you see above.
python lightning-detection.py /path/to/storm.mp4 100000
# video threshold (higher = stricter)
Why it works: lightning is the rare event
where almost the entire frame brightens at once. A dumb sum-of-differences beats
a neural net here — cheaper, faster, and nothing to train.