# Since triangle mesh is the most popular representation of 3D face,
# the main part is mesh processing.
mesh/ # written in python and c++
| cython/ # c++ files, use cython to compile
| io.py # read & write obj
| vis.py # plot mesh
| transform.py # transform mesh & estimate matrix
| light.py # add light & estimate light(to do)
| render.py # obj to image using rasterization render
mesh_numpy/ # the same with mesh/, with each part written in numpy
# slow but easy to learn and modify
# 3DMM is one of the most popular methods to generate & reconstruct 3D face.
morphable_model/
| morphable_model.py # morphable model class: generate & fit
| fit.py # estimate shape&expression parameters. 3dmm fitting.
| load.py # load 3dmm data
cd ./examples
-
3dmm.
python 2_3dmm.py
left: random example generated by 3dmm
right: fitting face with 3dmm using 68 key points
-
transform.
python 3_transform.py
left:fix camera position & use orthographic projection. (often used in reconstruction)
then transform face object: scale, change pitch angle, change yaw angle, change roll angle
right:
fix obj position & use perspective projection(fovy=30). (simulating real views)
then move camera position and rotate camera: from far to near, down & up, left & right, rotate camera
-
light.
python 4_light.py
single point light: from left to right, from up to down, from near to far
-
image map
python 6_image_map.py
render different attributes in image pixels.
: depth, pncc, uv coordinates
-
uv map
python 7_uv_map.py
render different attributes in uv coordinates.
: colors(texture map), position(2d facial image & corresponding position map)
-
Python 2 or Python 3
-
Python packages:
- numpy
- skimage (for reading&writing image)
- scipy (for loading mat)
- matplotlib (for show)
- Cython (for compiling c++ file)
-
Clone the repository
git clone https://github.com/YadiraF/face3d cd face3d
-
Compile c++ files to .so for python use (ignore if you use numpy version)
cd face3d/mesh/cython python setup.py build_ext -i
-
Prepare BFM Data (ignore if you don't use 3dmm)
-
Run examples
(examples use cython version, you can change
mesh
intomesh_numpy
to use numpy version)cd examples python 1_pipeline.py
For beginners who want to continue researches on 3D faces, I strongly recommend you first run examples according to the order, then view the codes in mesh_numpy and read the comments written in the beginning in each file. Hope this helps!
Moreover, I am new in computer graphics, so it would be great appreciated if you could point out some of my wrong expressions. Thanks!
- 2018/10/08 change structure. add comments. add introduction. add paper collections.
- 2018/07/15 first release