Wednesday
Mar312010

Updates for the week

I've got the QT-Canon repo moved from SVN to Git, and you can now check out the code from my GitHub.  On Ubuntu, you can check out the repo and, if you've got the QT SDK installed, build and run the application.  On Windows, you can check out the code, but you can't build it yet, because I haven't figured out what I need to (and am allowed to) include from the Canon SDK.  Give me a few days, and I should have this worked out.  As far as the Mac goes, well that could never happen, I'm not sure yet.  I guess I'll wait and see what happens once people start using this thing.

On the gpx_tools front, I've made some good progress the last few days.  I know I should be working on the algorithms to figure out how many runs you skied and vertical skied, but I got the idea in my head, that the script should know which resort you skied at and present you with data about that resort.  Because this is a brute force problem, I figured I'd just hit it head on.  I started with a GPX file that had waypoints for all the resorts in North America that I got from Travel By GPS.  I decided to turn this into a general purpose XML file (noth_america.xml), and stripped the GPX specific header from the file.  Then I added more info to each resort including: base elevation, vertical, average snow fall, number of runs, number of lifts, and the url for each resort.  I'm going to the website for each resort (and using wikipedia for the larger resorts), and grabbing the information above and adding it to the XML.  For any of the data I can't get, I put a -1 as a place holder.  When I'm all finished, I can spend time looking for the missing data for each of the resorts.  Here is a sample entry in the XML file:

<wpt lat="39.638997000" lon="-106.347394000">
  <ele>8120</ele>
  <vertical>3450</vertical>
  <name>Vail</name>
  <numruns>193</numruns>
  <numlifts>34</numlifts>
  <snow>190</snow>
  <longestrun>2</longestrun>
  <url>http://www.vail.com/mountain/mountain-home.aspx</url>
</wpt>

 

Next, I updated the ski_stats.pl script to use the XML file to figure out which resort you skied at.  The results are pretty nice:

 

 

That's all I've got for now.  Things I plan on tackling in the next week or so are getting the QT-Canon app building on Windows from the GitHub repo, building out the QT-Canon project page, working on the XML file and ski_stats script, and I've been cooking up an idea in my head for another pretty slick QT application.
-- Rob
Saturday
Mar272010

Welcome

Hi and welcome to my new site.  Over the last few years, I've been leaving my mark all over the net.  Well starting today, I've decided to make a permanent home for myself.  Carve out a little corner of the net to bed in.  This site is my personal blog/website/project page, and will contain much randomness that you may or may not be interested in.  All in all, I hope I can post some useful code and share my unique view on things ranging from motorcycles, the interwebs, gadgets, dogs, and maybe every once in a while some politics (don't hold me to that).

I just got this thing up, so there may be some broken links (I imported my old blog) and I'm still working on getting my projects over to my GitHub .  Please be patient with me, as I do have a full time job.  I know I owe a few people from my old blog some updates on a few things.  I'm going to do my best to get updates for code, as well as updated instructions posted ASAP.

Thanks for stopping by!

Wednesday
Feb172010

Perl script for creating time lapse videos from a GoPro HD camera

A few months ago, I bought a GoPro HD helmet cam. It takes 1080p video at 30fps, and is basically bomb proof. Video is not the only thing this little beast does, however. It has a mode to take continuous still pictures at given intervals ( 2,5,30,60 seconds ). Because it has a rather nice glass, wide angle lens, you can capture a lot in a single shot. This camera basically does all the hard work for you, so all you have to do is stitch the pictures back together. If you remember correctly (and you probably don't, because let's face it, who reads this blog?), I did a post on how to use ffmpeg to do stuff. In there I showed how you could use ffmpeg to create time lapse videos from stills. Basically you just do the following:

ffmpeg -r 15 -b 1800 -i IMG_%04d.JPG movie.avi

Anyway, this works for the GoPro as well (except the regex for the image name), but you get a cropped square picture, and pretty poor compression. So how do we fix that? Like so:

ffmpeg %d.JPG -r 12 -croptop 180 -cropbottom 180 -s hd720 -vcodec ffv1 movie.avi

Again, the name regex is incorrect in this case, but I'm just using this for demostration. So, this solves the problem of formatting the video to your liking, but there are two other issues that need to be accounted for:

1. When taking more >1000 images the GoPro makes a new folder and starts the image count over again. So your images end up in folders like 100MEDIA, 101MEDIA, so on and so forth.

2. You now have images with the same name in multiple folders.

The problem with this is the way ffmpeg handles the input of still images. It would be nice if you could just input *.jpg, but you can't. Because you have to have your images named sequentially, you can't delete pictures out of the sequence either.

Because of these problems, I wrote a perl script that grabs all the images in any of the MEDIA folders, resizes and renames them, by modified time, and then puts then in a single folder. It then creates the movie for you.

Download the script here (Update: I added a line to escape spaces in the file names before piping it to ImageMagick)

 To make this script run on Windows:

1. Install Perl from ActiveState - ActivePerl
2. Install ImageMagick - Windows Bins
3. Save the above script into a file called "makeMovie.pl"
4. Copy all the MEDIA folders from your GoPro to a folder on your machine once you've captured your images
5. From the command line, switch into the folder with your MEDIA folders and copy the perl script into the folder
6. Run the perl script

To run this on Linux (Ubuntu):

1. Install imagemagick - sudo apt-get install imagemagick
2. Copy the above script into a file called "makeMovie.pl"
3. From the command line chomod the file - chmod +x makeMovie.pl
4. Copy your MEDIA folders from your GoPro to a folder
5. Copy your perl script into the same folder as the MEDIA folders
6. Run the perl script

Here's a few examples of what you get:

And one from skiing:

Friday
Nov132009

Using ffmpeg to manage video

This is going to be a quick and dirty how-to on ffmpeg and you can find this stuff all over the net (well except the slow motion trick, I couldn't find that anywhere). Here goes:

Where to get ffmpeg
Ubuntu - sudo apt-get install ffmpeg
Windows - Install ImageMagick or Use a binary someone has built

Mac - Aren't you using Final Cut anyway? [Edit: Use this guide to build ffmpeg on the Mac]

 

Easiest way to convert video

 ffmpeg -i video.wmv -sameq video.mpg

Create video from a series of images
Assuming your images are named like this - IMG_0001.JPG, IMG_0002.JPG...
Also, I'm setting the frame rate low here.
ffmpeg -r 15 -b 1800 -i IMG_%04d.JPG movie.mpg

Create a time lapse from a regular video
movie.mpg is the original, and I'm going to save every 5th frame. Then we stitch them back together.
ffmpeg -i movie.mpg -r 5 -f image2 %d.jpg
ffmpeg -b 1800 -i %d.jpg tt_movie.mpg

Make a video slow motion (kind of a hack, but I couldn't find another way)
This will make images from every frame in the clip. Then you stitch them back together with a different frame rate. The lower the rate, the slower the vid.
ffmpeg -i movie.mpg %d.jpeg
ffmpeg -r 10 -b 1800 -i %d.jpg tt_movie.mpg

Add audio to a video
ffmpeg -sameq -ar 22050 -ab 32k -i song.mp3 -i video.mpg videoWithMusic.mpg

Make an image into a video clip (for an intro or credits or something)
This will play for 10 seconds
ffmpeg -loop_input -i image.jpg -t 10 -r 30 -qscale 2 vid.mpg

Trim a video
This will clip the first 30 seconds of the video
ffmpeg -i video.mpg -sameq -ss 00:00:00 -t 00:00:30 trim.mpg

Stitch clips together (no ffmpeg needed)
This only works with a few formats. I tend to always work with mpeg, so this works great for me
cat video.mpg video2.mpg video3.mpg > finalVid.mpg

 

Wednesday
Jul292009

Geotagging photos with your iPhone

Ever since I starting using my iPhone to take photos and upload them to the net, I've really become interested in geotagging my photos. I didn't realize how cool it is to be able to see your photos on a map (or Google Earth) until all my photos started showing up tagged (thanks to the GPS in the iPhone). Having low res photos tagged is cool and all, but I want to tag them with my SLR. You could buy an adapter for you camera from Amazon or you could just use the GPS you're carrying with you every where you go. Here's how:

First, get an app from the app store that logs GPS data points. There are a ton of them, and one app specifically tailored to this called GeoLogTag. Anything that allows you to export your data in a GPX file with times should work. I just use MotionX GPS because it's super cheap for what you get, I use it for hiking as well, and it makes it super easy to share/get the GPX file.

Next you'll need an app that allows you to tie your GPS location and timestamps to your photos. There is a ton of software that does this, but I chose to use a perl script because I wanted something cross platform and any time I can use the command line, I'm happy. You can find the handy dandy perl script called gpsPhoto here. You'll need to install two more perl packages if you don't already have them installed. The site goes over how to install them if you don't already know how.

So let's go step by step:

0. Make sure the time is set correctly on your camera.
1. Turn on MotionX GPS and start logging.
2. Walk around and take pictures like a mofo.
3. When you're done taking pictures, stop MotionX, save the track, and email yourself the GPX log (called sharing in MotionX)
4. Go home and dump the pictures from your camera into a folder.
5. Fire up a command window and change into the directory where you pictures are.
6. Run the perl script. Here is the command I used:

./gpsPhoto.pl --dir geotag --gpsfile Track.gpx --timeoffset 21600

There are a ton of options that you can use, but these 3 should get you by. The first two args are pretty self explanatory, but the third isn't at first. The timeoffset is the UTC offset in your timezone in seconds. I live in Denver, and my offset is 7 hours, minus 1 hour since we are on daylight savings. Just google the local time in your city if you don't know what your offset is, and then multiply that by 60 minutes and 60 seconds.

Anyway, this should get you started, and I was able to get this to work on Windows, Mac OSX, and Ubuntu, so you should be able to follow my instructions on any OS that supports perl. Lastly, you can use any old GPS to get the GPX file, it's just a matter of having your GPS with you as well as the ease of getting the GPX file to your computer.

Page 1 ... 3 4 5 6 7 ... 8 Next 5 Entries ยป