Camera

class packnet_sfm.geometry.camera.Camera(K, Tcw=None)[source]

Bases: torch.nn.modules.module.Module

Differentiable camera class implementing reconstruction and projection functions for a pinhole model.

property Kinv

Inverse intrinsics (for lifting)

property Twc

World -> Camera pose transformation (inverse of Tcw)

property cx

Principal point in x

property cy

Principal point in y

property fx

Focal length in x

property fy

Focal length in y

project(X, frame='w')[source]

Projects 3D points onto the image plane

Parameters
  • X (torch.Tensor [B,3,H,W]) – 3D points to be projected

  • frame ('w') – Reference frame: ‘c’ for camera and ‘w’ for world

Returns

points – 2D projected points that are within the image boundaries

Return type

torch.Tensor [B,H,W,2]

reconstruct(depth, frame='w')[source]

Reconstructs pixel-wise 3D points from a depth map.

Parameters
  • depth (torch.Tensor [B,1,H,W]) – Depth map for the camera

  • frame ('w') – Reference frame: ‘c’ for camera and ‘w’ for world

Returns

points – Pixel-wise 3D points

Return type

torch.tensor [B,3,H,W]

scaled(x_scale, y_scale=None)[source]

Returns a scaled version of the camera (changing intrinsics)

Parameters
  • x_scale (float) – Resize scale in x

  • y_scale (float) – Resize scale in y. If None, use the same as x_scale

Returns

camera – Scaled version of the current cmaera

Return type

Camera

to(*args, **kwargs)[source]

Moves object to a specific device