Arthur151 / ROMP

Monocular, One-stage, Regression of Multiple 3D People and their 3D positions & trajectories in camera & global coordinates. ROMP[ICCV21], BEV[CVPR22], TRACE[CVPR2023]

Home Page:https://www.yusun.work/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Quick clarification of projected 2d points of smpl

Dipankar1997161 opened this issue · comments

hello @Arthur151, I had a quick query to be clarified.

Now that we have the 3d smpl joints, I want to project it on the resp. 2d image.
I am aware that we have pj2d, but I wish to do the conversion myself.

So, I checked the repo and saw a perspective projective function
Q1. is this the function used for the conversion of 3d smpl joints to 2d ?? or there's something else.

def perspective_projection_ROMP(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]

Q2. We only require the 'smpl_joints' for such plotting right? or do we need the 'smpl_poses'?
Q3. For plotting the skeleton, can I use the following function after I have generated the 2d smpl

def draw_skeleton(image, pts, bones=smpl24_connMat, cm=None, label_kp_order=False,r=8):

and this is the skeleton_tree for smpl I suppose

smpl24_connMat = np.array([0,1, 0,2, 0,3, 1,4,4,7,7,10, 2,5,5,8,8,11, 3,6,6,9,9,12,12,15, 12,13,13,16,16,18,18,20,20,22, 12,14,14,17,17,19,19,21,21,23]).reshape(-1, 2)

Q4. Lastly, for plotting the 2d joints on the image(not the skeleton), do you recommend any function in ROMP to check or can we just use matplotlib scatterplot to plot the joints on the IMAGES.

I really need to know these. Thank you @Arthur151

@Dipankar1997161
Sorry for the late reply!

Q1. Yes, this function is written to perform the 2D projection of SMPL's 3D joints.
Q2. Actually, it just implements a normal perspective projection, so the 3D joints are required. SMPL theta poses are not needed.
Q3. Yes, this could be very convenient.
Q4. Any functions you like to plot the 2D joints should be fine.