Code Monkey home page Code Monkey logo

gopro-meta's Introduction

App to extract images asociated with GPS

Purpose:

Given a GoPro movie with metadata (gpmf format), the application extracts images with the given framerate and interpolates the GPS coordinates, speed, accelerometer, gyro, and any other desired metadata.

Dependencies

  • Boost (for filesystem stuff):
  $ sudo apt install libboost-all-dev
  • Opencv3: Link

  • libyaml-cpp for yaml file creation and parsing: Link:

    • Ubuntu 16.04 (apt-get installs v0.5.2):

        $ sudo apt-get install libyaml-cpp-dev
    • Ubuntu 14.04 (apt-get installs v0.5.1 which does not contain yaml-cpp-config.cmake):

        $ git clone https://github.com/jbeder/yaml-cpp.git
        $ cd yaml-cpp/
        $ mkdir build
        $ cd build/
        $ cmake ..
        $ make -j 
        $ sudo make install

Usage

This code uses the gpmf-parser so that submodule has to be cloned into its folder (../gpmf-parser):

  $ git submodule init
  $ git submodule update

After that we can compile and run the script, which parses the metadata in video.mp4 at a frame rate of 3fps, and it saves images and yaml file to folder /tmp/output:

  $ cd img_gps_extractor
  $ mkdir build && cd build
  $ cmake ..
  $ make -j
  $ ./img_gps_extractor -i video.mp4 -f 3 -o /tmp/output

As a design choice, the GoPro never saves videos bigger than 4Gb (not even when SD is extFat). If a video is bigger than this, it splits it into sub videos, with a sort of complicated way to handle the metadata. If this is the case, use the -d option, instead of the -i option.

The following example gets all the videos that correspond to one video in the folder /tmp/input and it deals with everything so that you don't have to merge them externally (not even ffmpeg is currently able to merge gopro videos keeping the metadata):

  $ ./img_gps_extractor -d /tmp/input -f 3 -o /tmp/output

The directory should look something like this:

  $ tree /tmp/input
  /tmp/input
  ├── GOPRXXXX.MP4
  ├── GP01XXXX.MP4
  └── GP02XXXX.MP4

The only check that we do is for the .MP4 extension and then we order in alphabetical order to recover the order structure, so don't rename the files please :)

Format of the output .yaml file:

This is temporary, but it gives an idea of how the final one will look like:

  • ts is timestamp in seconds
  • gps is:
    • lat (degrees)
    • long (degrees)
    • altitude (meters)
    • 2D earth speed magnitude (m/s)
    • 3D speed magnitude (m/s)
000000.jpg:  # Original File: /tmp/input/GOPRXXXX.MP4, Frame rate: 0.020000
  ts: 0
  gps:
    lat: 50.72745
    long: 7.087335
    alt: 121.54
    2dv: 0.061
    3dv: 0.11
000001.jpg:
  ts: 50.00829
  gps:
    lat: 50.72681
    long: 7.088741
    alt: 117.3692
    2dv: 7.321869
    3dv: 7.33
000002.jpg:  # Original File: /tmp/input/GP01XXXX.MP4, Frame rate: 0.020000 (-< when the video it was taken from changes, we comment!)
  ts: 99.99573
  gps:
    lat: 50.7245
    long: 7.09001
    alt: 91.91341
    2dv: 7.956978
    3dv: 7.976304

To parse the yaml file from python:

import yaml
with open("metadata.yaml", 'r') as stream:
  data= yaml.load(stream)
data['000001.jpg']['gps']['lat'] #latitude gps of image 000001.jpg
data['000034.jpg']['ts'] #timestamp for image 000034.jpg

Comments and credits

gopro-meta's People

Contributors

tano297 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.