Skip to main content

boltseeker is a command line tool to extract frames with lightning bolts from videos.

Project description

boltseeker

boltseeker is a command-line tool that detects and extracts frames containing lightning bolts from storm videos. It uses frame differencing and blob detection to identify sudden, spatially coherent brightness changes while ignoring persistent light sources like house lights and street lamps that don't change between frames.

How it works

For each consecutive frame pair, boltseeker computes an absolute difference image and thresholds it to isolate changed pixels. Morphological dilation merges nearby changes into coherent regions (blobs). A frame is flagged when at least one blob meets two conditions: its area exceeds a minimum size (ruling out raindrops and noise), and the mean luminance within the blob's contour in the current frame exceeds a minimum value (ruling out dark blobs from cloud or rain movement).

Installation

pip install boltseeker

Usage

usage: boltseeker [-h] [-o OUTPUT_DIR] [-d DIFF_THRESHOLD] [-a MIN_BLOB_AREA] [-l LUMINANCE_THRESHOLD] [-p PADDING] [--no-save]
                  video

Detect and extract lightning frames from a storm video.

positional arguments:
  video                 Path to the input video file.

options:
  -h, --help            show this help message and exit
  -o OUTPUT_DIR, --output-dir OUTPUT_DIR
                        Directory to save extracted frames. (default: lightning_frames)
  -d DIFF_THRESHOLD, --diff-threshold DIFF_THRESHOLD
                        Minimum per-pixel absolute difference (0-254) between consecutive frames to count a pixel as changed.
                        Raise this to ignore gradual changes like slow cloud movement or rain. (default: 25)
  -a MIN_BLOB_AREA, --min-blob-area MIN_BLOB_AREA
                        Minimum area in pixels of a connected changed region to consider. Raise this to filter out small
                        transient changes like raindrops or noise. (default: 500)
  -l LUMINANCE_THRESHOLD, --luminance-threshold LUMINANCE_THRESHOLD
                        Minimum mean luminance (0-254) within a blob's contour mask in the current frame. Filters out dark blobs
                        caused by cloud or rain movement. (default: 80)
  -p PADDING, --padding PADDING
                        Extra frames to save before/after each hit (>= 0). Ignored with --no-save. (default: 1)
  --no-save             Detect only; do not write any image files. (default: False)

Examples

# Basic usage
boltseeker storm.mp4

# Save to a custom directory
boltseeker storm.mp4 -o ~/bolts

# Detect only, no output files
boltseeker storm.mp4 --no-save

# More sensitive detection
boltseeker storm.mp4 -d 15 -l 60

# Less sensitive detection
boltseeker storm.mp4 -d 40 -a 1000

Output

Detected frames are saved as JPEG files named frame_NNNNNN_lightning.jpg. Padding frames saved around each hit are named frame_NNNNNN_padding.jpg. The terminal output lists each flagged frame with its index and timestamp as the video is scanned.

Tuning

Run with --no-save first to see which frames are flagged and at what timestamps before committing to saving files. The three detection parameters are independent:

  • If dark frames from cloud movement are being saved, raise --luminance-threshold.
  • If small rain or noise artefacts trigger false positives, raise --min-blob-area.
  • If slow-moving clouds cause false positives, raise --diff-threshold.
  • If faint or distant bolts are being missed, lower --diff-threshold or --luminance-threshold.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

boltseeker-0.1.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

boltseeker-0.1.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file boltseeker-0.1.0.tar.gz.

File metadata

  • Download URL: boltseeker-0.1.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.17.0 {"ci":null,"cpu":"x86_64","distro":{"id":"noble","libc":{"lib":"glibc","version":"2.39"},"name":"Ubuntu","version":"24.04"},"implementation":{"name":"CPython","version":"3.12.3"},"installer":{"name":"hatch","version":"1.17.0"},"openssl_version":"OpenSSL 3.0.13 30 Jan 2024","python":"3.12.3","system":{"name":"Linux","release":"6.8.0-124-generic"}} HTTPX2/2.3.0

File hashes

Hashes for boltseeker-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7a15cab0a4c2009fd85389dcd433c4179a84ad898fac99d605d4aad0686754b2
MD5 65a885077ad9d4dcc7eebaf034c2a507
BLAKE2b-256 12e9a0943f9520780f2fd4cc01be0557ac4583e65cc217a4617b3dfdc185b17b

See more details on using hashes here.

File details

Details for the file boltseeker-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: boltseeker-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.17.0 {"ci":null,"cpu":"x86_64","distro":{"id":"noble","libc":{"lib":"glibc","version":"2.39"},"name":"Ubuntu","version":"24.04"},"implementation":{"name":"CPython","version":"3.12.3"},"installer":{"name":"hatch","version":"1.17.0"},"openssl_version":"OpenSSL 3.0.13 30 Jan 2024","python":"3.12.3","system":{"name":"Linux","release":"6.8.0-124-generic"}} HTTPX2/2.3.0

File hashes

Hashes for boltseeker-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3678d4995a257b7996338e45295fcbdb50ccbc5bd64ab45eac5409166b54072c
MD5 48466cbbaed4b9fa6597d221edf8b9e1
BLAKE2b-256 056ec3d7e236e96e4ff302f1ab246ff16020dab03648a8de99c490cb3faa8d08

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page