mpetroff / pannellum

Pannellum is a lightweight, free, and open source panorama viewer for the web.
https://pannellum.org/
MIT License
4.15k stars 710 forks source link

Generating multires spherical panoramas from Hugin directly? #1152

Open hmeine opened 1 year ago

hmeine commented 1 year ago

I have successfully stitched some high-res photos into spherical panoramas in Hugin, then exported them as equirectangular TIFF, which I then ran through pannellum's generate.py. Since the projections come with some distortions, I am concerned with the multiple resampling steps due to the intermediate TIFF and would like to know if it's possible to write a script that directly exports appropriate cubemaps from Hugin?

mpetroff commented 1 year ago

It's definitely possible, although an easier solution would be to just export your equirectangular image at a higher resolution, so to mitigate any resampling losses.

There are two steps you'd need to do to export the cube map directly from Hugin, setting the projection and then the transformation for each cube face, both of which can be done using the pano_modify utility included with Hugin.

First, set a rectilinear projection with a 90° field of view and let Hugin choose the optimal canvas size:

pano_modify --projection=0 --fov=90x90 --canvas=AUTO --output=f.pto input.pto

Then, rotate the view for the other cube faces:

pano_modify --rotate=180,0,0 --output=b.pto f.pto
pano_modify --rotate=0,-90,0 --output=u.pto f.pto
pano_modify --rotate=0,90,0 --output=d.pto f.pto
pano_modify --rotate=90,0,0 --output=l.pto f.pto
pano_modify --rotate=-90,0,0 --output=r.pto f.pto

This will leave you with six new PTO files, which you can then stitch. The letters correspond to the letters used in Pannellum's multires format. After you stitch the faces, you'd have to create the multires tiles using the method in Pannellum's generate.py script.