Git Product home page Git Product logo

projectortool's Introduction

Projector tool

A simple script to convert back and forth between panoramic pictures in different projections.

Supported projections

Equi-rectangular projection

Popular for use cases where the image quality matters most along the equator and less at the poles. The ideal aspect ratio is 2:1. Equi-rectangular image

Cube map projection

Often used in games because it is easy to render. Distortions are highest near the edges and corners. The ideal aspect ratio is 4:3. Cube map image

Hemispherical projection

Produced by wide-angle (fish eye) lenses. Distortion drastically increases towards the edges. The ideal aspect ratio is 1:1. Hemispherical image

Dependencies

  • Python 3.7 or greater. f-strings and type hints are used.
  • Pillow
  • Numpy

Usage

python project.py <input image> --in-projection <projection> --out-projection <projection> --out <output image> --width <int> --height <int> --samples <int> --rotation <int,int,int> --hemi-fov-x <int> --hemi-fov-y <int>

  • --in-projection can be any of equirectangular, cubemap, hemispherical. Can also be left blank for auto detection based on aspect ratio.
  • --width and --height control the size of the output image. If omitted, a reasonable size is picked based on input image size and output projection.
  • --samples can be used to specify super-sampling quality. N times N samples per pixel will be taken, so this has a serious performance penalty.
  • --rotation allows for a rotation of the scene along the x, y and z axes. The rotation is applied in this order and must be specified as comma-separated integers (degrees).
  • --hemi-fov-x and --hemi-fov-y can be used to specify the field of view along the x and y image axes when using hemispherical projection. If your image is not square but the scene is circular as in the example image above, the ratio of the FOVs should match the aspect ratio of the image. In the example image, the correct FOVs are x=180 and y=121.

Example:

python project.py example_equi.jpg --in-projection equirectangular --out-projection cubemap --out cube.png --width 1536 --height 1024 --samples 2 --rotation 180,90,0

Bulk processing

To process a large number of images with the same parameters, use the project_many.py script. It generates a lookup table for the projection parameters and given image resolution, which can be applied quickly to many images. Instead of an image file path, it accepts a path to a text file which in turn should contain image file paths. Specify the output directory using --out-dir. The --samples parameter is not supported in this case.

projectortool's People

Contributors

random6174 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.