ginput
function to select the keypoints of my face. Based on a specific order, for example, from nose to mouse and from eyes to ears, I orderly selected different keypoints on my face and add four bounder points at each angles of the image. Then I utilized the scipy.spatial.Delaunay
to help me create triangulation based on selected keypoints.np.linalg.solve
function to solve the linear matrix between target triangle points and source points, I get a affinity matrix, which projects from target to source. Then I calculated the inversive affine matrix and applied it to the source points, which help me perfectly warp the image.By using an annotated dataset on https://fei.edu.br/~cet/facedatabase.html , I averaged the keypoints of each face and use it as the target to morph the images. Here is the result of average face of 200 different faces, and the top four images is part of the morphed results and bottom are the initial images.
Then I tried to morph my own face into average face and morph other's face in my face. The following is the results.
I calculated the distance between my face's keypoints and mean face's keypoints and times it by 2.0, then add it back to my face's keypoints.
I created a music video for Star Trek captains by using face morphing.