A Script for Easily Finding Lightning Strike Stills Inside HD Video

lightning

Photographer Saulius Lukse recently decided to try his hand at shooting video to capture photos of a lightning strike rather than using a special trigger for still photos. The technique worked well, and is rather efficient thanks to a special script Lukse wrote to quickly find frames containing lightning.

Lukse started out by pointing his GoPro HERO 3 Black camera at a lightning storm and recording 15 minutes of 1080/60p footage. Sifting through the video would ordinarily require a good amount of time and manual editing, but Lukse decided to put his coding skills to good use.

He wrote a Python script that detects differences between pairs of frames — when lightning strikes, there are a good number of white pixels that quickly show up between one frame and another. The script then saves the recorded values to a CSV file and saves the entire frame as a still photo on Lukse’s computer if the difference crosses a certain threshold. Here’s a chart created using the saved numbers:

chart

The spikes indicate when lightning struck and how big the strike was. “As a result many frames with lightning being saved to disk,” Lukse tells PetaPixel.

He says the script is relatively fast: it was able to process the 15 minute video in just 8 minutes on an i7 CPU. Using the extracted lightning-frames, Lukse was able to easily put together time-lapse clips showing just the lightning strikes:

K4qaXGd

If you’re interested (and computer savvy), you can find the script Lukse wrote over on his blog.

(via Hack A Day)

Discussion