Batch Processing with Cube2Pano

Photoshop Script Snippets - Note: Full Scripts go in the Photoshop Scripts Forum

Moderators: Kukurykus, Tom, xbytor

Nicholas

Batch Processing with Cube2Pano

Post by Nicholas »

This is a small simple .BAT file I made for use on Win 2000/XP systems as a front end to a panorama stitcher called Cube2Pano. Cube2Pano is a tool that uses PTStitcher which is part of the free panorama tools called PanoTools. The problem with Cube2Pano is that it doesn't support batch processing.

So this simple program acts as a front end to processing a set of six cube faces into a one equirectangular image for a series of frames. This is extremely useful if you want to make a panorama animation from 3D Studio MAX as 3D Studio MAX does not support exporting panorama images in a sequence. The work around is to export 6 cube faces and use these tools to stitch them together.

This tool assumes the images you are feeding into it have the sequence number of the frame at the front and not at the back of the file name.

So for example when making panorama images they are always fed in this order Front, Right, Back, Left, Up and Down

The naming convention expected as an input for this program would be ####_imageXX.jpg.

#### refers to the sequence numbers of your frames, image is the name you have given to your sequence and XX refers to 11,22,33,44,55,66 which in order of cube faces is Front, Right, Back, Left, Up and Down.

The program can easily be changed to add the sequence number at the back of the file name but it is not advisable as Cube2Pano deletes letters off its input file names and appends its own letters which can destroy your frame ordering hence why I have opted to use a front sequence naming convention here.

This program was mainly written for sequences that begin with 0s but can easily be used with single digit or larger sequence numbers.

This program expects that Cube2Pano and this .BAT are in the same folder as the images you expect to process and doesn't check for stupidly inputted variables such as a letter when a digit is expected so use wisely

Just paste into notepad and save as BatchCube2Pano with the extension .bat

