def render_lsd(seq): plypath = os.path.join(seq, 'render_me.ply') verts, edges = IO.read_ply(plypath) lsd_mesh = Mesh() lsd_mesh.verts = verts.astype(np.float32) campath = os.path.join(seq, 'render.py') Rs, ts = IO.import_blender_cam(campath) W, H = 1920, 1080 im = empty((H, W, 3), np.uint8) cam = Geom.cam_params(29.97, W, H, 35) # Blender defaults cam = cam.astype(np.float32) render_out = os.path.join(seq, 'render') Util.try_mkdir(render_out) im[:] = 255 pts = lsd_mesh.project_verts(Rs[0].astype(np.float32), ts[0].astype(np.float32), cam) pt_buf = buffer_points(pts, np.r_[255, 82, 82], alpha=0.2, size=2) render_buffer(im, pt_buf, bg=255) out = os.path.join(render_out, 'frame_0.png') IO.imwrite(out, im)
def spsolve_chol(sparse_X, dense_b): factor = cholesky_AAt(sparse_X.T) return factor(sparse_X.T.dot(dense_b)).toarray() # robust_lm = np.array( [36, 39, 42, 45, 30, 48, 54]) bfm_landmark_indices = np.array( [2088, 5959, 10603, 14472, 8319, 5781, 11070, 19770, 35341]) #right eye out, in, left eye in,out , nosetip, right lip, left lip , right ear, left ear seq = '/home/shubham/datasets/groundtruth/head_mesh/Kurth/' meshpath = seq + 'Kurth.ply' target = IO.read_ply(meshpath, return_normals=False, return_faces=False) print("Done reading target...") gt_lms_path = seq + '/lms.txt' gt_lms = np.loadtxt(gt_lms_path) nL = gt_lms.shape[0] mesh, meshfaces = read_obj('mean.obj') tls = meshfaces - 1 print("template mean mesh norm :", np.linalg.norm(mesh[2087, :] - mesh[14471, :])) print("ground truth mesh norm: ", np.linalg.norm(gt_lms[0] - gt_lms[3])) ##scale up template mesh## scale = np.linalg.norm(mesh[2087, :] -
def from_ply(path): verts, faces = IO.read_ply(path) mesh = Mesh() mesh.verts = verts.astype(np.float32) mesh.faces = faces.astype(np.uint32) return mesh