Skip to content

API Reference

The public API is exported from the top-level equilib package. Each transform provides a class and a func variant.

cube2equi

equilib.Cube2Equi

Bases: object

params: - w_out, h_out (int): equirectangular image size - cube_format (str): input cube format("dice", "horizon", "dict", "list") - mode (str): interpolation mode, defaults to "bilinear"

inputs: - cubemap (np.ndarray, torch.Tensor, dict, list)

returns: - equi (np.ndarray, torch.Tensor)

Source code in equilib/cube2equi/base.py
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
class Cube2Equi(object):
    """
    params:
    - w_out, h_out (int): equirectangular image size
    - cube_format (str): input cube format("dice", "horizon", "dict", "list")
    - mode (str): interpolation mode, defaults to "bilinear"

    inputs:
    - cubemap (np.ndarray, torch.Tensor, dict, list)

    returns:
    - equi (np.ndarray, torch.Tensor)
    """

    def __init__(
        self,
        height: int,
        width: int,
        cube_format: str,
        clip_output: bool = True,
        mode: str = "bilinear",
    ) -> None:
        self.height = height
        self.width = width
        self.cube_format = cube_format
        self.clip_output = clip_output
        self.mode = mode

    def __call__(self, cubemap: CubeMaps, **kwargs) -> ArrayLike:
        return cube2equi(
            cubemap=cubemap,
            cube_format=self.cube_format,
            width=self.width,
            height=self.height,
            clip_output=self.clip_output,
            mode=self.mode,
            **kwargs,
        )

equilib.cube2equi

equi2cube

equilib.Equi2Cube

Bases: object

params: - w_face (int): cube face width - cube_format (str): ("dice", "horizon", "dict", "list") - mode (str) - z_down (bool)

inputs: - equi (np.ndarray, torch.Tensor) - rots (dict, list[dict]): {"roll", "pitch", "yaw"}

returns: - cube (np.ndarray, torch.Tensor, list, dict)

Source code in equilib/equi2cube/base.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
class Equi2Cube(object):
    """
    params:
    - w_face (int): cube face width
    - cube_format (str): ("dice", "horizon", "dict", "list")
    - mode (str)
    - z_down (bool)

    inputs:
    - equi (np.ndarray, torch.Tensor)
    - rots (dict, list[dict]): {"roll", "pitch", "yaw"}

    returns:
    - cube (np.ndarray, torch.Tensor, list, dict)
    """

    def __init__(
        self,
        w_face: int,
        cube_format: str,
        z_down: bool = False,
        clip_output: bool = True,
        mode: str = "bilinear",
    ) -> None:
        self.w_face = w_face
        self.cube_format = cube_format
        self.z_down = z_down
        self.clip_output = clip_output
        self.mode = mode
        # cache for the rotation-invariant grid (`xyz`), keyed by input
        # shape/dtype; reused across calls since the config above is fixed.
        self._cache: Dict = {}

    def __call__(self, equi: ArrayLike, rots: Rot, **kwargs) -> CubeMaps:
        return equi2cube(
            equi=equi,
            rots=rots,
            w_face=self.w_face,
            cube_format=self.cube_format,
            z_down=self.z_down,
            clip_output=self.clip_output,
            mode=self.mode,
            cache=self._cache,
            **kwargs,
        )

equilib.equi2cube

equi2equi

equilib.Equi2Equi

Bases: object

params: - w_out, h_out (optional int): equi image size - clip_output (bool) whether to clip values in the range of input - mode (str): interpolation mode, defaults to "bilinear" - z_down (bool)

input params: - src (np.ndarray, torch.Tensor) - rots (dict, list[dict])

return: - equi (np.ndarray, torch.Tensor)

Source code in equilib/equi2equi/base.py
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
class Equi2Equi(object):
    """
    params:
    - w_out, h_out (optional int): equi image size
    - clip_output (bool) whether to clip values in the range of input
    - mode (str): interpolation mode, defaults to "bilinear"
    - z_down (bool)

    input params:
    - src (np.ndarray, torch.Tensor)
    - rots (dict, list[dict])

    return:
    - equi (np.ndarray, torch.Tensor)
    """

    def __init__(
        self,
        height: Optional[int] = None,
        width: Optional[int] = None,
        clip_output: bool = True,
        mode: str = "bilinear",
        z_down: bool = False,
    ) -> None:
        self.height = height
        self.width = width
        self.clip_output = clip_output
        self.mode = mode
        self.z_down = z_down
        # cache for the rotation-invariant grid (`m`), keyed by input
        # shape/dtype; reused across calls since the config above is fixed.
        self._cache: Dict = {}

    def __call__(self, src: ArrayLike, rots: Rot, **kwargs) -> ArrayLike:
        return equi2equi(
            src=src,
            rots=rots,
            clip_output=self.clip_output,
            mode=self.mode,
            z_down=self.z_down,
            cache=self._cache,
            **kwargs,
        )

