rIleriaaa
blobTrack
[ 05 ]

Overview

A real-time motion blob tracker built with Dear PyGui and OpenCV — no browser, no server, just a native desktop window running a live computer-vision pipeline frame by frame. Load any video file or a live camera feed, and BlobTrack detects moving objects via background subtraction, then overlays customizable bounding shapes, labels, network-style connection lines, and a glitchy fragment scatter effect on each detected blob, all fully adjustable while playback is running. The preview always keeps the source's native aspect ratio, letterboxed against a black background rather than stretched to fill the panel. Every visual element in the sidebar maps directly onto the same frame that gets written out when you hit Record, so what you see live is exactly what gets exported, always at full native resolution regardless of the live preview scale.

BlobTrack interface showing live blob tracking with bounding boxes and connection lines

Features

  • Live motion detection — MOG2 background subtraction, with an adjustable detection rate and min/max blob area filters.
  • Customizable overlays — Square, circle, or no outline, with adjustable size, thickness, and color per blob.
  • Bounding box filters — Apply Invert, Blur, Pixelate, Thermal, or Edge effects inside each detected region.
  • Mesh connection lines — Link each blob to its k nearest neighbors with distance-based fade, for a network/web visualization.
  • Fragment Scatter effect — Copies random patches from around each blob and scatters them nearby as resized fragments, with optional borders and lines tracing back to the blob. Count, spread, regenerate rate, and border style are all adjustable.
  • Optional score labels — Each blob shows its area as a fraction of the frame. Toggle it on or off and set the font size.
  • Adjustable playback speed — 0.5x to 2x for file sources.
  • Live Resolution scaling — Native, 75%, 50%, or 25% trades preview quality for performance without affecting export quality.
  • Broad video format support — MP4, MOV, AVI, MKV, WEBM, M4V, WMV, and FLV, with case-insensitive extension matching.
  • One-click webcam access — Jump straight to a live camera feed from the video panel, no CLI needed.
  • Letterboxed preview — Video always keeps its native aspect ratio inside the panel, with black bars filling any leftover space instead of stretching.
  • Video export with audio — Save the processed feed (with all overlays) to .mp4, always at full native resolution regardless of preview settings. For file sources, the original audio is automatically muxed back in and tempo-adjusted to match your chosen playback speed.
  • Save/Load presets — Store and restore your whole look as a .json file.
  • Fullscreen toggle — Hides the sidebar, and the video panel resizes cleanly with the window.

Tech Stack

Interface: Dear PyGui, an immediate-mode GUI library that renders natively rather than through a browser or web view — chosen for how directly it can push raw frame buffers to a dynamic texture at high frame rates without the overhead a DOM-based UI would introduce. Vision pipeline: OpenCV's BackgroundSubtractorMOG2 for motion detection, followed by thresholding, morphological opening, and dilation to clean up noise before contour extraction — a classical (non-deep-learning) approach, which keeps the whole thing dependency-light and runs comfortably on CPU alone.

Frame buffers: NumPy arrays reused across frames rather than reallocated each tick, cutting allocation and garbage-collection overhead at higher resolutions. Export: OpenCV's VideoWriter, writing processed frames straight to .mp4 at a speed-adjusted FPS, locked for the duration of a recording so the exported file's timing stays consistent. Audio: ffmpeg extracts the matching audio segment, time-stretches it with atempo for non-1x speeds, and muxes it into the exported .mp4. Packaging: distributed via PyPI and installable through pipx.

How it works

Each frame runs through OpenCV's BackgroundSubtractorMOG2 to isolate moving regions, followed by thresholding, morphological opening, and dilation to clean up the mask. In the live preview, detection runs on a downscaled copy of the frame (max 640 px on the long side) and can skip frames based on the Detection Rate setting. Contours are extracted, filtered by minimum and maximum area, and the largest N are kept as tracked blobs.

Overlays (and the optional fragment effect) are drawn directly onto the frame before it's uploaded to a Dear PyGui dynamic texture for display — and, if recording, written to disk via cv2.VideoWriter at full native resolution, independent of what's shown in the live preview.

When a recording of a video file finishes, the matching audio segment is extracted with ffmpeg, time-stretched with atempo if you used a non-1x speed, and muxed into the exported .mp4.

Usage / Controls

Detection

ControlDescription
Minimum AreaFilters out blobs smaller than this pixel area.
Max BlobsCaps how many blobs are tracked per frame.
Detection RateRuns detection every N frames in the live preview (higher = faster, less responsive). Recording always detects every frame.
Maximum Area %Ignores blobs larger than this percentage of the frame, useful for filtering out camera shake or lighting changes.

Overlays

ControlDescription
ShapeBounding shape drawn around each blob (Square / Circle / None).
Bounding Size / ThicknessSize (16–512 px presets) and stroke width of the bounding shape.
Connection LinesToggles mesh-style lines between nearby blobs.
Nearest NeighborsHow many neighbors each blob connects to.
Connection Line ThicknessStroke width of the connection lines.
Bounding Box FilterVisual effect applied inside each bounding box: Invert, Blur, Pixelate, Thermal, or Edge.
Font Size / Show Score TextSize of the score label per blob, and whether it's shown at all.
Bounding Box / Connection Line ColorPreset colors or a custom color picker.

Playback and presets

ControlDescription
Playback Speed0.5x to 2x for file sources. Locked while recording.
Live ResolutionNative / 75% / 50% / 25%. Only affects the live preview; exports always render at full native resolution.
Save PresetOpens a save dialog to store your current settings as a .json preset.
Load PresetOpens a file dialog to load a saved .json preset and apply all its settings instantly.

Video panel buttons

ButtonDescription
LoadOpens a file picker to load a video.
CamSwitches to a live webcam feed without relaunching.
Pause / PlayFreezes or resumes the current frame.
FullToggles fullscreen and hides the sidebar.

Configuration options

Every option lives directly in the sidebar and takes effect on the next frame, since the app reads slider and button state live inside the render loop. Nothing is saved automatically — every run starts from the same defaults — but you can store and restore your whole look with Save Preset / Load Preset as a .json file. Detection Rate, Maximum Area %, and the Fragment Count / Regenerate Rate / Spread sliders are not currently included in saved presets.

Recording notes

  • Starting a recording rewinds the video to frame 0, unpauses it, and records from the beginning.
  • While recording, the live preview temporarily drops to 25% resolution to keep the UI smooth; your previous setting is restored when recording stops. The exported video is unaffected and stays at native resolution.
  • Recording locks the Playback Speed selector, since the export FPS is fixed at recording start.
  • Reaching the end of a file automatically stops any active recording and restarts playback from frame 0.
  • Webcam recordings are saved without audio.

Troubleshooting

  • Video won't load; the file picker supports .mp4, .mov, .avi, .mkv, .webm, .m4v, .wmv, and .flv (uppercase extensions like .MOV work too), but actual playback still depends on your OpenCV build having the right codec — if a file doesn't appear at all in the picker or fails silently once loaded, try converting it to .mp4 as the safest fallback.
  • Preview stays black after loading — check whether playback is paused, since the pause state persists across a new Load and a paused feed simply stops pulling new frames rather than indicating a failed load.
  • Recording produces an empty or truncated file — confirm the destination path in the save dialog is writable and not on a read-only or network drive.
  • Exported video has no audio — webcam recordings never include audio. For file sources, make sure ffmpeg is installed and on your PATH, since it handles extracting and muxing the audio.
  • Frame rate drops on high-resolution sources — lower the Live Resolution setting, or raise Detection Rate, during preview; neither affects the exported recording, which still renders every frame at full native resolution.

Installation

proceed to blobtrack installation