From 4ab76492b01a7913533ae4ff1f58022b24307c8c Mon Sep 17 00:00:00 2001 From: YadiraF Date: Sat, 28 Apr 2018 22:26:06 +0800 Subject: [PATCH] add front func --- utils/rotate_vertices.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 utils/rotate_vertices.py diff --git a/utils/rotate_vertices.py b/utils/rotate_vertices.py new file mode 100644 index 0000000..73c42ee --- /dev/null +++ b/utils/rotate_vertices.py @@ -0,0 +1,11 @@ +import numpy as np + +# import scipy.io as +def frontalize(vertices): + canonical_vertices = np.load('Data/uv-data/canonical_vertices.npy') + + vertices_homo = np.hstack((vertices, np.ones([vertices.shape[0],1]))) #n x 4 + P = np.linalg.lstsq(vertices_homo, canonical_vertices)[0].T # Affine matrix. 3 x 4 + front_vertices = vertices_homo.dot(P.T) + + return front_vertices