sphere_snap.sphere_snap

class SphereSnap:

Reproject various image types by projecting them first on a sphere surface

SphereSnap(snap_config)

Given the input parameters, creates an SphereSnap object

def get_xyz_from_pixel(self, uv):

Returns the points on the sphere in xyz that are mapped to these uv (image) coordinates or None if neither point is in the view's bounds

def get_spherical_from_pixel(self, uv):

Returns the points on the sphere (in spherical coordinates) that are mapped to these uv (image) coordinates or None if neither point is in the view's bounds

def get_coor_from_pixel(self, uv):

Returns the coordinates in the source image that are mapped to this snap image pixel coordinates

def get_pixel_from_spherical( self, spherical, return_indices=False, np=<module 'numpy' from '/Users/andreigeorgescu/opt/miniconda3/lib/python3.9/site-packages/numpy/__init__.py'>):

Given the spherical coords (phi, theta) in radians, returns the corresponding uv points

def get_pixel_from_xyz(self, xyz, return_indices=False):

Given some xyz points on the normalised sphere surface returns the coordinates in the current image if exists and [-1,-1] if is outside optionally can return the outside indices

def rotate_snap(self, new_rotation_matrix):

Keep all the same snap configuration bot different orientation

def get_source_image_coors(self):

Returns an array of the snap out_hw size that has the image source coordinates for each pixel

def snap_to_perspective(self, source_img):
def image2spherical(*args, **kwargs):

Transforms from image coordinates to sphere coordinates return the image sphere

def spherical2image(*args, **kwargs):

Transforms from sphere coordinates to image coordinates return the image coordinates

Parameters
  • spherical: spherical coordinates for the sphere surface points that we want to project
  • snap_config: a snap_config object containing metadata of the snap
@staticmethod
def merge_multiple_snaps( output_hw, sphere_snaps, imgs, merge_method='average', target_type='equi'):

Given a list of images extracted from a source image, re-create an image return the full image obtained from the source views

Parameters
  • output_hw: a tuple containing source image size(height, width)
  • views: a list of views we want to merge back in the full image
  • imgs: a list of imgs coresponding to the views
  • merge_method: average, sum, max, last
  • target_type: image projection type (equi, fisheye180)
@staticmethod
def sample_polygon_from_image( points, hw, source_img_fov_deg, source_dist_coeff=None, return_polar=False):

Given a polygon on the sphere returns all the 2d points inside it from the source image

Parameters
  • points: polygon xyz points on the sphere
  • hw: resolution of the source image you want to sample from
  • source_img_fov_deg: a tuple containing (hfov, vfov) of the perspective source image, if this is None the image is equirectangular
  • source_dist_coeff: None if does not exist, array containing radial distortion parameters, offset center should be normalised {lambda, center_offset_x, center_offest_y}
  • return_polar: If true, it will return also the sphere projection of the points in polar coordinates
K_matrix

Returns intrinsics matrix (pinhole camera) based on snap config properties

def copy(self):

Returns a copy of this SphereSnap object