Station open - training dossier Hangar Brief / UAV school Public release - not classified
Aviation dossier Hangar Brief

Home / FPV Video processing with Raspberry Pi

19 Oct 2026

Smoke and flame on an FPV stream

Lab 07 / Wildfire cue

Blueprint of an FPV picture feeding the wildfire detector: smoke as an early plume, flame as fire in progress, and an optional lamp on the bench.
SIG-11 – Same grounded picture as the other labs. This one looks for smoke and flame. A person still confirms it.

Purpose

Run wild_fires_detection_ai (https://github.com/mesudpasic/wild_fires_detection_ai) on a picture that is already coming from an FPV aircraft. The Raspberry Pi stays on the bench. The aircraft keeps its camera and video transmitter.

The project watches a live stream for two things. Smoke is the early stage: a moving gray or white plume. Flame is fire in progress: an orange, red, or yellow region that is also moving. The default engine is OpenCV colour and motion. It needs no downloaded weights, so it runs on a Pi. YOLO is the optional heavier engine and is not what this lab starts.

A match can pulse a small light on a GPIO pin. That light is a cue for the person at the bench. This is not a fire service, and it is not a certified alarm. A sunset, a rust roof, or dust can still draw a box. A person confirms the picture before anyone treats it as a fire.

The same six sockets from the earlier labs feed this one. USB analog, USB HDMI, and a V4L2 loopback are camera numbers, which is what the project's own command line accepts. An rtsp://, rtmp://, or http:// address is opened by the project's VideoRunner. UDP H.264 is not a camera number. Decode it with lab 04 or lab 06, then point this script at that device.

The project license is non-commercial. Training on this station fits. A paid service does not, without a written license from SETEC.

Words

  • FPV (First Person View). The live picture from the aircraft.
  • VTX (Video Transmitter) and VRX (Video Receiver). The picture radio on the aircraft, and the box on the bench that receives it.
  • OpenCV (Open Source Computer Vision Library). The default engine. No extra model file.
  • HSV (Hue, Saturation, Value). A way to describe colour as "what hue, how strong, how bright." Flame looks for warm hues.
  • YCrCb. Another colour split. Y is brightness. Cr and Cb are the colour axes. A high Cr helps separate flame from brown earth.
  • MOG2 (Mixture of Gaussians, version 2). A background model. Smoke is the part of the frame that is gray and also moving.
  • CLI (Command Line Interface). The project's python -m wild_fires_detection_ai.main command.
  • JSON (JavaScript Object Notation). The result printed when the run ends: found or not, smoke or flame, and when.
  • GPIO (General Purpose Input/Output). A pin on the Pi that can light a lamp or close a relay.
  • BCM (Broadcom). The pin numbering gpiozero uses. The project default is BCM 17.
  • YOLO (You Only Look Once). The optional neural-net engine. Heavier. Leave it off on a Pi unless you have weights and a reason.
  • V4L2 (Video for Linux 2). A camera number such as 0 or /dev/video2.
  • RTSP (Real Time Streaming Protocol), RTMP (Real Time Messaging Protocol), and HTTP (Hypertext Transfer Protocol). Network addresses for a picture. Labs 03 and 05 walk through opening them.
  • UDP (User Datagram Protocol) and H.264 (Advanced Video Coding). The digital packet stream from lab 04. Bring it in through a camera device first.

What you need

  • A working picture from one of labs 01 to 06
  • Python 3.11 or 3.12
  • The project cloned beside codes/:
cd ..
git clone https://github.com/mesudpasic/wild_fires_detection_ai
python3 -m venv wild_fires_detection_ai/env
wild_fires_detection_ai/env/bin/pip install -r wild_fires_detection_ai/requirements.txt

On the Pi, sudo apt install python3-opencv is enough for the colour engine if you would rather not build a venv. Set SHOW_WINDOW=false in the project's .env when the Pi has no desktop.

Run

From this folder, with the venv active:

python3 detect_wildfire.py --source 0
python3 detect_wildfire.py --source 2
python3 detect_wildfire.py --source rtsp://192.168.1.40:8554/fpv
python3 detect_wildfire.py --source http://192.168.1.50:8080/video --classes smoke

The project's own command, for a camera number only:

python3 -m wild_fires_detection_ai.main --video-source-type stream --stream-source 0 --detect-classes smoke,flame

Press q if a window is open, or Ctrl+C. MAX_FRAMES=0 means the stream runs until you stop it. JSON is printed at the end.

A GPIO lamp, if you wire one, uses BCM 17 and stays on for about ten seconds per new match. No lamp is required. Off a Pi the light call only writes a log line.

What the code does

detect_wildfire.py finds the cloned package, builds FireEngineCV, and calls VideoRunner with your source. Smoke boxes are the early stage. Flame boxes are fire in progress. The runner skips some frames (FRAME_EVERY) so a Pi can keep up, and it shrinks the scan to PROCESS_WIDTH before the colour work.

Lower SMOKE_MIN_AREA_PX and FLAME_MIN_AREA_PX in the project's .env if the fire is a small mark in a wide FPV shot. Raise them if roofs and sunsets keep matching.

Command

python3 detect_wildfire.py --source 0

detect_wildfire.py

#!/usr/bin/env python3
"""Look for smoke and flame in an FPV picture. The Pi stays on the bench.

Uses SETEC's wild_fires_detection_ai package:
https://github.com/mesudpasic/wild_fires_detection_ai

The published command line only accepts a camera number. A USB capture,
an HDMI grabber, and a V4L2 loopback are camera numbers, so they match.
An rtsp://, rtmp://, or http:// address is handed to the same VideoRunner,
which opens it with OpenCV. UDP H.264 is not a camera number. Decode that
with lab 04 or lab 06, then pass the resulting /dev/video index here.

This is an early cue for a person watching the picture. It is not a fire
brigade, and it is not a certified alarm.
"""

import argparse
import json
import os
import sys
from pathlib import Path

os.environ.setdefault("SHOW_WINDOW", "true")
os.environ.setdefault("MAX_FRAMES", "0")
os.environ.setdefault("ENGINE", "cv")
os.environ.setdefault("DETECT_CLASSES", "smoke,flame")
os.environ.setdefault("FRAME_EVERY", "5")
os.environ.setdefault("PROCESS_WIDTH", "640")


def find_package():
    here = Path(__file__).resolve()
    candidates = [
        here.parents[2] / "wild_fires_detection_ai",
        here.parents[1] / "wild_fires_detection_ai",
        here.parents[2].parent / "wild_fires_detection_ai",
    ]
    for folder in candidates:
        engine = folder / "utils" / "fire_engine_cv.py"
        if engine.is_file():
            return folder.parent
    return None


def open_source(raw):
    if raw.isdigit():
        return int(raw)
    lowered = raw.lower()
    if lowered.startswith(("rtsp://", "rtmp://", "http://", "https://")):
        return raw
    raise SystemExit(
        "Pass a camera number (0, /dev/video2 -> 2) or an rtsp://, rtmp://, or http:// URL.n"
        "For UDP H.264, decode it onto a V4L2 device first (lab 04 or lab 06), then pass that number."
    )


def main():
    parser = argparse.ArgumentParser(
        description="Detect smoke and flame on a grounded FPV picture."
    )
    parser.add_argument(
        "--source",
        default="0",
        help="V4L2 camera number, or an rtsp:// rtmp:// http:// URL",
    )
    parser.add_argument(
        "--classes",
        default="smoke,flame",
        help="smoke, flame, or both. smoke is the early stage. flame is fire in progress.",
    )
    args = parser.parse_args()
    os.environ["DETECT_CLASSES"] = args.classes

    package_parent = find_package()
    if package_parent is None:
        raise SystemExit(
            "Clone https://github.com/mesudpasic/wild_fires_detection_ai "
            "so the folder wild_fires_detection_ai sits next to the codes/ folder."
        )
    sys.path.insert(0, str(package_parent))

    from wild_fires_detection_ai.utils.classes import parse_detect_classes
    from wild_fires_detection_ai.utils.fire_engine_cv import FireEngineCV
    from wild_fires_detection_ai.utils.raspberry_pi import RaspberryPiLight
    from wild_fires_detection_ai.utils.video_runner import VideoRunner

    detect_classes = parse_detect_classes(args.classes)
    engine = FireEngineCV(detect_classes=detect_classes)
    runner = VideoRunner(engine, detect_classes=detect_classes)
    source = open_source(args.source)

    with RaspberryPiLight() as light:
        result = runner.run(
            input_type="stream",
            stream_source=source,
            light=light,
        )
        light.wait()

    print(json.dumps({"status": True, "result": result, "message": ""}, indent=2))


if __name__ == "__main__":
    main()

Clone wild_fires_detection_ai beside the codes/ folder, then run the command above from this lab folder. The Pi stays on the ground. A match is a cue for a person, not a certified alarm.