FaceConverter
FaceConverter copied to clipboard
Face swap and 3D alignment from a single image based on PRNet
C++ implementation of PRNet on iOS
This project contains:
- Face reconstruct(Face swap) from only a single image.
- Face pose estimate and keypoints(68) in 3D model.
The origin python code with training is in PRNet.
Platfrom and requirements
1. iPhone SE, arm64
2. OpenCV 3.4.0
3. NCNN
Outline
- Mtcnn --> resize to 256x256 --> PRNet --> UV,Z --> Render 86906 triangles in 3D --> SeamlessClone
- Mtcnn --> resize to 256x256 --> PRNet --> 43867 vertices --> SVD to estimate pose Mtcnn --> resize to 256x256 --> PRNet --> 43867 vertices --> pick 68 points for sparse alignment

Application
- Face Swap, change the target face image(@"ref.jpg") to your own.
- Face 3D pose estimate and face keypoints in 3D.








About the configuration
There's 4 config files in this project.
1. face_ind.txt
This file is the index of [0,65535], which is the region of the WHITE area of the image[256x256] below.

2. uv_kpt_ind.txt
This file is the index of coordinate(x,y) for 68 keypoints refer to face_ind.txt

3. triangles.txt
86906 triangles' vertices index refer to face_ind.txt

4. canonical_vertices.txt
canonical model for pose estimate, there's coordinate (uv,z) of 43867 vertices
Other details
- About the Euler angles.
http://www.gregslabaugh.net/publications/euler.pdf
- 3D points transformation matrix.
http://nghiaho.com/?page_id=671
- Render 3D texture.
http://blackpawn.com/texts/pointinpoly/