face-scan is a small OpenCV toolkit for running face detection across images, live camera feeds, and video files. The project now shares one reusable core instead of separate ad hoc scripts, and it adds structured summaries, audit trails, privacy redaction modes, and better output validation.
The project has been overhauled around a reusable face_scan/ package:
- Shared detector, media, workflow, and observability modules
- Safer output handling for images, recordings, snapshots, and JSON summaries
- Dedicated video-file processing via
detect_video.py - Better CLI parity across image, video, and live capture modes
- Support for camera indexes or device/file paths in live capture
- Cleaner error handling when cascades or output targets are invalid
- Lightweight tests for audit logging, JSON output, and capture-source parsing
- Python 3.x
- OpenCV
Install dependencies:
/home/wellington/env/bin/python -m pip install -r requirements.txtUse /home/wellington/env/bin/python for every command below.
/home/wellington/env/bin/python detect.py image.jpg --output annotated.jpg --summary-json reports/image.json --show-metrics --draw-labels --no-showUseful flags:
--privacy blur|pixelate|black--cascade-sha256 <sha256>--audit-log logs/audit.jsonl--log-format json --log-file logs/run.log
/home/wellington/env/bin/python detectCapture.py --camera 0 --show-metrics --snapshot-dir snapshots --record output/live.mp4 --summary-json reports/live.jsonUseful flags:
--camera 0for numeric camera indexes--camera /path/to/device-or-video-sourcefor string sources--timeout 60--reconnect-attempts 3 --reconnect-delay 0.5--privacy blur|pixelate|black
/home/wellington/env/bin/python detect_video.py input.mp4 --output output/annotated.mp4 --summary-json reports/video.json --snapshot-dir snapshots/video --sample-every 2 --show-metricsBy default this opens an annotated playback window while processing. Press q or Esc to stop early. Use --no-display for headless runs.
Useful flags:
--sample-every Nto trade accuracy for speed--max-frames Nto cap long runs--snapshot-dir <dir>to save sampled frames containing faces--privacy blur|pixelate|black
Each workflow can emit a JSON summary with fields such as:
modesourceframes_processedframes_with_facestotal_facesmax_faces_in_frameavg_faces_per_processed_frameavg_detection_seconds
If you write an audit log with --audit-log, verify the tamper-evident hash chain with:
/home/wellington/env/bin/python verify_audit.py logs/audit.jsonlRun the lightweight regression suite with:
/home/wellington/env/bin/python -m unittest discover -s tests -p 'test_*.py'