FaceSwap Engine  1.0
FaceSwap Engine Documentation

Project Code Overview

The FaceSwap Engine is a software library designed to detect and swap faces within an image. It uses computer vision techniques to identify facial features, allowing for the exchange of faces between individuals. The engine's logic adapts based on the number of faces detected: if two faces are found, they are swapped. If more than two are present, the largest face is copied onto all others.

Key Components

Core Classes

Face Detection and Landmark Mapping

core::face::FaceDetectorYunet: This class is responsible for the initial step of detecting the presence and location of faces in an image, utilizing OpenCV's robust DNN-based model.

core::face::FaceMesh: Once faces are detected, this class generates a detailed mesh of facial landmarks for each one. These landmarks are critical for accurately mapping the geometry of the source face onto the target face.

Swapping and Rendering

visualization::FaceDrawer: This utility class contains the core rendering logic. Its drawFaceSwap method takes the landmarks from a source and target face, calculates the necessary transformations to warp the source face's texture, and seamlessly blends it onto the target face's position and orientation.

Temporal Smoothing for Video

core::filter::LandmarkFlowFilter: To improve stability in video sequences, this class implements a filter to track facial landmarks smoothly across consecutive frames. This helps reduce jitter and ensures the swapped face remains properly aligned during motion.

Function Highlights

File and Dependency Structure

The project files are organized in the C:/Projects/Engine/AntalEngine/Engine directory. Key header files include: