Skip to content

cameras_from_opencv_projection always instantiates cameras on the CPU side #1021

Closed
@rbregier

Description

@rbregier

🐛 Bugs / Unexpected behaviors

Hi,
the function cameras_from_opencv_projection instantiates cameras on the CPU side when provided with GPU tensors.

I believe that passing an additional parameter device=R.device to the following constructor should solve the issue:

return PerspectiveCameras(

Best,
Romain

Instructions To Reproduce the Issue:

import torch
import pytorch3d.utils

device = torch.device(0)

R = torch.eye(3, device=device)[None]
tvec = torch.zeros(1, 3, device=device)
camera_matrix = torch.eye(3, device=device)[None]
image_size = torch.as_tensor([[320, 240]], device=device)

cameras = pytorch3d.utils.cameras_from_opencv_projection(R=R, tvec=tvec, camera_matrix=camera_matrix, image_size=image_size)

print("Input device", R.device)
print("Output device", cameras.R.device)

Output:

Input device cuda:0
Output device cpu

(expected output: cuda:0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions