Git Product home page Git Product logo

360projection's Introduction

360-degree Projection

This repo includes code for rendering 360-degree images/video frames and converting these images among different types of spherical projections.

Equirectangular Projection

In equirectangular projection, angles on the sphere given by yaw and pitch values(in degrees) are discretized and mapped to pixels on a rectangular image with x = (yaw + 180)/360 * width and y = (90 - pitch)/180 * height.

The size of the equirectangular image (width, height). The center of the equirectangular image is at: <yaw = 0, pitch = 0>.

equirectangular.py contains code for rendering view at a specific angle, vertical and horizontal field of view, and view resolution, given an image in equirectangular projection. It also contains code for converting the equirectangular projection to the standard cubic projection.

Cubic Projection

In cubic projections, pixels on a sphere are projected onto six faces of a cube. Six cube faces are then arranged on a planar image for image/video encoding. To date, there exists two types of cubic projections: the standard cubic projection and the offset cubic projection. Standard cube can be seen as a special case of offset cube.

Standard Cube

In this projection, a cube is constructed around the sphere. Rays are projected outward from the center of the sphere, and each ray intersects with both a location on the spherical surface and a location on a cube face. Pixels on the spherical surface are mapped to corresponding pixels on the cube through the mapping produced by these projected rays.

Offset Cube

The offset cubic projection has an orientation. Distortion is performed on the spherical surface so that pixels on the sphere that are close to the oriented area are mapped to wider angles on the cube. More details on the offset cubic projection can be found in our paper:

A Measurement Study of Oculus 360 Degree Video Streaming [pdf]
Chao Zhou, Zhenhua Li, and Yao Liu
Proceedings of ACM Multimedia Systems (MMSys) 2017

cube.py contains code for contains code for rendering view at a specific angle, vertical and horizontal field of view, and view resolution, given an image in cubic projection. It also contains code for converting the cubic projection to the equirectanglar projection.

equi_to_offset_cube.py is used for generating OffsetCube given an equirectangular image as well as OffsetCube settings including the yaw and pitch of offset cube's orientation, width and height of offset cube faces (in pixels), and the magnitude of offcenter_z (e.g., -0.7).

Usage

usage: main.py [-h] config_f img_f

positional arguments:
  config_f    path to config file
  img_f       path to input image

optional arguments:
  -h, --help  show this help message and exit

config is a json formatted file. A few example config files as well as a config_template have been provided in this repo.

For example, to render an equirectangular image, example parameters can be found at config_equi_render, then run

python main.py config_equi_render equi_image.jpg

To convert an equirectangular image to an offset cube image, use example parameters at config_equi_to_offcube and run

python main.py config_equi_to_offcube equi_image.jpg

To render an offset cube image, offset cube parameters (e.g., yaw and pitch of the offset cube, expand coefficient, and offset value) and rendering parameters must be specified in config_offcube_render

python main.py config_offcube_render offset_image.jpg

360projection's People

Contributors

yaoliu-yl 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.