Code: Select all@ECHO OFF
:: AUTOMATED BATCH FILE FOR STITCHING 6 CUBE FACES INTO EQUIRECTANGULAR FORMAT FOR USE WITH CUBE2PANO AND PANOTOOLS
CLS
ECHO.
ECHO.****AUTOMATED BATCH STITCHER FOR CUBE2PANO****
ECHO.   ****CREATED BY NICHOLAS PIRES ©2005*****
ECHO.
ECHO.FOR BATCH PROCESSING FRAMES WITH FRONT DIGIT PREFIXS.
ECHO.
ECHO.Image cube faces must be named in the convention ####_imageXX
ECHO.
ECHO.Where #### is sequence number and XX refers to 11,22,33,44,55,66
ECHO.In the order of Front,Right,Back,Left,Up,Down
ECHO.
ECHO.WARNING: If you are stitching files above sequence number 1000 or have a
ECHO.sequence of images that do not have a 0 infront of the frame number enter
ECHO.5 when asked how many 0's are before the actual frame number so you can
ECHO.target your sequence files accordingly.
ECHO.
ECHO.You must enter the number of 0's if you are stitch files from sequence
ECHO.0000 to 0999. Otherwise without the 0 the program will not know where to
ECHO.find your files and increment the stitching number as required.
ECHO.----------------------------------------------------------------------
ECHO.
PAUSE
CLS
SET _0=
SET _num=
SET fov=
SET imode=
SET frame=
SET image=
SET end=
SET width=
ECHO.Enter your stitching Parameters
ECHO.*******************************
ECHO.
SET /p width=Enter Image Width:
ECHO.
ECHO.Width = %width%
ECHO.
SET /p fov=Enter FOV:
ECHO.
ECHO.FOV = %fov%
ECHO.
SET imode=spline64
ECHO.Interpolation mode = %imode%
ECHO.
ECHO.*******************************
PAUSE
CLS
ECHO.Assign starting sequence frame number
ECHO.*************************************
ECHO.
:ZERO
SET /p _0=Enter number 1-3 or (5 for no beginning 0s) for 0's in #### sequence:
GOTO CHECK
:ZERONUM
ECHO.
ECHO.Beginning 0 prefix format = %_0%
ECHO.
SET /p _num=Enter starting frame number without front 0's (eg.0,9,10,199)=
ECHO.
:STARTFRAME
ECHO.Starting frame number = %_0%%_num%
SET frame=%_0%%_num%
ECHO.
GOTO ENDFRAME
:STARTFRAME1000
ECHO.
SET /p _num=Enter starting frame number =
ECHO.
GOTO STARTFRAME
ECHO.
:ENDFRAME
SET /p end=Enter ending frame sequence including 0's (if any):
ECHO.
ECHO.Ending frame sequence number = %end%
ECHO.
SET /p image=Enter Image name prefix (eg "image"):
ECHO.
ECHO.Image name prefix = %image%
ECHO.
CLS
ECHO.Current Batch Parameters
ECHO.************************
ECHO.
ECHO.Equirectangular width = %width%
ECHO.
ECHO.Camera FOV = %fov%
ECHO.
ECHO.Interpolation mode = %imode%
ECHO.
ECHO.Starting frame number = %_0%%_num%
ECHO.
ECHO.Ending frame number = %end%
ECHO.
ECHO.Current frame number = %_0%%_num%
ECHO.
ECHO.Image name prefix = %image%
ECHO.
ECHO.************************
ECHO.
PAUSE
CLS
::*******END CHECK******
ECHO.BEGIN EXECUTION OF BATCH PROCESS
ECHO.********************************
ECHO.
ECHO.Processing images:
ECHO.
ECHO.%frame%_%image%11
ECHO.%frame%_%image%22
ECHO.%frame%_%image%33
ECHO.%frame%_%image%44
ECHO.%frame%_%image%55
ECHO.%frame%_%image%66
ECHO.
ECHO.TO
ECHO.
ECHO.%end%_%image%11
ECHO.%end%_%image%22
ECHO.%end%_%image%33
ECHO.%end%_%image%44
ECHO.%end%_%image%55
ECHO.%end%_%image%66
ECHO.
PAUSE
:START
CLS
SET frame=%_0%%_num%
ECHO.Processing frame number %frame% out of %end%
ECHO.****************************************
ECHO.
If %frame%==%end% GOTO END
:CUBE
IF %_num%==9 SET _0=00
IF %_num%==99 SET _0=0
IF %_num%==999 SET _0=
CALL cube2Pano.bat %width% %fov% %imode% %frame%_%image%11.jpg %frame%_%image%22.jpg %frame%_%image%33.jpg %frame%_%image%44.jpg %frame%_%image%55.jpg %frame%_%image%66.jpg
SET /a _num=_num + 1
GOTO START
ECHO.
:END
CLS
ECHO.Processing frame number %end% out of %end%
ECHO.****************************************
ECHO.
CALL cube2Pano.bat %width% %fov% %imode% %end%_%image%11.jpg %end%_%image%22.jpg %end%_%image%33.jpg %end%_%image%44.jpg %end%_%image%55.jpg %end%_%image%66.jpg
ECHO.
ECHO.
CLS
ECHO.***** BATCH PROCESSING OF FOLDER COMPLETE ******
ECHO.
ECHO.Thank you for using BatchCube2Pano.
ECHO.A Free utility written by Nicholas Pires ©2005.
ECHO.
ECHO.EXIT PROGRAM
PAUSE
EXIT
:EOF
:CHECK
If %_0%==1 GOTO SET1
:CHECK1
If %_0%==3 SET _0=000
:CHECK2
If %_0%==2 SET _0=00
:CHECK3
If %_0%==4 GOTO ZERO
:CHECK0
If %_0%==0 GOTO CHECK1001
:CHECK4
If %_0%==5 GOTO CHECK1000
GOTO ZERONUM
:CHECK1000
If %_0%==5 SET _0=
GOTO STARTFRAME1000
:CHECK1001
If %_0%==0 SET _0=
GOTO STARTFRAME1000
:SET1
SET _0=0
GOTO ZERONUM

Nicholas

Batch Processing with Cube2Pano

Post by Nicholas »

