- 1 Dome2rect v1.5.1 – March 29, 2016
- 1.1 Overview
- 1.2 Download
- 1.3 Installation
- 1.4 Version History
- 1.5 About the Tool
- 1.6 Image Conversion Example
- 1.7 Converting 1080p HD Media to Fulldome
- 1.8 Batch Script Notes
- 1.9 PT Conversion Scripts
Dome2rect v1.5.1 – March 29, 2016
by Andrew Hazelden
Dome2rect is a command line script that uses the open source Panotools library + MPRemap application to automate the process of converting image sequences between multiple panoramic formats. I created this script because I wanted to make it simpler to convert a fulldome movie trailer into a “flat screen” rectilinear format for posting on sites like YouTube.
The dome2rect program is an open source program that is a free download. A sample fulldome image sequence is included.
You can also download the dome2rect toolset from the GitHub page here.
Note: Windows 7 or newer is required to use the dome2rect tools.
For the software to work it has to be expanded and moved to the folder:
Changes in Version 1.5
New in Dome2rect version 1.5 is a movie2imagesequence.bat script that makes it easy to extract image sequences from any .mp4 movies placed in the dome2rect input folder. Also added a script alphaextract.bat that extracts a transparent mask from footage and saves it into an RGB image file in the output folder. The encodemovie.bat script will re-encode a mp4/mov/mkv/avi movie file with ffmpeg into a compact mp4 movie to make it playback better on mobile/tablets/desktop systems.
Changes in Version 1.4
New in Dome2rect version 1.4 is support for converting LatLong Stereo images into the GearVR Stereo cubic format, and a LatLong to mental ray cube1 horizontal strip format conversion.
Changes in Version 1.3
New in Dome2rect version 1.3 is support for LatLong to cubic, horizontal cross, vertical cross, and cubemap3x2 conversions.
About the Tool
I was inspired to make this after reading Jason Fletcher’s blog post on converting fulldome movies for display on flat screens:
Image Conversion Example
The dome2rect conversion process works by reading fulldome formatted imagery from the C:\dome2rect\input folder and saving the converted rectilinear frames to the C:\dome2rect\output folder. Let’s convert the included fulldome angular fisheye sample image sequence named (zosma.0000.jpg – zosma.0035.jpg) to a flattened rectilinear format.
Fulldome Sample Image
Step 1. Edit the batch script file dome2rect.bat using a text editor. Type in your current input and output image filenames.
Step 2. Double click on the dome2rect.bat program to start the conversion process.
Step 3. The script will start and begin converting the imagery. A progress screen displays the status as the mpremap utility converts the current frame. (When the program gets to the end of your image sequence you will get a generic warning indicating mpremap couldn’t find the next image.)
Step 4. When the conversion process is complete we can review the image sequence that was generated in the “output” folder. If you are running Windows 7 you can use the included review.bat movie viewer.
dome2rect.bat Output Image:
This image was created using a dome to rectilinear conversion.
Converting 1080p HD Media to Fulldome
The rect2dome.bat script can be used to convert a 1080p HD JPEG or PNM image sequence into a fulldome formatted fisheye projection.
The final output image resolution and the image positioning is controlled by editing the rect2dome script in the
A sample rectilinear to domemaster image sequence conversion, named rect2dome.0000.jpg to rect2dome.0035.jpg, is included in the
rect2dome.bat Input Image:
This is the input image for the rectilinear to dome conversion.
rect2dome.bat Output Image:
This image was re-projected into a domemaster fisheye format.
When the rect2dome output image is viewed in a fulldome simulator it looks like this:
Note: The Domemaster Stereo shader tool “Dome Viewer” was used to preview the rect to dome conversion.
Batch Script Notes
The tool is an early alpha release and will be improved over time. Right now the only image format enabled for input/output is .jpg files and a UNIX .pnm image format. In the future all the common image/video formats could be supported since the FFMPEG library is used for format conversions.
I created the following example .bat scripts to show what is possible:
This script extracts a transparent mask from footage and saves it into an RGB image file in the output folder.
Converts a an angular fisheye image to a cylindrical image.
Converts an angular fisheye image to a latitude/longitude (equirectangular) image.
Converts a 180 degree domemaster format angular fisheye image to a rectilinear image format.
Re-encode a mp4/mov/mkv/avi movie file with ffmpeg into a compact mp4 movie to make it playback better on mobile/tablets/desktop systems.
Converts a latitude/longitude image to a cubic format that has a single image output with a Cubemap 3×2 arrangement with 3 cubic faces on the top row, and 3 cubic faces on the bottom row.
The Cubemap 3×2 format was popularized by Garden Gnome Software’s Pano2VR Panoramic tools.
Converts a latitude/longitude image to a set of 6 cubic face images.
Converts a latitude/longitude image to a cylindrical image.
Converts a latitude/longitude (equirectangular) image to a fulldome image.
Converts a latitude/longitude image to a cubic format that has a single image output with a horizontal cross arrangement.
Converts a latitude/longitude image into a cubic format that has a single image output with a mental ray cube1 horizontal strip arrangement.
Converts a latitude/longitude (equirectangular) image to a rectilinear image.
Converts a pair of latitude/longitude stereo images into a cubic format that has a single image output with a Samsung Gear VR Stereo horizontal strip arrangement.
Converts a latitude/longitude image to a cubic format that has a single image output with a vertical cross arrangement.
Extract image sequence frames from all of the .mp4 movie files in the input folder using ffmpeg.
Converts a rectilinear image to a fisheye image
Simple playback program to view the image output. This tool uses ffmpeg’s playback tool.
PT Conversion Scripts
Internally the image projections are done using the mpremap library by Helmut Dersch:
The conversion scripts are stored in the scripts/ folder and are written using the Panotools PT Stitcher syntax:
This example panotools conversion script takes an equidistanst fisheye image and converts it to a 1920x1080p rectilinear image output. The image is rolled -10 degrees, and pitched 55 degrees.
# Defish fulldome image to a 1080p HD format:
p f0 w1920 h1080 v90
o f3 v180 r-10 y0 p55
This example panotools conversion script takes an angular fisheye image and converts it to a 2160×1080 cylindrical image output. The image is pitched 90 degrees.
# Defish image to a cylindrical 1080p format:
p f1 w2160 h1080 v360
o f3 v360 r0 y0 p90 b0
This example panotools conversion script takes an angular fisheye image and converts it to a 2048×1024 latitude longitude (equirectangular) image output. The image is pitched 90 degrees.
# Defish image to a latlong 1024p format:
p f2 w2048 h1024 v360
o f3 v360 r0 y0 p90 b0
This example panotools conversion script takes a latitude longitude (equirectangular) image and converts it to a 1920x1080p rectilinear image output.
# latlong image to a 1080p HD format:
p f0 w1920 h1080 v90
o f4 v360 r0 y0 p0
This example panotools conversion script takes a latitude longitude (equirectangular) image and converts it to a 1080×1080 fulldome angular fisheye image output. The image is pitched -90 degrees.
# latlong to fulldome fisheye 1080x1080 format:
p f3 w1080 h1080 v180
o f4 v360 r0 y0 p-90
Here is a quick summary of the PT Stitcher syntax:
'p' = Destination Image Attributes
C0,960,420,960 = Crop Dimensions left,right,top,bottom
f0 = projection mode 0 = rectilinear
f1 = projection mode 1 = cylindrical
f2 = projection mode 2 = equirectagular/latlong
f3 = projection mode 3 = fullframe fisheye
w1920 = destination width 1920 px
h1080 = destination height 1080 px
v90 = horizontal field of view = 90 degrees
'o' = Source Image Attributes
f0 = projection mode 0 = rectilinear
f3 = projection mode 3 = equidistant fisheye
f4 = projection mode 4 = equirectagular/latlong
f5 = projection mode 5 = circular fisheye
f10 = projection mode 10 = equisolid fisheye
r-10 = roll the image -10 degrees (left)
y22 = yaw the image 22 degrees
p45 = pitch the image 45 degrees
b0.1 or b0.5 = barrel distort correct
= useful ranges from -1.0 to 1.0
m = Image Anti-Aliasing
m i2 = smooth spline36 interpolation of the converted imagery
Changing Input & Output File Names
To change the name of the input and output files you can edit the .bat scripts using a plain text editor. All image sequences start on frame number 0 (eg. 0.jpg)
To convert a single frame image enter the exact image name. (eg. image.jpg)
To convert an unpadded image sequence use the value %%d.jpg (eg. 9.jpg )
To convert an a 4 digit padded image sequence use the value %%.4d.jpg (eg: 0009.jpg)
If you want the dome2rect script to process a single frame for testing change the following code:
If you want the dome2rect script to process a 4 digit padded image sequence change the following code: