Skip to content

Commit

Permalink
refactoring, and fixed global coordinate settings
Browse files Browse the repository at this point in the history
  • Loading branch information
haruishi43 committed Jun 22, 2021
1 parent b973550 commit e80fdd0
Show file tree
Hide file tree
Showing 43 changed files with 709 additions and 490 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ __Right-handed rule XYZ global coordinate system__. `x-axis` faces forward and `
- `pitch`: counter-clockwise rotation about the `y-axis`
- `yaw`: counter-clockwise rotation about the `z-axis`

You can chnage the right-handed coordinate system so that the `z-axis` faces down by adding `z_down=True` as a parameter.

See demo scripts under `scripts`.


Expand Down Expand Up @@ -187,7 +189,7 @@ Check [CONTRIBUTING.md](./CONTRIBUTING.md) for more information

- [ ] Documentations for each transform
- [x] Add table and statistics for speed improvements
- [ ] Batch processing for `numpy`
- [ ] Batch processing for `numpy` (uses too much memory; alternative will be `multiprocessing`)
- [ ] Mixed precision for `torch`
- [ ] `c++` version of grid sampling

Expand Down
6 changes: 3 additions & 3 deletions demo/equi2equi_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def preprocess(
img: Union[np.ndarray, Image.Image],
is_cv2: bool = False,
) -> np.ndarray:
r"""Preprocesses image"""
"""Preprocesses image"""
if isinstance(img, np.ndarray) and is_cv2:
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
if isinstance(img, Image.Image):
Expand All @@ -37,7 +37,7 @@ def preprocess(


def test_video(path: str) -> None:
r"""Test video"""
"""Test video"""
# Rotation:
pi = np.pi
inc = pi / 180
Expand Down Expand Up @@ -105,7 +105,7 @@ def test_video(path: str) -> None:


def test_image(path: str) -> None:
r"""Test single image"""
"""Test single image"""
# Rotation:
rot = {
"roll": 0, #
Expand Down
6 changes: 3 additions & 3 deletions demo/equi2equi_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def preprocess(
img: Union[np.ndarray, Image.Image],
is_cv2: bool = False,
) -> torch.Tensor:
r"""Preprocesses image"""
"""Preprocesses image"""
if isinstance(img, np.ndarray) and is_cv2:
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
if isinstance(img, Image.Image):
Expand Down Expand Up @@ -66,7 +66,7 @@ def postprocess(


def test_video(path: str) -> None:
r"""Test video"""
"""Test video"""
# Rotation:
pi = np.pi
inc = pi / 180
Expand Down Expand Up @@ -134,7 +134,7 @@ def test_video(path: str) -> None:


def test_image(path: str) -> None:
r"""Test single image"""
"""Test single image"""
# Rotation:
rot = {
"roll": 0, #
Expand Down
6 changes: 3 additions & 3 deletions demo/equi2pers_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def preprocess(
img: Union[np.ndarray, Image.Image],
is_cv2: bool = False,
) -> np.ndarray:
r"""Preprocesses image"""
"""Preprocesses image"""
if isinstance(img, np.ndarray) and is_cv2:
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
if isinstance(img, Image.Image):
Expand All @@ -42,7 +42,7 @@ def test_video(
w_pers: int = 640,
fov_x: float = 90.0,
) -> None:
r"""Test video"""
"""Test video"""
# Rotation:
pi = np.pi
inc = pi / 180
Expand Down Expand Up @@ -116,7 +116,7 @@ def test_image(
w_pers: int = 640,
fov_x: float = 90.0,
) -> None:
r"""Test single image"""
"""Test single image"""
# Rotation:
rot = {
"roll": 0, #
Expand Down
6 changes: 3 additions & 3 deletions demo/equi2pers_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def preprocess(
img: Union[np.ndarray, Image.Image],
is_cv2: bool = False,
) -> torch.Tensor:
r"""Preprocesses image"""
"""Preprocesses image"""
if isinstance(img, np.ndarray) and is_cv2:
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
if isinstance(img, Image.Image):
Expand Down Expand Up @@ -71,7 +71,7 @@ def test_video(
w_pers: int = 640,
fov_x: float = 90.0,
) -> None:
r"""Test video"""
"""Test video"""
# Rotation:
pi = np.pi
inc = pi / 180
Expand Down Expand Up @@ -145,7 +145,7 @@ def test_image(
w_pers: int = 640,
fov_x: float = 90.0,
) -> None:
r"""Test single image"""
"""Test single image"""
# Rotation:
rot = {
"roll": 0, #
Expand Down
7 changes: 1 addition & 6 deletions equilib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from equilib.equi2cube.base import Equi2Cube, equi2cube
from equilib.equi2equi.base import Equi2Equi, equi2equi
from equilib.equi2pers.base import Equi2Pers, equi2pers
from equilib.info import __version__

__all__ = [
"Cube2Equi",
Expand All @@ -15,9 +16,3 @@
"equi2equi",
"equi2pers",
]

__version__ = "0.2.1"
__author__ = "Haruya Ishikawa"
__homepage__ = "www.hoge.com"
__description__ = "equirectangular processing"
__url__ = "www.hoge.com/equilib"
69 changes: 0 additions & 69 deletions equilib/common/numpy_utils.py

This file was deleted.

86 changes: 0 additions & 86 deletions equilib/common/torch_utils.py

This file was deleted.

9 changes: 5 additions & 4 deletions equilib/cube2equi/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


class Cube2Equi(object):
r"""
"""
params:
- w_out, h_out (int): equirectangular image size
- cube_format (str): input cube format("dice", "horizon", "dict", "list")
Expand Down Expand Up @@ -74,18 +74,19 @@ def cube2equi(
sampling_method: str = "default",
mode: str = "bilinear",
) -> Union[np.ndarray, torch.Tensor]:
r"""
"""
params:
- cubemap: Union[
- cubemap (Union[
np.ndarray,
torch.Tensor,
Dict[str, Union[np.ndarray, torch.Tensor]],
List[Union[np.ndarray, torch.Tensor]]]
List[Union[np.ndarray, torch.Tensor]]])
- cube_format (str): ("dice", "horizon", "dict", "list")
- w_out (int):
- h_out (int):
- sampling_method (str): "default"
- mode (str): "bilinear"
- z_down (bool): False
return:
- equi (np.ndarray, torch.Tensor)
Expand Down
8 changes: 4 additions & 4 deletions equilib/cube2equi/cube2equi_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def cube_dict2h(


def cube_dice2h(cube_dice: np.ndarray) -> np.ndarray:
r"""dice to horizion
"""dice to horizion
params:
- cube_dice: (C, H, W)
Expand Down Expand Up @@ -57,7 +57,7 @@ def _to_horizon(cubemap: np.ndarray, cube_format: str) -> np.ndarray:


def _equirect_facetype(h: int, w: int) -> np.ndarray:
r"""0F 1R 2B 3L 4U 5D"""
"""0F 1R 2B 3L 4U 5D"""

tp = np.roll(
np.arange(4).repeat(w // 4)[None, :].repeat(h, 0), 3 * w // 8, 1
Expand Down Expand Up @@ -92,7 +92,7 @@ def _run_single(
sampling_method: str,
mode: str,
) -> np.ndarray:
r"""Run a single batch of transformation"""
"""Run a single batch of transformation"""
w_face = cubemap.shape[-2]

theta, phi = create_equi_grid(h_out, w_out)
Expand Down Expand Up @@ -145,7 +145,7 @@ def run(
sampling_method: str,
mode: str,
) -> np.ndarray:
r"""Run cube to equirectangular image transformation
"""Run cube to equirectangular image transformation
params:
- cubemap: np.ndarray
Expand Down
Loading

0 comments on commit e80fdd0

Please sign in to comment.