Mac & OS X Research Software Sports Uncategorized

GoPro GPS Overlay

Yesterday I decided to get an action camera. The decision between a Garmin Virb and the latest GoPro is probably a topic for another article, so let’s just get the decision out of the way; I ended up getting the GoPro Hero3+ Black Edition. In fact, if I’d decided to get the Garmin Virb this article wouldn’t even be necessary. Why? Read on.

Firstly, I’ll say that there are various reasons for getting an action camera, one of which is the need to record my daily ride to work. Nearly every day I encounter situations that I’d like to have proof of, should the need arise. Read: motorists that probably shouldn’t be on the road in the first place.


So what is this article about? I work in I.T. for a living and like looking at GPS data for my proper rides. So, that means you may or may not find the stuff below a wee bit technical. That all depends what you’re into. Anyway, for the GPS part of things I use a Garmin Edge 800. With an action camera, it makes sense that having some speed or other performance data on screen with the video – it’s the inner geek in me controlling that, no doubt. The Elite version of the Garmin Virb has built-in GPS which makes it very easy to overlay GPS data on top of videos. However, because I bought a GoPro, this is an option I don’t have. Not out of the box, at least. But surely it can be done, right?

The short answer: yes!

Desired result

When I look at a cycling video I’ve made, I want to see the current speed & GPS track at the same time. Not in separate windows, either – on top of the video.

The search

I started out looking online for a way to do what I wanted. I found a few ways, including some software that looked promising. Unfortunately, the software is built for Windows only – I use a Mac. Stumped again!

Fortunately for me I found a blog called Syntax Candy, run by a guy called Bartek – a programmer based in Poland. I found that he’d already written a Java application to do exactly what I wanted – score! There are other apps that will do the same thing, but they aren’t free.

Now, I’ve done a fair amount of development in the past but never in Java. That meant my system wasn’t setup for Java development. The next step? Give my system the ability to compile and run Java applications.

The process

Here’s what I had to do get my system ready to run Bartek’s application. I can only cover what I did on OS X, sorry – YMMV for Windows. Note that ~ refers to your home directory.

  1. Download and install the Java Development Kit. As I write this, version 8 is the current version – click here to download.

  2. Set the JAVA_HOME variable. This step is dependant on your shell – the default on OS X is bash, although I use Zsh. For bash, edit ~/.bashrc and for Zsh edit ~/.zshrc (create the relevant file if it doesn’t exist). Put this line in the file:

    export JAVA_HOME=$(/usr/libexec/java_home)
  3. Download Apache Maven – it is required when running Bartek’s application. Click here to download.

  4. You can put Apache Maven anywhere, but put it somewhere that makes sense as you’ll need to reference that location later. On my system, the full path to Apache Maven is in ~/Applications/apache-maven–3.2.1.

  5. Get the full path to your Apache Maven location. To do this, open a Terminal window and type the following commands. They will return the full path, substituting ~ for the actual path to your home directory. Note that this example assumes your Apache Path is ~/Applications/apache-maven–3.2.1.

    cd ~/Applications/apache-maven-3.2.1
  6. Copy the path that is returned – mine is /Users/chris/Applications/apache-maven–3.2.1.

  7. Add the path from step 6 to your PATH environment variable. This isn’t strictly required, but it means you can run Apache Maven without entering the full path to the binary. For bash, edit ~/.bashrc, for Zsh edit ~/.zshrc. On my system, the PATH declaration is as follows – yours will be different, but you can see where I’ve added the Apache Maven path.

    export PATH="/Users/chris/Applications/apache-maven-3.2.1/bin:/Applications/MAMP/bin/php/php5.4.25/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin"
  8. Download the GpsVideo application from Bartek’s blog. Click here to read and download.

  9. Extract the application’s archive somewhere. It doesn’t matter where, as long as you can access it via the Terminal.

  10. Open a Terminal window and change to the directory you extracted the application to. Type the following command. This might take a while as Apache Maven needs to download a bunch of files that are required to run the application.

    mvn package
  11. In the same Terminal window, type the following command. You must be in the GpsVideo application’s directory for this to work.
    mvn compile exec:exec

Here is what the contents of the Terminal window should look like (yours may look different depending on themes, etc).

GpsVideo - Terminal Output
GpsVideo – Terminal Output

And here is what the app should look like, when running correctly.

GpsVideo - Application
GpsVideo – Application

That’s it! If you’ve done everything correctly, the GpsVideo application should run after a few seconds.

GPX files

The Garmin Edge cycle computers save GPS and tracking data in FIT format (by default). For the GpsVideo application, the data needs to be in GPX format. This means taking the FIT file and converting it using something like Garmin Connect or rubiTrack. rubiTrack isn’t free, but the trial version’s only limitation is the number of activities you can have. Imported activites can be exported as GPX from there or Garmin Connect very easily.

What does it look like?

Here’s a screenshot of what a video produced by GpsVideo looks like – not bad at all!

GpsVideo - Video Sample
GpsVideo – Video Sample
Archived Sports Uncategorized

Eufemiano Fuentes – Fascinating Read

If you know me, you know that I ride bikes from time to time.  Ok, so that’s a bit of an understatement – if it wasn’t financially stupid I’d happily spend more on a bike than I ever would on a car … oh wait, my bike *is* worth than my car and my cycling shoes are worth more some peoples’ bikes.  Hmmm … lol.

So anyway, the point of this quick post isn’t to go on about how much my cycling gear is worth (read my ‘Evolution‘ series to get into that) but more to direct anyone reading this to a fascinating article I just found on about Eufemiano Fuentes, the Spanish gynaecologist (by trade), sports physician & doctor at the center of the 2006 cycling scandal, Operación Puerto.

The article, titled "Playing God: Eufemiano Fuentes" goes into some pretty heavy detail on Operación Puerto, Fuentes himself and some of the comments made by people involved in the case.

"Arguably the most important figure in Spanish cycling over the past 20 years, Eufemiano Fuentes is reviled by many but views himself as cycling’s ultimate altruist."

Sports physiology is something I find particularly fascinating and is probably what I’d love to be involved in if I had the academic ability to study medicine but, since I’m just a simple geek, I have to be satisfied with reading about what happens instead of getting arrested for prescribing EPO myself.  😉

If you want to read the article yourself, please do so by clicking the link provided above, or, if you missed it (open your eyes!), by clicking the following link: "Playing God: Eufemiano Fuentes".

Archived Sports Uncategorized

Calculating distance and speed manually

I’ve been doing a reasonable amount of training on the road bike lately and given that the weather here in Melbourne is temperemental at best coming into winter I decided to get another indoor wind trainer. Because I didn’t want to break the bank I didn’t buy one that shows you your speed or distance. Apart from the fact that effective training should be based off heart rate and cadence anyway (or power output if you’re REALLY serious) you’re looking at AUD$800+ for that sort of thing, money I’m not prepared to spend on a trainer at the moment.

Anyway, I still wanted to know how far I’d gone and what my average speed was so I set about figuring out how to calculate these figures given the information I do have – cadence, time, wheel size and gear sizes.

Required Info

A bit of research came up with a few different ways of calculating the distance and average speed when you know the following:

  • Wheel circumference
  • Average cadence for the training session
  • Chainring sizes (measured in number of teeth)
  • Sprocket/cassette cog sizes (measured in number of teeth)
  • Training session time

The method I found that worked best for me came from a Wikipedia page entitled Bicycle Gearing. It contains a whole load of useful information, including how to calculate what is referred to as “metres of development” i.e. the distance travelled for a single crank revolution. This, of course, is dependant on which gear you’re in. Another thing to note before carrying on is that it’s often recommended to train for certain intervals at certain levels of intensity and cadence. The only problem I can see with the calculations below is if you change gears a LOT during a trainer session you’d need to know how long you were in each gear for (in order to calculate the metres of development for each gear used). I’m not a doctor either so please be responsible and don’t train before consulting a physician if you’re not sure what you’re doing. However, carrying on …