Ive written an updated version of this small app to include a batch rename function for those who do not have a renaming function handy. This will allow you to take a sequential output straight out of your 3D app and use it with this stitcher.

Code: Select all@ECHO OFF
:: AUTOMATED BATCH FILE FOR STITCHING 6 CUBE FACES INTO EQUIRECTANGULAR FORMAT FOR USE WITH CUBE2PANO AND PANOTOOLS
CLS
ECHO.
ECHO.****AUTOMATED BATCH STITCHER FOR CUBE2PANO****
ECHO.   ****CREATED BY NICHOLAS PIRES ©2005*****
ECHO.
ECHO.FOR BATCH PROCESSING FRAMES WITH FRONT DIGIT PREFIXS.
ECHO.
ECHO.Image cube faces must be named in the imageXX_#### or
ECHO.####_imageXX convention for compliance.
ECHO.
ECHO.Where #### is sequence number and XX refers to 11,22,33,44,55,66
ECHO.In the order of Front,Right,Back,Left,Up,Down
ECHO.
ECHO.As part of the processing of the files they will be renamed
ECHO.to a ####_imageXX convention for compliance with Cube2Pano.
ECHO.
ECHO.WARNING: If you are stitching files above sequence number 1000 or have a
ECHO.sequence of images that do not have a 0 infront of the frame number enter
ECHO.5 when asked how many 0's are before the actual frame number so you can
ECHO.target your sequence files accordingly.
ECHO.
ECHO.You must enter the number of 0's if you are stitch files from sequence
ECHO.0000 to 0999. Otherwise without the 0 the program will not know where to
ECHO.find your files and increment the stitching number as required.
ECHO.----------------------------------------------------------------------
ECHO.
PAUSE
CLS
SET _0=
SET _num=
SET fov=
SET imode=
SET frame=
SET image=
SET end=
SET width=
SET quality=
SET rename=
SET undo=
ECHO.Enter your stitching Parameters
ECHO.*******************************
ECHO.
SET /p width=Enter Image Width:
ECHO.
ECHO.Width = %width%
ECHO.
SET /p fov=Enter FOV:
ECHO.
ECHO.FOV = %fov%
ECHO.
SET /p rename=Do you require renaming? Enter 1 for YES and 2 for NO:
ECHO.
If %rename%==1 GOTO YES
If %rename%==2 GOTO NO
:YES
ECHO.Renaming is required!
GOTO UNDO
:NO
ECHO.Renaming is NOT required!
GOTO IMODE
:UNDO
ECHO.
SET /p undo=Do you require an undo of the renaming when done? Enter 1 for YES and 2 for NO:
ECHO.
If %undo%==1 GOTO UYES
If %undo%==2 GOTO UNO
:UYES
ECHO.Undo function for renaming is required!
GOTO IMODE
ECHO.
:UNO
ECHO.Undo function for renaming is NOT required!
GOTO IMODE
:IMODE
ECHO.
SET imode=spline64
ECHO.Interpolation mode = %imode%
ECHO.
ECHO.*******************************
PAUSE
CLS
ECHO.Assign starting sequence frame number
ECHO.*************************************
ECHO.
:ZERO
SET /p _0=Enter number 1-3 or (5 for no beginning 0s) for 0's in #### sequence:
GOTO CHECK
:ZERONUM
ECHO.
ECHO.Beginning 0 prefix format = %_0%
ECHO.
SET /p _num=Enter starting frame number without front 0's (eg.0,9,10,199)=
ECHO.
:STARTFRAME
ECHO.Starting frame number = %_0%%_num%
SET frame=%_0%%_num%
ECHO.
GOTO ENDFRAME
:STARTFRAME1000
ECHO.
SET /p _num=Enter starting frame number =
ECHO.
GOTO STARTFRAME
ECHO.
:ENDFRAME
SET /p end=Enter ending frame sequence including 0's (if any):
ECHO.
ECHO.Ending frame sequence number = %end%
ECHO.
SET /p image=Enter Image name prefix (eg "image"):
ECHO.
ECHO.Image name prefix = %image%
ECHO.
CLS
ECHO.Current Batch Parameters
ECHO.************************
ECHO.
ECHO.Equirectangular width = %width%
ECHO.
ECHO.Camera FOV = %fov%
ECHO.
ECHO.Interpolation mode = %imode%
ECHO.
ECHO.Starting frame number = %_0%%_num%
ECHO.
ECHO.Ending frame number = %end%
ECHO.
ECHO.Current frame number = %_0%%_num%
ECHO.
ECHO.Image name prefix = %image%
ECHO.
ECHO.************************
ECHO.
PAUSE
CLS
::*******END CHECK******
ECHO.BEGIN EXECUTION OF BATCH PROCESS
ECHO.********************************
ECHO.
ECHO.Processing images:
ECHO.
IF "%rename%"=="2" ECHO.%frame%_%image%11
IF "%rename%"=="2" ECHO.%frame%_%image%22
IF "%rename%"=="2" ECHO.%frame%_%image%33
IF "%rename%"=="2" ECHO.%frame%_%image%44
IF "%rename%"=="2" ECHO.%frame%_%image%55
IF "%rename%"=="2" ECHO.%frame%_%image%66
IF "%rename%"=="1" ECHO.%image%11_%frame%
IF "%rename%"=="1" ECHO.%image%22_%frame%
IF "%rename%"=="1" ECHO.%image%33_%frame%
IF "%rename%"=="1" ECHO.%image%44_%frame%
IF "%rename%"=="1" ECHO.%image%55_%frame%
IF "%rename%"=="1" ECHO.%image%66_%frame%
ECHO.
ECHO.TO
ECHO.
IF "%rename%"=="2" ECHO.%end%_%image%11
IF "%rename%"=="2" ECHO.%end%_%image%22
IF "%rename%"=="2" ECHO.%end%_%image%33
IF "%rename%"=="2" ECHO.%end%_%image%44
IF "%rename%"=="2" ECHO.%end%_%image%55
IF "%rename%"=="2" ECHO.%end%_%image%66
IF "%rename%"=="1" ECHO.%image%11_%end%
IF "%rename%"=="1" ECHO.%image%22_%end%
IF "%rename%"=="1" ECHO.%image%33_%end%
IF "%rename%"=="1" ECHO.%image%44_%end%
IF "%rename%"=="1" ECHO.%image%55_%end%
IF "%rename%"=="1" ECHO.%image%66_%end%
ECHO.
PAUSE
ECHO.
SET _0BAK=%_0%
SET _numBAK=%_num%
SET _0BAK=%_0BAK%
SET _numBAK=%_numBAK%
IF %rename%==1 GOTO BSTART
IF %rename%==2 GOTO START
:BSTART
ECHO.Batch renaming files for compliance
ECHO.***********************************
ECHO.
SET frame=%_0BAK%%_numBAK%
:RENAME
If %frame%==%end% GOTO BEND
IF %_numBAK%==9 SET _0BAK=00
IF %_numBAK%==99 SET _0BAK=0
IF %_numBAK%==999 SET _0BAK=
REN %image%11_%frame%.jpg %frame%_%image%11.jpg
REN %image%22_%frame%.jpg %frame%_%image%22.jpg
REN %image%33_%frame%.jpg %frame%_%image%33.jpg
REN %image%44_%frame%.jpg %frame%_%image%44.jpg
REN %image%55_%frame%.jpg %frame%_%image%55.jpg
REN %image%66_%frame%.jpg %frame%_%image%66.jpg
ECHO.Renamed frame %frame% files for compliance
ECHO.******************************************
SET /a _numBAK=_numBAK+1
ECHO.
GOTO BSTART
ECHO.
:BEND
REN %image%11_%end%.jpg %end%_%image%11.jpg
REN %image%22_%end%.jpg %end%_%image%22.jpg
REN %image%33_%end%.jpg %end%_%image%33.jpg
REN %image%44_%end%.jpg %end%_%image%44.jpg
REN %image%55_%end%.jpg %end%_%image%55.jpg
REN %image%66_%end%.jpg %end%_%image%66.jpg
ECHO.Renamed frame %end% files for compliance
ECHO.******************************************
ECHO.
ECHO.Renaming of %frame% files to %end% files complete!
ECHO.
SET _0undo=%_0%
SET _0undo=%_0undo%
SET _numundo=%_num%
SET _numundo=%_numundo%
PAUSE
:START
CLS
SET frame=%_0%%_num%
ECHO.Processing frame number %frame% out of %end%
ECHO.****************************************
ECHO.
If "%frame%"=="%end%" GOTO END
:CUBE
IF %_num%==9 SET _0=00
IF %_num%==99 SET _0=0
IF %_num%==999 SET _0=
CALL cube2Pano.bat %width% %fov% %imode% %frame%_%image%11.jpg %frame%_%image%22.jpg %frame%_%image%33.jpg %frame%_%image%44.jpg %frame%_%image%55.jpg %frame%_%image%66.jpg
REN %frame%_%image%(w%width%).tif %image%_%frame%.tif
ECHO.
SET /a _num=_num+1
GOTO START
ECHO.
:END
CLS
ECHO.Processing frame number %end% out of %end%
ECHO.****************************************
ECHO.
CALL cube2Pano.bat %width% %fov% %imode% %end%_%image%11.jpg %end%_%image%22.jpg %end%_%image%33.jpg %end%_%image%44.jpg %end%_%image%55.jpg %end%_%image%66.jpg
REN %frame%_%image%(w%width%).tif %image%_%frame%.tif
ECHO.
IF "%undo%"=="1" SET frame=%_0undo%%_numundo%
ECHO.
IF "%rename%"=="2" GOTO FINISH
IF "%undo%"=="1" GOTO UNDORENAME
IF "%undo%"=="2" GOTO FINISH
:UNDORENAME
If "%frame%"=="%end%" GOTO UBEND
IF %_numundo%==9 SET _0undo=00
IF %_numundo%==99 SET _0undo=0
IF %_numundo%==999 SET _0undo=
REN %frame%_%image%11.jpg %image%11_%frame%.jpg
REN %frame%_%image%22.jpg %image%22_%frame%.jpg
REN %frame%_%image%33.jpg %image%33_%frame%.jpg
REN %frame%_%image%44.jpg %image%44_%frame%.jpg
REN %frame%_%image%55.jpg %image%55_%frame%.jpg
REN %frame%_%image%66.jpg %image%66_%frame%.jpg
ECHO.Undo rename on %frame% files
ECHO.****************************
SET /a _numundo=_numundo+1
ECHO.
GOTO UNDORENAME
ECHO.
:UBEND
REN %end%_%image%11.jpg %image%11_%end%.jpg
REN %end%_%image%22.jpg %image%22_%end%.jpg
REN %end%_%image%33.jpg %image%33_%end%.jpg
REN %end%_%image%44.jpg %image%44_%end%.jpg
REN %end%_%image%55.jpg %image%55_%end%.jpg
REN %end%_%image%66.jpg %image%66_%end%.jpg
ECHO.Undo rename on %end% files
ECHO.**************************
ECHO.
ECHO.Undo operation on file rename is complete!
ECHO.
PAUSE
:FINISH
CLS
ECHO.***** BATCH PROCESSING OF FOLDER COMPLETE ******
ECHO.
ECHO.Thank you for using BatchCube2Pano.
ECHO.A Free utility written by Nicholas Pires ©2005.
ECHO.
ECHO.EXIT PROGRAM
PAUSE
EXIT
:EOF
:CHECK
If %_0%==1 GOTO SET1
:CHECK1
If %_0%==3 SET _0=000
:CHECK2
If %_0%==2 SET _0=00
:CHECK3
If %_0%==4 GOTO ZERO
:CHECK0
If %_0%==0 GOTO CHECK1001
:CHECK4
If %_0%==5 GOTO CHECK1000
GOTO ZERONUM
:CHECK1000
If %_0%==5 SET _0=
GOTO STARTFRAME1000
:CHECK1001
If %_0%==0 SET _0=
GOTO STARTFRAME1000
:SET1
SET _0=0
GOTO ZERONUM


Enjoy!