reproject_image#

deltacamera.reproject_image(image, old_camera, new_camera, output_imshape=None, border_mode=cv2.BORDER_CONSTANT, border_value=0, interp=None, antialias_factor=1, dst=None, cache_maps=False, precomp_undist_maps=True, use_linear_srgb=False, return_validity_mask=False)[source]#

Transform an image captured with old_camera to look like it was captured by new_camera. The optical center (3D world position) of the cameras must be the same, otherwise we’d have parallax effects and no unambiguous way to construct the output.

There are two caching options. If cache_maps is True, the coordinate maps for this particular reprojection will be cached. If multiple images will be reprojected with the same old_camera and new_camera, it is recommended to set cache_maps to True.

The second option is precomp_undist_maps. This is only relevant if the new_camera has distortion. If precomp_undist_maps is True, an undistortion map of that camera’s distortion coefficients will be precomputed and cached. This precomputed map only depends on the distortion coefficients of the new camera, therefore it can be reused in more contexts. Therefore, if multiple images will be reprojected with the same new_camera distortion coefficients, but with varying other parameters, it is recommended to set precomp_undist_maps to True.

Parameters:
  • image (ndarray) – the input image

  • old_camera (Camera) – the camera that captured image

  • new_camera (Camera) – the camera that should capture the newly returned image

  • output_imshape (tuple) – (height, width) for the output image

  • border_mode (int) – OpenCV border mode for treating pixels outside image

  • border_value – OpenCV border value for treating pixels outside image

  • interp – OpenCV interpolation to be used for resampling.

  • antialias_factor – If larger than 1, first render a higher resolution output image that is antialias_factor times larger than output_imshape and subsequently resize it by ‘area’ interpolation to the desired size.

  • dst – destination array (optional)

  • cache_maps – Whether to cache the coordinate maps used for reprojection.

  • precomp_undist_maps – Whether to precompute and cache undistortion maps for the cameras.

  • use_linear_srgb – If True, decode image from 8-bit encoded sRGB to 16-bit linear space before reprojecting and encode the result back to 8-bit sRGB. This ensures correct color interpolation for sRGB inputs.

Returns:

The new image.

Return type:

ndarray