JDAI-CV/DSD-SATN

Wrong global orientation

Mercurialzhang opened this issue · 2 comments

def batch_orth_proj(X, camera, mode='2d'):
    camera = camera.view(-1, 1, 3)
    s = camera[:, :, 0].unsqueeze(-1)
    X_trans = X[:,:,:2].contiguous()
    if mode=='2d':
        X_trans = s * X_trans + camera[:, :, 1:]
        return X_trans
    elif mode=='v3d':
        X[:, :, :2] = s * X_trans + camera[:, :, 1:]
        return X
    elif mode=='j3d':
        X[:, :, :2] = s * X_trans/torch.abs(s) + camera[:, :, 1:]
        return X
    else:
        print('projection mode is not included')
        return X

https://github.com/Arthur151/DSD-SATN/blob/3fb61686c6161bf89a91aab7635eb57a58b04c25/src/model/model.py#L261

It seems that you directly manipulate the tensor passed in, so verts and verts_cam here are the same value, and vertices of the body model is coupled with the camera.

@Mercurialzhang Yes, you are right!
If you want to get vertices decoupled from the camera rotation, please just make the change like,
verts_camed = util.batch_orth_proj(verts.copy(), cam, mode='v3d')
The code will be revised later. Thanks for your kindness.

Thanks for your quick reply! I will have a try