microsoft / Deep3DFaceReconstruction

Accurate 3D Face Reconstruction with Weakly-Supervised Learning: From Single Image to Image Set (CVPRW 2019)
MIT License
2.16k stars 441 forks source link

point_buf in BFM_model_front.mat ? #207

Open giracle opened 1 year ago

giracle commented 1 year ago

This is a great job, but I have some questions. Can you help me answer them? 'pointbuf' in 'BFM model_ front.mat', How to obtain the content of 'point_buf' and create the point_buf ?

HITKevin commented 1 year ago

hi dear,i encountered the same issue and i solved it. point buffer holds the adjacent tri-faces id for each vertice. the default num of faces is 8,if not,fill in with len(tri). And the point buf only used for calculating v_norm in this function:

def Compute_norm(self, face_shape):

        face_id = self.tri.long()
        point_id = self.point_buf.long()
        shape = face_shape
        v1 = shape[:, face_id[:, 0], :]
        v2 = shape[:, face_id[:, 1], :]
        v3 = shape[:, face_id[:, 2], :]
        e1 = v1 - v2
        e2 = v2 - v3
        face_norm = e1.cross(e2)
        empty = torch.zeros((face_norm.size(0), 1, 3),
                            dtype=face_norm.dtype, device=face_norm.device)
        face_norm = torch.cat((face_norm, empty), 1)
        v_norm = face_norm[:, point_id, :].sum(2)
        v_norm = v_norm / v_norm.norm(dim=2).unsqueeze(2)

        return v_norm