Face-stabilized photo-to-video pipeline. Locks a chosen face anchor across a set of photos and renders a smooth crossfade progression video.
- Detects eye + nose landmarks per photo using OpenCV YuNet
- Computes a similarity transform (translate + rotate + scale) per photo so landmarks land at a fixed position
- Warps and crops all photos to a consistent output frame
- Renders a crossfade mp4 at target resolution
python3 -m venv venv
./venv/bin/pip install -r requirements.txtDownload 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- Put photos in
extracted/ - Run phase 1 — detects, aligns, builds preview grid + GIF:
./venv/bin/python scripts/prepare.py
- Review
alignment_grid.pngandpreview.gif. Remove bad frames fromaligned/if needed. - Run phase 2 — encode:
Output:
./venv/bin/python scripts/encode.py
~/Downloads/gym_progression.mp4
Re-run detection from scratch: ./venv/bin/python scripts/prepare.py --rerun
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 |
- Photos sorted lexically by filename — works with Pixel
PXL_YYYYMMDD_*naming - For EXIF-sorted photos, swap
list_photos()sort key to readDateTimeOriginal landmarks.jsoncaches detections — delete to force re-detect- Bad detections (face in lower half of image) are auto-retried on cropped top 55% region