Skip to content

Convert camera extrinsic openCV to R and T matrix of SfMPerspectiveCameras #287

Closed
@hiro050696

Description

@hiro050696
camera_pose  = np.array([[ 0.10624042,  0.99397693,  0.0268858,   0.2087519 ],
                            [-0.68876547,  0.05406284,  0.72296565,  0.61393758],
                            [ 0.71715765, -0.09532618,  0.69036065,  3.16445006],
                            [0.0        ,           0.0,        0.0,        1.0]])


def getNewCameraPose(camera_pose=camera_pose):
    rot_X       = np.array([[ 1.0, 0.0, 0.0, 0],
                            [ 0.0, -1.0, 0.0, 0],
                            [ 0.0, 0.0, -1.0, 0],
                            [0, 0, 0, 1]])
    rot_X_1     = np.array([[ 1.0, 0.0, 0.0, 0],
                            [ 0.0, 0.0, 1.0, 0],
                            [ 0.0, -1.0, 0.0, 0],
                            [0, 0, 0, 1]])
    A = np.dot(rot_X,camera_pose)
    A = np.dot(A,rot_X_1)
    camera_pose = np.linalg.inv(A)
    return camera_pose

camera_pose = getNewCameraPose(camera_pose=camera_pose)
R 			= torch.Tensor([camera_pose[:3,:3]])
T 			= torch.Tensor([camera_pose[:3,3]])

After using OpenCV cabliration, i got a 4x4 extrinsic matrix. I want to convert it to 2 matrix R and T form OpenCV coordinate to Pytorch3D coordinate, those matrix are used in SfMPerspectiveCameras projection function.
I tried a lot of approach but it didnt work correctly, maybe the problem is related to right-hand and left-hand coordinate system.

How can I do it?

Metadata

Metadata

Assignees

Labels

how toHow to use PyTorch3D in my project

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions