sandorlevi / vr180-convert

Simple VR180 image converter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

Simple VR180 image converter

License:MIT License


Languages

Language:Python 99.2%Language:JavaScript 0.8%