mks0601 / I2L-MeshNet_RELEASE

Official PyTorch implementation of "I2L-MeshNet: Image-to-Lixel Prediction Network for Accurate 3D Human Pose and Mesh Estimation from a Single RGB Image", ECCV 2020
MIT License
724 stars 127 forks source link

clarification of OLD issue - Smpl body to image projection #127

Open Dipankar1997161 opened 1 year ago

Dipankar1997161 commented 1 year ago

Hey @mks0601, hope you doing well.

I actually came across your issue regarding the smpl body projection to image #https://github.com/classner/up/issues/17#issue-508798131

I used the following projection function but unsure if the points are correct.

def perspective_projection_custom(points, rotation, translation, focal_length,
                           camera_center):
    """
    This function computes the perspective projection of a set of points.
    Input:
        points (bs, N, 3): 3D points
        rotation (bs, 3, 3): Camera rotation
        translation (bs, 3): Camera translation
        focal_length (bs,) or scalar: Focal length
        camera_center (bs, 2): Camera center
    """
    batch_size = points.shape[0]
    K = torch.zeros([batch_size, 3, 3], device=points.device)
    K[:, 0, 0] = focal_length
    K[:, 1, 1] = focal_length
    K[:, 2, 2] = 1.0
    K[:, :-1, -1] = camera_center

    # Transform points
    points = torch.einsum("bij,bkj->bki", rotation, points)
    points = points + translation.unsqueeze(1)

    # Apply perspective distortion
    projected_points = points / points[:, :, -1].unsqueeze(-1)

    # Apply camera intrinsics
    projected_points = torch.einsum("bij,bkj->bki", K, projected_points)

    return projected_points[:, :, :-1]

Can you share the check the function once or maybe share your sample code which you used for smpl body projection to image If possible?

I need to convert the smpl points into several other format for a custom dataset, so this conversion and projection is crucial for me.

I hope you can help out. Thank you once again.