A computer vision program to extract lightning strikes! ⚡
A Jupyter Notebook that extracts lightning images from videos of storms! :lightning:
Sometimes I like to set up my camera during storms, but watching hours of footage after a lightning storm is time consuming and not very fun. I went to find an existing script to perform this task, and found one written in Python 2 by programmer and mad scientist Saulius Lukse. I converted the handy script to Python 3, and fit the whole thing into a Jupyter notebook for easy access.
Currently, the notebook takes a video and uses OpenCV to extract frames and dectect a difference between frames. If the difference exedes the threshold, then the image passes and is saved as a jpg. You can tune the threshold to suit your individual video; on a ten minute video, this program can extract less than a hundred frames or several thousand, depending on the threshold.
Future design should be a standalone program, so that stormchasers don't have to wrangle with software as much.
First, create a new environment in Anaconda and activate it. Install libopencv, opencv, py-opencv, and pillow to the new enviroment.
Next, create a folder with a lightning video inside; this folder will be filled with images by the lightning frame extractor.
Then, open the lightning extractor notebook. Set the filename to match your lightning video filename; on Linux,
filename = '/home/user/Videos/Camera/lightning.mp4'
Finally, set an appropriate threshold for your video. On the example video, the optimum threshold is around 500,000; the higher the threshold, the faster the process will run and the less output images you will get. You will have to experiment to find the best threshold, but starting high and going lower is the best approach. Once the threshold is set, run the notebook and wait a bit. The program will take a few minutes to run.
Distributed under the MIT License. See LICENSE
for more information.
Liam Plybon - [email protected]
Project Link: https://github.com/blablabliam/Lightning-Analyzer