{"id":19544126,"url":"https://github.com/sunset1995/py360convert","last_synced_at":"2025-04-10T04:49:24.995Z","repository":{"id":37735715,"uuid":"166572699","full_name":"sunset1995/py360convert","owner":"sunset1995","description":"Python implementation of convertion between equirectangular, cubemap and perspective. (equirect2cube, cube2equirect, equirect2perspec)","archived":false,"fork":false,"pushed_at":"2025-03-15T00:15:36.000Z","size":1504,"stargazers_count":483,"open_issues_count":4,"forks_count":101,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-03T02:30:58.022Z","etag":null,"topics":["360","converter","cubemap","equirectangular","perspective","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sunset1995.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-19T17:16:15.000Z","updated_at":"2025-04-02T08:09:27.000Z","dependencies_parsed_at":"2024-06-19T00:08:57.848Z","dependency_job_id":"c3ed4956-b46c-4c5e-b2e5-9fd9a576acee","html_url":"https://github.com/sunset1995/py360convert","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunset1995%2Fpy360convert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunset1995%2Fpy360convert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunset1995%2Fpy360convert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunset1995%2Fpy360convert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sunset1995","download_url":"https://codeload.github.com/sunset1995/py360convert/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248161244,"owners_count":21057552,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["360","converter","cubemap","equirectangular","perspective","python"],"created_at":"2024-11-11T03:24:41.992Z","updated_at":"2025-04-10T04:49:24.970Z","avatar_url":"https://github.com/sunset1995.png","language":"Python","readme":"# py360convert\n\nFeatures of this project:\n- Conversion between cubemap and equirectangular:\n    ![](assets/teaser_convertion.png)\n- Conversion between Equirectangular and planar:\n    ![](assets/teaser_2planar.png)\n- Pure python implementation and depend only on [numpy](http://www.numpy.org/) and [scipy](https://www.scipy.org/).\n- Vectorization implementation:\n    - If opencv is installed, py360convert will automatically use it to accelerate computations (several times speedup).\n\n## Install\n```\npip install py360convert\n```\n\nYou can use the library with `import py360convert` and through the command line tool `convert360`.\n\n### Command line examples\nThe convert360 command line tool can be run like so. Use `convert360 -h` for details. The convert360 python script is also doubles as ab example code for how to use this as a package in your code.\n\n```\nconvert360 e2c assets/example_input.png out.png --size 200\n```\n| Input Equirectangular | Output Cubemap |\n| :---: | :----: |\n| ![](assets/example_input.png) | ![](assets/example_e2c.png) |\n\n-----\n\n```\nconvert360 c2e assets/example_e2c.png out.png --width 800 --height 400\n```\n| Input Cubemap | Output Equirectangular |\n| :---: | :----: |\n| ![](assets/example_e2c.png) | ![](assets/example_c2e.png) |\n\nYou can see the blurring artifacts in the polar region because the equirectangular in above figure are resampled twice (`e2c` then `c2e`).\n\n----\n\n```\nconvert360 e2p assets/example_input.png out.png --width 300 --height 300 --yaw 120 --pitch 23\n```\n| Input Equirectangular | Output Perspective |\n| :---: | :----: |\n| ![](assets/example_input.png) | ![](assets/example_e2p.png) |\n\n\n## Doc\n\n#### `c2e(cubemap, h, w, cube_format='dice')`\nConvert the given cubemap to equirectangular.  \n**Parameters**:\n- `cubemap`: Numpy array or list/dict of numpy array (depend on `cube_format`).\n- `h`: Output equirectangular height.\n- `w`: Output equirectangular width.\n- `mode:str`: Interpolation method; typically `bilinear` or `nearest`. Valid options: \"nearest\", \"linear\", \"bilinear\", \"biquadratic\", \"quadratic\", \"quad\", \"bicubic\", \"cubic\", \"biquartic\", \"quartic\", \"biquintic\", \"quintic\".\n\n- `cube_format`: Options: `'dice'` (default), `'horizon'` or `'dict'` or `'list'`. Indicates the format of the given `cubemap`.\n    - Say that each face of the cube is in shape of `256 (width) x 256 (height)`\n    - `'dice'`: a numpy array in shape of `1024 x 768` like below example\n\n      \u003cimg src=\"assets/cube_dice.png\" height=\"200\"\u003e\n    - `'horizon'`: a numpy array in shape of `1536 x 256` like below example\n\n      \u003cimg src=\"assets/cube_horizon.png\" height=\"100\"\u003e\n    - `'list'`: a `list` with 6 elements each of which is a numpy array in the shape of `256 x 256`. It's just converted from 'horizon' format with one line of code: `np.split(cube_h, 6, axis=1)`.\n    - `'dict'`: a `dict` with 6 elements with keys `'F', 'R', 'B', 'L', 'U', 'D'` each of which is a numpy array in shape of `256 x 256`.\n    - Please refer to [the source code](https://github.com/sunset1995/py360convert/blob/master/py360convert/utils.py#L176) if you still have any questions about the conversion between formats.\n\n#### `e2c(e_img, face_w=256, mode='bilinear', cube_format='dice')`\nConvert the given equirectangular to cubemap.  \n**Parameters**:\n- `e_img: NDArray`: Numpy array with shape [H, W, C].\n- `face_w: int`: The width of each cube face.\n- `mode:str`: See `c2e`.\n- `cube_format:str`: See `c2e`.\n\n#### `e2p(e_img, fov_deg, u_deg, v_deg, out_hw, in_rot_deg=0, mode='bilinear')`\nTake perspective image from given equirectangular.\n**Parameters**:\n- `e_img`: Numpy array with shape [H, W, C].\n- `fov_deg`: Field of view given in int or tuple `(h_fov_deg, v_fov_deg)`.\n- `u_deg`: Horizontal viewing angle in range [-pi, pi]. (- Left / + Right).\n- `v_deg`: Vertical viewing angle in range [-pi/2, pi/2]. (- Down/ + Up).\n- `out_hw`: Output image `(height, width)` in tuple.\n- `in_rot_deg`: Inplane rotation.\n- `mode`: `bilinear` or `nearest`.\n\n\n**Example**:\n```python\nimport numpy as np\nfrom PIL import Image\nimport py360convert\n\ncube_dice = np.array(Image.open('assets/demo_cube.png'))\n\n# You can make conversion between supported cubemap format\ncube_h = py360convert.cube_dice2h(cube_dice)  # the inverse is cube_h2dice\ncube_dict = py360convert.cube_h2dict(cube_h)  # the inverse is cube_dict2h\ncube_list = py360convert.cube_h2list(cube_h)  # the inverse is cube_list2h\nprint('cube_dice.shape:', cube_dice.shape)\nprint('cube_h.shape:', cube_h.shape)\nprint('cube_dict.keys():', cube_dict.keys())\nprint('cube_dict[\"F\"].shape:', cube_dict[\"F\"].shape)\nprint('len(cube_list):', len(cube_list))\nprint('cube_list[0].shape:', cube_list[0].shape)\n```\nOutput:\n```\ncube_dice.shape: (768, 1024, 3)\ncube_h.shape: (256, 1536, 3)\ncube_dict.keys(): dict_keys(['F', 'R', 'B', 'L', 'U', 'D'])\ncube_dict[\"F\"].shape: (256, 256, 3)\nlen(cube_list): 6\ncube_list[0].shape: (256, 256, 3)\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunset1995%2Fpy360convert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsunset1995%2Fpy360convert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunset1995%2Fpy360convert/lists"}