Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

face-tracking

Face-stabilized photo-to-video pipeline. Locks a chosen face anchor across a set of photos and renders a smooth crossfade progression video.

What it does

  1. Detects eye + nose landmarks per photo using OpenCV YuNet
  2. Computes a similarity transform (translate + rotate + scale) per photo so landmarks land at a fixed position
  3. Warps and crops all photos to a consistent output frame
  4. Renders a crossfade mp4 at target resolution

Setup

python3 -m venv venv
./venv/bin/pip install -r requirements.txt

Download the YuNet face detection model:

curl -L -o face_detection_yunet_2023mar.onnx \
  https://github.com/opencv/opencv_zoo/raw/main/models/face_detection_yunet/face_detection_yunet_2023mar.onnx

Usage

  1. Put photos in extracted/
  2. Run phase 1 — detects, aligns, builds preview grid + GIF:
    ./venv/bin/python scripts/prepare.py
  3. Review alignment_grid.png and preview.gif. Remove bad frames from aligned/ if needed.
  4. Run phase 2 — encode:
    ./venv/bin/python scripts/encode.py
    Output: ~/Downloads/gym_progression.mp4

Re-run detection from scratch: ./venv/bin/python scripts/prepare.py --rerun

Key constants

prepare.py

Constant Default Description
OUT_W, OUT_H 1080, 1920 Output frame size
ANCHOR_X, ANCHOR_Y 540, 600 Face center target in output
DETECT_W 1280 YuNet detection input width

encode.py

Constant Default Description
FPS 30 Output framerate
SOLO_FRAMES 4 Frames each photo holds alone
FADE_FRAMES 4 Crossfade frames between photos
BOOKEND_FRAMES 18 Extra hold on first + last photo

Notes

  • Photos sorted lexically by filename — works with Pixel PXL_YYYYMMDD_* naming
  • For EXIF-sorted photos, swap list_photos() sort key to read DateTimeOriginal
  • landmarks.json caches detections — delete to force re-detect
  • Bad detections (face in lower half of image) are auto-retried on cropped top 55% region

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages