# Real-Time Person Anonymizer Background-subtraction person anonymizer in pure OpenCV — no ML model required. ## Overview `Final.py` detects people in a live webcam stream using classical background subtraction and change them with a mosaic or Gaussian blur in real time. The system learns a static background over a 10-second warmup, then masks subsequent motion through a five-stage pipeline (foreground diff, morphology cleanup, contour merging, feathered anonymization). It runs on any laptop CPU with only OpenCV and NumPy. ## Features - Real-time person detection without a pre-trained model - Two anonymization modes: irreversible mosaic and Gaussian blur - Interactive camera setup with exposure / white-balance / focus sliders - Live threshold tuning during the main loop - "Too close" protection (disables blurring when the person mask exceeds 55 % of the frame) - XVID-encoded `.avi` recording of the anonymized stream ## Requirements - Python 3.x and a webcam - `pip install opencv-python numpy` ## Quick start ``` python Final.py --camera 1 ``` ## CLI arguments | Flag | Default | Description | |---|---|---| | `--camera N` | 1 | Camera index | | `--output FILE` | timestamped `.avi` | Output filename | | `--width N` | 640 | Capture width | | `--height N` | 480 | Capture height | ## Keybindings — setup screen | Key | Action | |---|---| | `[` / `]` | Previous / next camera | | Mouse | Buttons and sliders | | `SPACE` | Proceed to warmup | | `q` | Quit | ## Keybindings — main loop | Key | Action | |---|---| | `q` | Quit | | `b` | Re-capture background | | `+` / `-` | Decrease / increase BGR threshold | | `[` / `]` | Decrease / increase HSV threshold | | `m` | Toggle mosaic ↔ Gaussian | | `n` / `N` | Decrease / increase mosaic block size | | `1` / `2` / `3` | Overlay / anonymized (records) / debug | | `p` | Pause | ## Project structure - `Final.py` — main application (originally `Modified_Blur_V3_1_1.py`) - `Modified_Blur*.py`, `person_blur.py` — earlier versions, kept for reference - `modified_blur_pipeline_workflow.svg` — five-stage pipeline diagram - `PROJECT_DOCUMENT.md` — full design document ## Known limitations - Requires a static camera and a person-free warmup scene - Lighting drift invalidates the background (press `b` to recapture) - Slow movers are absorbed into the background - Fingertip dropouts may persist See `PROJECT_DOCUMENT.md` for tuning guidance.