Deep-Live-Cam/modules
google-labs-jules[bot] 4e36622a47 feat: Implement Optical Flow KPS tracking for webcam performance
Introduces Nth-frame full face detection combined with KCF bounding
box tracking and Lucas-Kanade (LK) optical flow for keypoint (KPS)
tracking on intermediate frames. This is primarily for single-face
webcam mode to improve performance while maintaining per-frame swaps.

Key Changes:
- Modified `face_swapper.py` (`process_frame`):
    - Full `insightface.FaceAnalysis` runs every N frames (default 5)
      or if tracking is lost.
    - KCF tracker updates bounding box on intermediate frames.
    - Optical flow (`cv2.calcOpticalFlowPyrLK`) tracks the 5 keypoints
      from the previous frame to the current intermediate frame.
    - A `Face` object is constructed with tracked bbox and KPS for
      swapping on intermediate frames (detailed landmarks like
      `landmark_2d_106` are None for these).
    - Experimental similar logic added to `_process_live_target_v2`
      for `map_faces=True` live mode (non-many_faces path).
- Robustness:
    - Mouth masking and face mask creation functions in `face_swapper.py`
      now handle cases where `landmark_2d_106` is `None` (e.g., by
      skipping mouth mask or using bbox for face mask).
    - Added division-by-zero check in `apply_color_transfer`.
- State Management:
    - Introduced `reset_tracker_state()` in `face_swapper.py` to clear
      all tracking-related global variables.
    - `ui.py` now calls `reset_tracker_state()` at appropriate points
      (webcam start, mode changes, new source image selection) to ensure
      clean tracking for new sessions.
- `DETECTION_INTERVAL` in `face_swapper.py` increased to 5.

This aims to provide you with a smoother face swap experience with better FPS
by reducing the frequency of expensive full face analysis, while the
actual swap operation continues on every frame using tracked data.
2025-06-18 16:16:52 +00:00
..
processors feat: Implement Optical Flow KPS tracking for webcam performance 2025-06-18 16:16:52 +00:00
__init__.py Update __init__.py 2025-05-13 00:14:49 +08:00
capturer.py Revert "recommit webcam option" 2024-09-11 02:49:53 +08:00
cluster_analysis.py Added ability to map faces 2024-09-10 05:40:55 +05:30
core.py add mutil language 2025-01-07 14:04:18 +08:00
face_analyser.py fix: Lower face detection threshold for improved reliability 2025-06-13 15:11:17 +00:00
gettext.py add mutil language 2025-01-07 14:04:18 +08:00
globals.py Here's the refactor: 2025-06-07 19:53:02 +00:00
hair_segmenter.py Jules was unable to complete the task in time. Please review the work done so far and provide feedback for Jules to continue. 2025-05-31 08:55:16 +00:00
metadata.py Revert "Update metadata.py" 2025-04-17 02:39:05 +08:00
predicter.py add toggle button for blueish cam fix (Force OpenCV2 BGR2RGB) 2024-08-30 22:02:23 +02:00
typing.py initial commit 2023-09-24 21:36:57 +08:00
ui.json reverted to the old version 2024-09-19 17:38:02 +08:00
ui.py feat: Implement Optical Flow KPS tracking for webcam performance 2025-06-18 16:16:52 +00:00
utilities.py Adding Pygrabber as Cam manager 2024-12-13 19:49:11 +05:30
video_capture.py fix: Force AVFoundation for macOS camera, improve error clarity 2025-06-16 17:37:29 +00:00