Face Image Rotation using camera matrix and 3D morphable model?

25 Views Asked by At

community, I am trying this code for 3D face reconstruction. How can I generate front output faces in the test step? is this related to the camera_matrix or the 3DMM model? I mean I want to fix the position to zero angle. and thank you in advance.

def euler_rotation(rot_param):
    rx_mul = torch.Tensor([[0, 0, 0, 0, 1, 1, 0, 1, 1]]).to(rot_param.device)
    rx_add = torch.Tensor([[0, 1, 1, 1, 0, 1, 1, 3, 0]]).to(rot_param.device) * math.pi / 2.0
    ry_mul = torch.Tensor([[1, 0, 1, 0, 0, 0, 1, 0, 1]]).to(rot_param.device)
    ry_add = torch.Tensor([[0, 1, 3, 1, 0, 1, 1, 1, 0]]).to(rot_param.device) * math.pi / 2.0
    rz_mul = torch.Tensor([[1, 1, 0, 1, 1, 0, 0, 0, 0]]).to(rot_param.device)
    rz_add = torch.Tensor([[0, 1, 1, 3, 0, 1, 1, 1, 0]]).to(rot_param.device) * math.pi / 2.0

    Rx =  torch.cos(rx_mul*rot_param[:,0:1]+rx_add)
    Ry =  torch.cos(ry_mul*rot_param[:,1:2]+ry_add)
    Rz =  torch.cos(rz_mul*rot_param[:,2:3]+rz_add)
    R = Rx.view(-1,3,3)@Ry.view(-1,3,3)@Rz.view(-1,3,3)
    return R
0

There are 0 best solutions below