Dual Fisheye to Equirectangular Projection Mapping
Many '360°' camera's, such as the dokicam, consist of 2 fish-eye camera's.
Those camera's typically come with desktop software or apps to manipulate the images and for example share to facebook.
It's fun to explore doing this without relying on the official software.
The dokicam stores its photos and videos on its memory card in JPG and MP4 format, easily accessible via USB storage without even removing the card.
Those images and video's show the 'double fish-eye' nature of the device.
Services like Facebook, however require 360° imagery to be mapped
using the Equirectangular Projection. This can be achieved with
using 2 'mapping files' for your image type.
I did not find a suitable mapping for my camera online. However I did find
projection.c by Floris Sluiter which could generate such mapping files
for single-fisheye sources, and modified it to support double-fisheye.
Compile the generator code:
gcc -o projection projection.c -lm
Create mapping files for video and photo's:
./projection -x xmap_dokicam_video.pgm -y ymap_dokicam_video.pgm -h 1440 -w 2880 -r 1440 -c 2880 -b 35 -m samsung_gear_360 ./projection -x xmap_dokicam.pgm -y ymap_dokicam.pgm -h 2048 -w 4096 -r 2048 -c 4096 -b 75 -m samsung_gear_360
Once you have created (or downloaded) the mapping files, use them with ffmpeg:
ffmpeg -i photo.jpg -i xmap_dokicam.pgm -i ymap_dokicam.pgm -filter_complex remap out.jpg ffmpeg -i movie.mp4 -i xmap_dokicam_video.pgm -i ymap_dokicam_video.pgm -filter_complex remap out.mp4
For images, add exif metadata to help e.g. Facebook understand this is 360:
exiftool -ProjectionType="equirectangular" out.jpg
For videos, use Google's Spatial Metadata Injector with the following options:
The method used for mapping is a rather crude pixel-by-pixel conversion. You can clearly see the 'stitch' where the two images are joined together. You can probably achieve much better results with software that actually 'blends' together the images, like hugin, but that's also a bit more complicated ;).