valioDOTch / dualfisheye2equirectangular

Convert 'dual-fisheye' 360 image material to equirectangular mapping

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dual Fisheye to Equirectangular Projection Mapping

Many '360' camera's, such as the dokicam, consist of 2 fish-eye camera's.

Why DIY?

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.

Storage

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.

Projection conversion

Those images and video's show the 'double fish-eye' nature of the device. Services like Facebook, however require, require 306 imagery to be mapped using the Equirectangular Projection. This can be achieved with ffmpeg using 2 'mapping files' for your image type.

Mapping generation

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

Usage

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

I haven't figured out how to add video metadata yet.

Quality

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 ;).

About

Convert 'dual-fisheye' 360 image material to equirectangular mapping

License:MIT License


Languages

Language:C 99.4%Language:Makefile 0.6%