sphere_snap.utils

def construct_map(*args, **kwargs):

Given to sets of coordinates creates a map between them returns map from undistorted to distorted coordinates, the map might contain NaN values where there are not distortion calculated

def sample_from_image_np(source_img, coor_x, coor_y):
def sample_from_image_cp(source_img, coor_x, coor_y):
def sample_from_img(source_img, coor_xy, clamp=True):

Constructs the image using the computed coordinates clamp: determines how texture is sampled when texture coord are out of the typical 0..1 range, If True texture edge pixels are stretched when outside of range.

def sample_polygon(*args, **kwargs):

Given a polygon on the sphere returns all the points inside it in eq coordinates

Parameters
  • points: polygon xyz points on the sphere
  • hw: resolution of the source image you want to sample from
  • full_img_fov_deg: a tuple containing (hfov, vfov) of the perspective source image, if this is None the image is equirectangular
def check_uv_in_bounds(uv, hw):

Returns an array of True (for uv coordinates in array that are in hw bound) and False (otherwise)

def compute_focal_length_yx(fov, hw):

Returns focal lenght given resolution and fov

def compute_fovs(focal_length_yx, hw):

Returns pinhole camera fov given focal length and resolution

def compute_hw(focal_length_yx, fov):

Returns pinhole camera resolution given focal length and fov

def check_fov_res_consistency(fov, hw, threshold=0.12):

check for square pixels given pinhole camera asumption

def ensure_fov_res_consistency(fov, hw, threshold=0.12):

if we don't have square pixels we assume the vfov is correct and adjust hfov accordingly.