This commit includes:
- Refactored modules/ui.py: Live webcam preview loop now uses ROOT.after() for better UI responsiveness and potentially smoother external capture.
- Refactored modules/video_capture.py: Implemented threaded, non-blocking frame reads for improved camera capture performance and stability.
- Feature: Ear preservation for Poisson blending to reduce artifacts (controlled by --preserve-ears and related globals).
- Feature: Histogram-based color correction (--color-correction).
- Feature: Poisson blending for smoother face integration (--poisson-blending).
These changes aim to improve overall swap quality, UI stability, and address reported FPS issues with external capture tools like SplitCam.
- Added functionality to preserve target's ears when using Poisson blending.
- Introduced new global variables in `globals.py`:
- `preserve_target_ears` (boolean flag)
- `ear_width_ratio`
- `ear_height_ratio`
- `ear_vertical_offset_ratio`
- `ear_horizontal_overlap_ratio`
- Added command-line argument `--preserve-ears` to `core.py`.
- Modified `face_swapper.py` to adjust the Poisson blending mask by
subtracting calculated ear regions if `preserve_target_ears` is true.
This aims to reduce artifacts around ears by using the original target
frame's ear content.
- Updated `face_swapper.py` to prioritize using the face bounding box (bbox) for creating the Poisson blending mask. This provides a tighter mask around the swapped face area, aiming to reduce artifacts near ears/hairline.
- Implemented fallback to landmark-based convex hull if bbox is invalid or unavailable.
- Added logging for mask generation issues and skipping blending if no valid mask can be created.
- Added histogram-based color correction to `face_swapper.py` for improved color matching of the swapped face to the target frame. Controlled by `--color-correction`.
- Integrated Poisson blending (`cv2.seamlessClone`) for smoother face integration, reducing visible seams. Controlled by `--poisson-blending`.
- Added global variables `use_poisson_blending` and `poisson_blending_feather_amount` and corresponding command-line arguments.
- Refined argument parsing in `core.py` for new features.
- Updated `swap_face` logic to incorporate these features and handle potential errors during blending.
- Add explicit checks for face detection results (source and target faces).
- Handle cases when face embeddings are not available, preventing AttributeError.
- Provide meaningful log messages for easier debugging in future scenarios.
Added:
- try-finally Block: This makes sure the camera.release() is called no matter how the while loops end.
- Resource Cleanup: The finally block takes care of cleaning up resources to keep the application stable.
The following changes have been implemented:
-A "clear" button has been incorporated.
-The Source x Target Mapper window has been retained following the submission of data via the "submit" button.