Archive

Posts Tagged ‘Matlab’

Videos in Matlab and Linux

April 23rd, 2007 2 comments

If you do computer vision research (as some of you may). Or any other type of research for that matter… Its a good idea to make nice videos of the results that you obtain. This is a simple disaster-proof way of demoing your work. I’ve been doing this quite a bit lately (as a result of all the video tracking work). I’ve come up with some tips, tricks, and tools that will help out the aspiring video-creator (who uses Matlab and Linux… otherwise you’re out of luck).

Personally, I find Matlab’s built-in avi code terrible. It’s just bad. Instead, I prefer to make figures that show what I want to show on each frame, save those out, and then compile them into a movie later. This seems to be the nicest command to save the frames out:

>>for i=1:last_frame
>> %% code to create the frame in a figure
>> f = getframe;
>> imwrite(f.cdata, sprintf('./video/%04d.png',i));
>>end

This should leave you with a directory full of .png files. From here you have to assemble these into a movie. This is a fantastic script called mkmpeg4 (download). The way to run it is as such (by the way, this only works in Linux with mplayer installed)

$mkmpeg4 -o output.avi -f 30 `ls *.png`
$mplayer output.avi

Note the ` quotation marks as opposed to your typical ‘ marks. This makes compressed videos that look good and will still play on Linux, Windows, and Mac. (Also, they work in PowerPoint). One final tip. If you want to go the other way; take a video and convert it to frames, here’s how:

$mplayer -vo png movie_to_unpack.avi

If you video file is interlaced (looks good in a player, extracted images look bad), try this instead:

$mplayer -nosound -vf pp=ci -vo png:z=0 movie_to_unpack.avi

Happy Matlab Video-ing. Feel free to post your own tips or correct mine in the comments.

Categories: Mac/OSX, Matlab Tags: , ,

Matlab TeXniques

January 29th, 2007 1 comment

Those of you who don’t know or don’t care what Matlab is… today’s post isn’t for you. Just skip it.

Now that the cool kids have left, us geeks can be alone: So, in my lab at GT we primarily use Matlab, so I’m trying to rekindle that romance after a torrid affair with C++ at Siemens. Unarguably, one of the best things about Matlab is how easy it is to visualize things. However, one little tidbit has always bugged me. There is always that damn big fat gray border around all of your figures. This is only mildly annoying while programming… but when it comes time to save figures out for a paper or a report annoying becomes infuriating. You have to scale and crop and zoom and you can’t script it well at all. (Not being able to script things is one of my pet peeves.)

But fear not dear friends… I have found the solution: exportfig. This is a great script for Matlab that lets you A) use tight borders for the figure, B) change the colors cleverly to black and white or grayscale, C) save the figure directly as a .eps file for easy integration with LaTeX! Here’s a nice page that explains how to use the library: Exporting Figures for Publication: Part 2.

One question that I haven’t been able to solve is how to eliminate that gray border in day-to-day usage. I pretty much never want it. If anybody has any suggestions, send them my way!

And, since I have the attention of all you Matlab-ers out there, I just got R2006a (this is the newest version). This baby rocks. It has a cool feature that allows you to execute code in little blocks called ‘cells.’ This is exactly how I debug and prototype, so it saves me a lot of highlighting and pressing [F9]. Check it out if you have the means to.

Categories: LaTeX, Matlab Tags: , ,

Trashbot

May 6th, 2006 4 comments

Trashbot ThumbnailI had a lot of fun “teaching” a Sony Aibo to find and pick up “trash.” This project uses some rudimentary computer vision, simple tracking, audio location, and neural network classification. Plus, its cute!    Click to continue →

Categories: Matlab, Projects Tags: ,

Robot Simulator

February 1st, 2006 5 comments

Robot Simulator IconThis was a quick and dirty project for a robotics class that I took at Georgia Tech in 2005. In this project, I built a Matlab simulator for testing out some simple obstacle avoidance/navigation code. My hope is that someone uses this a springboard to make a more complete version.    Click to continue →

Categories: Matlab, Projects Tags: ,