Shortcuts

pypose.reprojerr

class pypose.reprojerr(points, pixels, intrinsics, extrinsics=None, reduction='none')[source]

Calculates batched per-pixel reprojection error (pixel distance) for points either in the camera or world frame given camera intrinsics or extrinsics, respectively.

Parameters:
  • points (torch.Tensor) – The 3D coordinate of points. Assumed to be in the camera frame if extrinsics is None, otherwiwse in the world frame. The shape has to be (…, N, 3).

  • pixels (torch.Tensor) – The image points. The associated pixel. The shape has to be (…, N, 2).

  • intrinsics (torch.Tensor) – intrinsic matrices. The shape has to be (…, 3, 3).

  • extrinsics (LieTensor, optional) – The camera extrinsics. The shape has to be (…, 7). Default: None.

  • reduction (str, optional) –

    The reduction to apply on the output: 'none' | 'sum' | 'norm'

    'none': No reduction is applied

    'sum': The reprojection error on each component (u, v) is summed for each pixel (L1 Norm)

    'norm': The reprojection error’s L2 norm for each pixel

Returns:

Per-pixel reprojection error.

The shape is (…, N) if reduction is 'sum' or 'norm'.

The shape is (…, N, 2) if reduction is 'none'.

Example

>>> import torch, pypose as pp
>>> f, (H, W) = 2, (9, 9) # focal length and image height, width
>>> intrinsics = torch.tensor([[f, 0, H / 2],
...                            [0, f, W / 2],
...                            [0, 0,   1  ]])
>>> object = torch.randn(6, 3)
>>> pose = pp.randn_SE3()
>>> pixels = pp.point2pixel(object, intrinsics, pose)
>>> err = pp.reprojerr(object, pixels, intrinsics, pose, reduction='norm')
tensor([0., 0., 0., 0., 0., 0.])

Docs

Access documentation for PyPose

View Docs

Tutorials

Get started with tutorials and examples

View Tutorials

Get Started

Find resources and how to start using pypose

View Resources