Skip to main content

Dewarp top-down fisheye image to panorama and rewarp panorama to fisheye image.

Project description

Fisheye Warping

Panorama

Fisheye

PyPI pyversions PyPI implementation

Test Release

PyPI status PyPI license

PyPI version fury.io

PyPI download month PyPI download week PyPI download day

forthebadge made-with-python

A tool for dewarping and rewarping on a top-down fisheye image by using OpenCV on Python.

Installation

pip install FisheyeWarping

Usage

fisheyewarping --help
usage: fisheyewarping [-h] [--panorama_output PANORAMA_OUTPUT] [--fisheye_output FISHEYE_OUTPUT] [--save_dewarp_mesh_path SAVE_DEWARP_MESH_PATH] [--save_rewarp_mesh_path SAVE_REWARP_MESH_PATH] [--load_dewarp_mesh_path LOAD_DEWARP_MESH_PATH]
                      [--load_rewarp_mesh_path LOAD_REWARP_MESH_PATH] [--fisheye_img_path FISHEYE_IMG_PATH] [--panorama_img_path PANORAMA_IMG_PATH] [--use_multiprocessing USE_MULTIPROCESSING]

optional arguments:
  -h, --help            show this help message and exit
  --panorama_output PANORAMA_OUTPUT
                        Specific path for `output`. Default is `./dewarp-output.png`.
  --fisheye_output FISHEYE_OUTPUT
                        Specific path for `output`. Default is `./rewarp-output.png`.
  --save_dewarp_mesh_path SAVE_DEWARP_MESH_PATH
                        Specific path for saving mesh data for `dewarping`. Default is `None`.
  --save_rewarp_mesh_path SAVE_REWARP_MESH_PATH
                        Specific path for saving mesh data for `rewarping`. Default is `None`.
  --load_dewarp_mesh_path LOAD_DEWARP_MESH_PATH
                        Specific path for loading mesh data for `dewarping`. Default is `None`.
  --load_rewarp_mesh_path LOAD_REWARP_MESH_PATH
                        Specific path for loading mesh data for `rewarping`. Default is `None`.
  --fisheye_img_path FISHEYE_IMG_PATH
                        Specific path of your fisheye image for dewarping to a panorama.
  --panorama_img_path PANORAMA_IMG_PATH
                        Specific path of your panorama image for rewarping to a fisheye image.
  --use_multiprocessing USE_MULTIPROCESSING
                        Use multiprocessing to get mesh. Default is `True`.

Example

Dewarp a fisheye image to panorama

  • In the first time, you will need to build a mesh file for dewarping.

    fisheyewarping \
    --save_dewarp_mesh_path ./dewarp-mesh.pkl \
    --fisheye_img_path ./test-fisheye.jpg
    
    import cv2
    from fisheyewarping import FisheyeWarping
    fisheye_img = cv2.imread('./test-fisheye.jpg')
    frd = FisheyeWarping(fisheye_img, use_multiprocessing=True)
    frd.build_dewarp_mesh(save_path='./dewarp-mesh.pkl')
    frd.run_dewarp(save_path='./dewarp-output.png')
    
  • In the next time, you just load the mesh and feel free to go.

    fisheyewarping \
    --load_dewarp_mesh_path ./dewarp-mesh.pkl \
    --fisheye_img_path ./test-fisheye.jpg
    
    import cv2
    from fisheyewarping import FisheyeWarping
    fisheye_img = cv2.imread('./test-fisheye.jpg'.)
    frd = FisheyeWarping(fisheye_img, use_multiprocessing=True)
    frd.load_dewarp_mesh(save_path='./dewarp-mesh.pkl')
    frd.run_dewarp(save_path='./dewarp-output.png')
    

Rewarp any panorama image to fisheye

  • In the first time, you will need to build 2 mesh files for dewarping and rewarping by using one fisheye image.

    fisheyewarping \
    --save_dewarp_mesh_path ./dewarp-mesh.pkl \
    --save_rewarp_mesh_path ./rewarp-mesh.pkl \
    --fisheye_img_path ./test-fisheye.jpg
    
    import cv2
    from fisheyewarping import FisheyeWarping
    fisheye_img = cv2.imread('./test-fisheye.jpg'.)
    frd = FisheyeWarping(fisheye_img, use_multiprocessing=True)
    frd.build_dewarp_mesh(save_path='./dewarp-mesh.pkl')
    frd.build_rewarp_mesh(save_path='./rewarp-mesh.pkl')
    panorama_img = cv2.imread('./test-panorama.jpg'.)
    frd.run_rewarp_with_mesh(panorama_img, save_path='./rewarp-output.png')
    
  • In the next time, you just load the meshes and feel free to go.

    fisheyewarping \
    --load_dewarp_mesh_path ./dewarp-mesh.pkl \
    --load_rewarp_mesh_path ./rewarp-mesh.pkl \
    --panorame_img_path ./test-panorama.jpg
    
    import cv2
    from fisheyewarping import FisheyeWarping
    frd = FisheyeWarping(None, use_multiprocessing=True)
    frd.load_dewarp_mesh(save_path='./dewarp-mesh.pkl')
    frd.load_rewarp_mesh(save_path='./rewarp-mesh.pkl')
    panorama_img = cv2.imread('./test-panorama.jpg'.)
    frd.run_rewarp_with_mesh(panorama_img, save_path='./rewarp-output.png')
    

Mesh

The source of mesh image is from (http://paulbourke.net/dome/fish2/).

Here is the mesh image for this tool, it shows the transformation from the original fisheye image to the panorama image.

  • Before - Fisheye
Fisheye
  • After - Panorama
Panorama

Contributor

Nat Lee
Nat Lee

LICENSE

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

FisheyeWarping-1.0.0.tar.gz (2.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

FisheyeWarping-1.0.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file FisheyeWarping-1.0.0.tar.gz.

File metadata

  • Download URL: FisheyeWarping-1.0.0.tar.gz
  • Upload date:
  • Size: 2.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for FisheyeWarping-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5e87cfb8343d7c6b49cc8e6e20b6a3770b050e4b00eace860c29309517aca431
MD5 f64d9079647318534dc43a05da76cec7
BLAKE2b-256 8543d32e23aa2365ced8af1139c73144cbd7c5212499ca47da30e5d72a62fef1

See more details on using hashes here.

File details

Details for the file FisheyeWarping-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: FisheyeWarping-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for FisheyeWarping-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1685bb31b06d2087afdbc7a8fe56377b61d3cbe0ac2506b678b141de36dc1f4a
MD5 5ad696b6a392f8be0dd50b29e9a42790
BLAKE2b-256 4e80e98e1c0503bab3decb5a8b26a85f500e5b8829aa5519a9476cdb4d230d6f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page