Skip to main content

Simple VR180 image converter

Project description

VR180 image converter

CI Status Documentation Status Test coverage percentage

Poetry black pre-commit

PyPI Version Supported Python versions License


Documentation: https://vr180-convert.readthedocs.io

Source Code: https://github.com/34j/vr180-convert


Simple VR180 image converter on top of OpenCV and NumPy.

Installation

Install this via pip (or your favourite package manager):

pipx install vr180-convert
Left Right Output
left right output

Usage

Simply run the following command to convert 2 fisheye images to a SBS equirectangular VR180 image:

v1c lr left.jpg right.jpg

You can also specify the conversion model by adding Python code directly to the --transformer option:

v1c lr left.jpg right.jpg ---transformer "EquirectangularEncoder() * Euclidean3DRotator(from_rotation_vector([0, np.pi / 4, 0])) * FisheyeDecoder("equidistant")"

Please refer to the API documentation for the available transformers and their parameters. For from_rotation_vector, please refer to the numpy-quaternion documentation.

The radius of the non-black area of the input image is assumed by counting black pixels by default, but it would be better to specify it manually to get stable results:

v1c lr left.jpg right.jpg --radius 1000
v1c lr left.jpg right.jpg --radius max # min(width, height) / 2

To convert a single image, use v1c s instead.

For more information, please refer to the help or API documentation:

v1c --help

Usage as a library

For more complex transformations, it is recommended to create your own Transformer.

Note that the transformation is applied in inverse order (new[(x, y)] = old[transform(x, y)], e.g. to decode orthographic fisheye images, transform_polar should be arcsin(theta), not sin(theta).)

from vr180_convert import PolarRollTransformer, apply_lr

class MyTransformer(PolarRollTransformer):
    def transform_polar(
        self, theta: NDArray, roll: NDArray, **kwargs: Any
    ) -> tuple[NDArray, NDArray]:
        return theta**0.98 + theta**1.01, roll

transformer = EquirectangularEncoder() * MyTransformer() * FisheyeDecoder("equidistant")
apply_lr(transformer, left_path="left.jpg", right_path="right.jpg", out_path="output.jpg")

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

Credits

This package was created with Copier and the browniebroke/pypackage-template project template.

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

vr180_convert-0.1.0.tar.gz (13.8 kB view hashes)

Uploaded Source

Built Distribution

vr180_convert-0.1.0-py3-none-any.whl (12.4 kB view hashes)

Uploaded Python 3

Supported by

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