2
\$\begingroup\$

How do I generate a cubic projection (AKA cubemap) with Hugin? I have enough images for a 360 view of my scene. I see the Cubic Projection in the Hugin documentation but I see no mention of it in the software itself. Preferably, I would like to output each face of the cube in a separate image.

\$\endgroup\$
6
  • 1
    \$\begingroup\$ See: vinayhacks.blogspot.com/2010/11/…. Looks like it's more a CLI task with Hugin/Panotools. If you want a GUI, commercial software like Pano2VR or the Flexify PS plugin are possible solutions. \$\endgroup\$
    – inkista
    Commented Aug 4, 2014 at 0:41
  • \$\begingroup\$ Hm, I tried this tutorial using their CLI interface but I'm getting errors: Can't locate auto/Win32/Win32.dll at (eval 1) line 36. Compilation failed in require at /loader/0x1b468fc/Cwd.pm line 643. BEGIN failed--compilation aborted. \$\endgroup\$
    – worbel
    Commented Aug 6, 2014 at 13:45
  • 1
    \$\begingroup\$ Well, that tutorial is for Linux users. I think what's going on is that you basically are creating a script/project file that does the six viewpoints as rectilinear remappings with a specified FoV of 90º. If you want to try creating the script directly, this thread on the panoguide forums might help you out. Personally, I just ponied up for Pano2VR. :) \$\endgroup\$
    – inkista
    Commented Aug 6, 2014 at 18:52
  • \$\begingroup\$ awesome, the panoguide was it. I had to find the documentation for the scripting/program parameters. I'll answer soon with a sample script. Thanks @inkista \$\endgroup\$
    – worbel
    Commented Aug 7, 2014 at 5:45
  • \$\begingroup\$ Yeah, the guys on the panoguide board are THE source for messing about with equirectangulars. \$\endgroup\$
    – inkista
    Commented Aug 7, 2014 at 16:23

2 Answers 2

1
\$\begingroup\$

Pano2VR or Flexify are probably your simplest solution, but if you're a scripting geek and have to use Hugin tools, then scripting nona commands is the way to go.

Since the panoguides board went down in sea of spam, I go to the Internet archives and post DorinDXN's answer (with some minor edits) of a Windows .bat file to create six nona_gui scripts and run them to create the six cube face images.


This is the equi2cubic100.bat file.

You'll need nona_gui.exe from the Hugin distribution. In the same folder with nona_gui.exe, place the pano.tif that is the equirectangular file.

You can change w1500 h1500 with the desired cube-face dimension in pixels w6000 h3000 with the size of the equirectangular and v100 (100°) for the FoV of the cubic.

Each line starts with @, don't break it into sublines.

@echo press any key if pano.tif was produced by PTGui
pause
@echo.
@echo -----------------------------------------------------
@echo Generating Face_0 FRONT
@echo p f0 w1500 h1500 v100 >script.txt
@echo m g1 i2 f0 m0>>script.txt
@echo o w6000 h3000 f4 p0 r0 v360 y0  u10 m0 n"pano.tif">>script.txt
@nona_gui -o cube_0.tif script.txt

@echo.
@echo -----------------------------------------------------
@echo Generating Face_1 RIGHT
@echo p f0 w1500 h1500 v100 >script.txt
@echo m g1 i2 f0 m0>>script.txt
@echo o w6000 h3000 f4 p0 r0 v360 y270  u10 m0 n"pano.tif">>script.txt
@nona_gui -o cube_1.tif script.txt
@echo.

@echo -----------------------------------------------------
@echo Generating Face_2 BACK
@echo p f0 w1500 h1500 v100 >script.txt
@echo m g1 i2 f0 m0>>script.txt
@echo o w6000 h3000 f4 p0 r0 v360 y180  u10 m0 n"pano.tif">>script.txt
@nona_gui -o cube_2.tif script.txt
@echo.

@echo -----------------------------------------------------
@echo Generating Face_3 LEFT
@echo p f0 w1500 h1500 v100 >script.txt
@echo m g1 i2 f0 m0>>script.txt
@echo o w6000 h3000 f4 p0 r0 v360 y90  u10 m0 n"pano.tif">>script.txt
@nona_gui -o cube_3.tif script.txt
@echo.

@echo -----------------------------------------------------
@echo Generating Face_4 UP
@echo p f0 w1500 h1500 v100 >script.txt
@echo m g1 i2 f0 m0>>script.txt
@echo o w6000 h3000 f4 p270 r0 v360 y0  u10 m0 n"pano.tif">>script.txt
@nona_gui -o cube_4.tif script.txt
@echo.

@echo -----------------------------------------------------
@echo Generating Face_5 DOWN
@echo p f0 w1500 h1500 v100 >script.txt
@echo m g1 i2 f0 m0>>script.txt
@echo o w6000 h3000 f4 p90 r0 v360 y0  u10 m0 n"pano.tif">>script.txt
@nona_gui -o cube_5.tif script.txt
@echo.
@del script.txt
\$\endgroup\$
1
  • 1
    \$\begingroup\$ If you add the command @Echo off to the start of your batch file you won't need to pre-pend each individual echo command with an @. \$\endgroup\$
    – Peter M
    Commented Mar 28, 2017 at 12:47
1
\$\begingroup\$

The input file (pano.tif above) needs to be a full, spherical panorama, as indicated by 'f4' and the 2:1 aspect ratio.

Each cube face will be a rectilinear panorama, as indicated by 'f0' above. The field of view for the face should probably be 90 degrees, rather than 100 as selected by 'v100' above.

Here is a shell script from MacOS with Hugin installed:

#!/bin/sh

# create cube faces
# $1  # path to equirectangular ("full spherical") panorama file (360x180 degrees)
# $2  # cube dimension in pixels
# $3  # cube field of vision (default 90)
# $4  # width of $1 in pixels
# $5  # height of $1 in pixels [should be 0.5 * $4]

# faces are "$1"-{left,right,front,back,up,down}.jpg

p="p f0 w$2 h$2 v$3"       # p-line describes rectilinear panorama on cube face
m="m g1 i2"                # m-line: gamma 1.0 spline36 interpolator
o="o f4 w$4 h$5 v360 r0"   # o-line selects from spherical full panorama

# path to "nona"
nona='/Applications/Hugin/HuginStitchProject.app/Contents/MacOS/nona'

# temporary file for script
tmp="/tmp/$$.oto"
trap 'rm -f $tmp' 0

# remove previous faces, if any
rm -f "$1"-*.jpg

# create scripts and extract the faces
cat > "$tmp" << eof
$p
$m
$o p0 y0 n"$1"
eof
"$nona" -m JPEG -z 95 -o "$1"-front.jpg "$tmp"

cat > "$tmp" << eof
$p
$m
$o p0 y270 n"$1"
eof
"$nona" -m JPEG -z 95 -o "$1"-right.jpg "$tmp"

cat > "$tmp" << eof
$p
$m
$o p0 y180 n"$1"
eof
"$nona" -m JPEG -z 95 -o "$1"-back.jpg "$tmp"

cat > "$tmp" << eof
$p
$m
$o p0 y90 n"$1"
eof
"$nona" -m JPEG -z 95 -o "$1"-left.jpg "$tmp"

cat > "$tmp" << eof
$p
$m
$o p270 y0 n"$1"
eof
"$nona" -m JPEG -z 95 -o "$1"-up.jpg "$tmp"

cat > "$tmp" << eof
$p
$m
$o p90 y0 n"$1"
eof
"$nona" -m JPEG -z 95 -o "$1"-down.jpg "$tmp"

Here is an archive with an Automator workflow as a graphical user interface for the shell script.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.