equilib.equi2equi

equi2pers

equilib.Equi2Pers

Bases: object

params: - height, width (int): perspective size - fov_x (float): perspective image fov of x-axis - skew (float): skew intrinsic parameter - sampling_method (str) - z_down (bool) - mode (str) - clip_output (bool)

inputs: - equi (np.ndarray, torch.Tensor) - rot (dict, list): Dict[str, float]

returns: - pers (np.ndarray, torch.Tensor)

Source code in equilib/equi2pers/base.py
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
class Equi2Pers(object):
    """
    params:
    - height, width (int): perspective size
    - fov_x (float): perspective image fov of x-axis
    - skew (float): skew intrinsic parameter
    - sampling_method (str)
    - z_down (bool)
    - mode (str)
    - clip_output (bool)

    inputs:
    - equi (np.ndarray, torch.Tensor)
    - rot (dict, list): Dict[str, float]

    returns:
    - pers (np.ndarray, torch.Tensor)

    """

    def __init__(
        self,
        height: int,
        width: int,
        fov_x: float,
        skew: float = 0.0,
        z_down: bool = False,
        mode: str = "bilinear",
        clip_output: bool = True,
    ) -> None:
        self.height = height
        self.width = width
        self.fov_x = fov_x
        self.skew = skew
        self.mode = mode
        self.z_down = z_down
        self.clip_output = clip_output
        # cache for the rotation-invariant grid prep (`m`, `G`), keyed by input
        # shape/dtype; reused across calls since the config above is fixed.
        self._cache: Dict = {}

    def __call__(self, equi: ArrayLike, rots: Rot, **kwargs) -> ArrayLike:
        return equi2pers(
            equi=equi,
            rots=rots,
            height=self.height,
            width=self.width,
            fov_x=self.fov_x,
            skew=self.skew,
            z_down=self.z_down,
            mode=self.mode,
            clip_output=self.clip_output,
            cache=self._cache,
            **kwargs,
        )

    def get_bounding_fov(self, equi: ArrayLike, rots: Rot) -> ArrayLike:
        return get_bounding_fov(
            equi=equi,
            rots=rots,
            height=self.height,
            width=self.width,
            fov_x=self.fov_x,
            skew=self.skew,
            z_down=self.z_down,
        )

equilib.equi2pers

pers2equi

equilib.Pers2Equi

Bases: object

params: - height, width (int): equirectangular size - z_down (bool) - mode (str) - clip_output (bool)

inputs: - pers (np.ndarray, torch.Tensor) - rot (dict, list): Dict[str, float]

returns: - equi (np.ndarray, torch.Tensor)

Source code in equilib/pers2equi/base.py
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
class Pers2Equi(object):
    """
    params:
    - height, width (int): equirectangular size
    - z_down (bool)
    - mode (str)
    - clip_output (bool)

    inputs:
    - pers (np.ndarray, torch.Tensor)
    - rot (dict, list): Dict[str, float]

    returns:
    - equi (np.ndarray, torch.Tensor)

    """

    def __init__(
        self,
        height: int,
        width: int,
        z_down: bool = False,
        mode: str = "bilinear",
        clip_output: bool = True,
    ) -> None:
        self.height = height
        self.width = width
        self.mode = mode
        self.z_down = z_down
        self.clip_output = clip_output
        # cache for the rotation-invariant grid prep (`m`, `G`), keyed by input
        # shape/dtype; reused across calls since the config above is fixed.
        self._cache: Dict = {}

    def __call__(
        self, pers: ArrayLike, rots: Rot, fov_x: float, **kwargs
    ) -> ArrayLike:
        return pers2equi(
            pers=pers,
            rots=rots,
            height=self.height,
            width=self.width,
            fov_x=fov_x,
            z_down=self.z_down,
            mode=self.mode,
            clip_output=self.clip_output,
            cache=self._cache,
            **kwargs,
        )

equilib.pers2equi