Skip to content

Latest commit

 

History

History
60 lines (38 loc) · 2.06 KB

README.md

File metadata and controls

60 lines (38 loc) · 2.06 KB

pyEquirectRotate

pyEquirectRotate support equirectangular rotation with pure python codes. 😎

You can rotate equirectangular images by rotating the surface of a sphere. 🌏

This code supports (yaw, pitch, roll) rotation, described in this Wikipedia page.

I wrote the code to be numpy-friendly. 😉

  • (yaw, pitch, roll) rotation
  • inverse rotation
  • numpy-friendly
  • single point rotation

Demo Result

demo

Quick Start

cd src
python demo.py
python demo2.py

Code Detail

class EquirectRotate

This is a class that supports equirectangular rotations.

equirectRot1 = EquirectRotate(h, w, (yaw, pitch, roll))
rotated_image = equirectRot1.rotate(src_image)

Once you create an EquirectRotate instance, you can re-use it when all other images are same image format; height, width, (yaw, pitch, roll)

After rotating and if you want to restore it, use .setInverse(True). It is described in demo.py in more detail.

function pointRotate

This is a function that supports a single point rotating on an equirectangular image.

rotated_point = pointRotate(h, w, i, j, (yaw, pitch, roll))

Further Reading

  • I tested my code for non-equirectangular image, for example (N, N) square version image. It still works well, moreover in inverse mapping! 🤩
  • Some formulas are inspired by Paul Bourke's work. link
  • If you want more awesome omnidirectional python codes, I recommend this repository!
  • C/C++ Equirectangular Rotation - whdlgp/Equirectangular_rotate