Skip to content

Keep subtitles off faces: anchor auto (T-5) - #61

Merged
IsraelWebDev merged 1 commit into
mainfrom
face-aware-captions
Nov 22, 2026
Merged

IsraelWebDev merged 1 commit into
mainfrom
face-aware-captions

Conversation

@IsraelWebDev

@IsraelWebDev IsraelWebDev commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

T-5: captions keep off faces

video subtitles now defaults to anchor="auto". For each cue, the frame at the cue's midpoint is read, faces are found, and the least busy anchor whose caption box touches no face is used. The audit (<name>.text_audit.json) records each cue's anchor, the faces seen, and whether the caption is clear.

Face finder and licence

  • OpenCV's haarcascade_frontalface_default.xml, shipped in the opencv-python-headless 4.x wheel under Apache-2.0. No model download.
  • YuNet was rejected: its training lineage includes WIDER FACE, licensed CC BY-NC-ND 4.0 (no commercial use).
  • OpenCV 5 dropped the cascade files, so the transcribe extra pins opencv-python-headless>=4.10,<5. This is a new dependency; pyproject.toml is kept in sync (test_pyproject_in_sync_with_requirements).

Behaviour changes

  • Default anchor is now auto (was bottom). Without OpenCV, or if a frame cannot be read, it falls back to bottom and the audit says why. Nothing fails.
  • anchor accepts auto, top, center, bottom. An explicit anchor is kept and not checked.

Limits

  • Haar is older and less accurate than neural detectors. It misses faces turned far to one side and some faces in poor light. The audit shows the count per cue, so a miss is visible.
  • One frame per cue (midpoint). A face that moves during a long cue is not tracked.
  • No real-face image is in the repo (licence-clean talking-head clip still wanted). The real-cascade test runs on a blank frame; the face logic is tested with a stubbed detector.

Tests

  • tests/test_faces.py: overlap rule; auto keeps the caption off a face (stubbed); auto falls back and says so without OpenCV; fixed anchor not checked; unknown anchor refused; real cascade finds no face in a blank frame (skipped without OpenCV 4.x).
  • Updated test_tool_options enum; catalog regenerated and --check passes; ruff check and ruff format --check clean.
  • Run locally: test_video, test_catalog, test_tool_options, test_server, test_p6_install, test_caption_timing, test_faces: all pass (the real-cascade test passes with OpenCV 4.10.0.84).

https://claude.ai/code/session_017qYKdYke3ySSZS76W9Tp34


Generated by Claude Code

The subtitle anchor now defaults to "auto". For each cue, the frame at the cue's midpoint is read, faces are found with
OpenCV's Haar cascade, and the least busy anchor whose caption box touches no face is used. The audit records the
anchor, the faces seen, and whether the caption is clear. Without OpenCV, or if the frame cannot be read, it falls back
to bottom and the audit says why.

Face finder: OpenCV's haarcascade_frontalface_default.xml, shipped in the opencv-python-headless 4.x wheel under
Apache-2.0. YuNet was rejected: its training lineage includes WIDER FACE (CC BY-NC-ND, no commercial use).
OpenCV 5 dropped the cascade files, so the transcribe extra pins <5.

Haar is older and less accurate than neural detectors: it misses faces turned far to one side and some in poor light.
The audit makes that visible per cue.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017qYKdYke3ySSZS76W9Tp34
@IsraelWebDev
IsraelWebDev merged commit 981d63c into main Nov 22, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants