Git Product home page Git Product logo

max2sphere's Introduction

max2sphere

maxsSphere Batch takes raw GoPro .360 frames (two strips of cube map projections encoded as EAC) and converts them to a more widely recognised equirectangular projection.

READ BEFORE YOU BEGIN

Installation

The max2sphere command line utility should build out of the box on Linux using the simple Makefile provided. The only external dependency is the standard jpeg library (libjpeg), the lib and include directories need to be on the gcc build path. The same applies to MacOS except Xcode and command line tools need to be installed.

$ git clone https://github.com/trek-view/max2sphere
$ make -f Makefile
$ @SYSTEM_PATH/max2sphere

Where @SYSTEM_PATH is full route to repo and max2sphere command, e.g.

/Users/dgreenwood/Documents/repos/trek-view/max2sphere/max2sphere

Note for Mac M1 Chip users

I ran into a few issues with my new Mac with an M1 chop that required a slightly different Makefile (because homebrew directory issues finding installed files, specifically fatal error: 'jpeglib.h' file not found).

To address this, instead use the following Makefile;

$ git clone https://github.com/trek-view/max2sphere
$ cd max2sphere
$ make -f Makefile-MacM1
$ @SYSTEM_PATH/max2sphere

Note for Linux users

An issue was raised identifying issues with Linux distros. In this case it was due to the Makefile config.

To address this, instead use the following Makefile;

$ git clone https://github.com/trek-view/max2sphere
$ cd max2sphere
$ make -f Makefile-Linux
$ @SYSTEM_PATH/max2sphere

Usage

Preparation

This script is designed to be used with frames.

You will need to first convert a .360 video to frames and then pass the two corresponding frames to the script (2 frames because .360's use 2 video tracks).

You can use ffmpeg to split your .360 video into frames (below at a rate of 1 FPS).

$ ffmpeg -i INPUT.360 -map 0:0 -r 1 -q:v 1 track0/img%d.jpg -map 0:5 -r 1 -q:v 1 track5/img%d.jpg

Note: this assumes video tracks are 0:0 and 0:5. If timelapse mode is used, the tracks are different:

  • Regular video = -map 0:0 and -map 0:5
  • Timewarp video = -map 0:0 and -map 0:4

Script

$ max2sphere [options] DIRECTORY_%d/img_%4d.jpg

Variables:

The DIRECTORY_%d should contain two %d entries, one for each video track (e.g. DIRECTORY_1 and DIRECTORY_2).

The img_%4 should contain sequentially numbered frames from each track with matching numbers (e.g. DIRECTORY_1/img_1.jpg and DIRECTORY_1/img_2.jpg).

Options:

  • -w n sets the output image width, default: -1
  • -a n sets antialiasing level, default = 2
  • -o s specify the output filename, default is based on track0 name. If specified then it should contain one %d field for the frame number
  • -n n Start index for the sequence, default: 0
  • -m n End index for the sequence, default: 100000
  • -d enable debug mode, default: off

How lookup tables are handled

max2sphere will first look for a lookup table (these are stored in the root directory once the script has successfully run once).

If it finds one it will read it and use it during the current processing run.

If it doesn't find a lookup table (or if the read above fails) it will create one and save it to disk and then use it during the current processing run.

Lookup tables rely on four values: the template number, the output width and height, and the antialising value.

e.g. Template 0, width 5376, height 2688 and antialising of 2.

In the case above where the output image width was autodetermined the lookup table is called 0_5376_2688_2.data

The template refers to the recording mode, the template defines the various geometric values the code needs in order to extract out the parts correctly.

Currently two recording modes are supported. At the top of the max2sphere.c file you will see the line referencing them:

FRAMESPECS template[NTEMPLATE] = {{4096,1344,1376,1344,32,5376},{2272,736,768,736,16,2944}};

The lookup table does take almost no time to read, compared to calculating the lookup table. However it does end up taking a decent about of disk space, almost 700MB in this case.

For us, this is acceptable as we only ever have 2 static lookup tables using default settings for 5.6k and 3k videos.

You can download these here:

5-6-video-4096w.data (5.6k)

pip3 install gdown
$ gdown --id 1_kynph90d3ZnaONQNXKCjZzgyMgd-Yfw

3k-video-2272w.data (3k)

pip3 install gdown
$ gdown --id 1LjZO_e-yhfMRuTcwkp2aLPQchNvvJwfj

Examples (MacOS)

Use a GoPro Max 3K video (input width = 2272 // recommended output width = 3072)

Single image

$ /Users/dgreenwood/max2sphere/max2sphere -w 3072 -n 1 -m 1 -o testframes/3k/single/STITCHED/GS018423_%d.jpg testframes/3k/single/track%d/GS018423_%d.jpg

Directory of images

$ /Users/dgreenwood/max2sphere/max2sphere -w 3072 -n 1 -m 4 -o testframes/3k/directory/STITCHED/GS018423_%d.jpg testframes/3k/directory/track%d/GS018423_%d.jpg
Use a GoPro Max 5.6K video (input width = 4096 // recommended output width = 5376)

Single image

$ /Users/dgreenwood/max2sphere/max2sphere -w 5376 -n 1 -m 1 -o testframes/5_6k/single/STITCHED/GS018421_%d.jpg testframes/5_6k/single/track%d/GS018421_%d.jpg

Directory of images

$ /Users/dgreenwood/max2sphere/max2sphere -w 5376 -n 1 -m 4 -o testframes/5_6k/directory/STITCHED/GS018421_%d.jpg testframes/5_6k/directory/track%d/GS018421_%d.jpg

Debugging

Failed to open warning

If you see the warning:

ReadFrame() - Failed to open "testframes/5_6k/track0/GS018421_11.jpg"

It is likely the value for -m used does not match the number of frames in the directories used.

This is not a critical error, and you should find all processed frames.

License

Apache 2.0.

max2sphere's People

Contributors

himynamesdave avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

max2sphere's Issues

sequence filenames are not filled with leading zeros but with spaces

ffmpeg fills filenames with leading zeros, when told to do so;
ffmpeg -t 00:00:01 -i INPUT.360 -map 0:0 -r 1 -q:v 1 track0/img%4d.jpg -map 0:5 -r 1 -q:v 1 track5/img%4d.jpg

max2sphere -n 1 -m 3 -o out/%d_sphere.jpg track%d/img%4d.jpg
gives the error:
CheckFrames() - Failed to open first frame "track0/img 1.jpg"

extract origin dual fisheye and imu measurements

Thanks so much for your job! i'm a newbie about gopro or ffmeg. I wonder if could i get the origin dual fisheye images and imu measurements from gopro max .360 file as i want to use it to do vio job. Thanks for your help!

`make -f Makefile` fails to run

When I try to run make -f Makefile on Windows 11 or make -f Makefile-Linux on WSL2 I get following output:

gcc  -Wall -O3  -o max2sphere max2sphere.o bitmaplib.o  -ljpeg -lm
max2sphere.o: file not recognized: file format not recognized
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:12: max2sphere] Error 1

What am I doing wrong?

how i can pass a unique frame name to max2sphere?

Thank you for the awesome repo. it helped me a lot. now i am stuck in something.

I have extracted frames from 360 videos and assigned a unique name to each frame. now I am stitching frames but getting this error.
how i can pass a unique frame name to max2sphere?

this is my command:
/max2sphere/max2sphere -w 4096 -n 1 -m 4 -o media//GS0111.360//stitched//123.jpg
media//GS011145.360//track%d//123.jpg

Error: This filename template "media//GS011145.360//track%d//123.jpg" does not look like it contains sufficient %d entries
Expect 2 but found 1

please reply.
thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.