A batch controller for Autostitch

Autostitch is an automatic 2D image stitcher. Give it a collection of partly overlapping images, and it will position and blend them into a seamless panorama. A demo version of Autostitch is available for free download. It has a simple GUI which can be used to select input images, and adjust parameters such as output resolution, cropping, and image rotation. However, the GUI interface is a little inconvenient when you have a large number of repetitive stitching tasks to perform, for example : panoramic video.

A panoramic video can be made by stitching each frame of an input video against a background panorama, as described in this earlier post. To do this we need to run thousands of separate stitching operations, each with different sets of images. Its too much to do by hand via the GUI, which is why I wrote this little batch controller for Autostitch.

The batch controller is a simple program that pretends to be a user, sending sequences of events to the GUI to simulate the normal operation of the program:

  1. In the Autostitch window, select menu File -> Open.
  2. When the open dialog appears, enter a set of image names into the edit control, and then press the “Open” button
  3. Wait for Autostitch to finish processing
  4. When Autostitch opens the preview window, close it. This makes Autostitch ready to perform the next stitching operation

Fortunately, this is not too hard to do using the Win32 API. FindWindow(NULL, name) gets us a top-level window with a given name (eg. “autostitch” or “Open”). The controls for a window can be recursively enumerated using EnumChildWindows(window, callback, data). We can use our own callback function to search based on the name or class of a control. Windows uses messages to communicate events to controls. We can generate the same messages using SendMessage. For example, to click a button:

  SendMessage(button, BM_CLICK, 0, 0);

or to enter text into an Edit control:

  SendMessage(edit, WM_SETTEXT, 0, (LPARAM) text);

If you want more details, check out the source from the download links below.

Usage

To use the batch controller, you need to first start Autostitch in the usual way. Autostitch must be “pointing” at the directory containing your source images. You can set this using the “File->Open” menu. Just select one or more images and press “Open” - it doesn’t matter whether the result is successful or not. From the command-line, you can then stitch any set of images from that directory like this:

  stitch file1.jpg file2.jpg file3.jpg

This will stitch the images as usual, opening the result “pano.jpg” in the default image previewer. To run multiple stitches in sequence, the preview window must be closed before the next stitch can start. Request this by specifying -wait -close. For example:

  stitch -wait -close file1.jpg file2.jpg file3.jpg

To stitch a sequence of images, use the -template option, like this:

  stitch -template frame%03d.jpg 20 50 file1.jpg file2.jpg file3.jpg

This specifies a file name template (using sprintf syntax), and a range of file numbers. The example generates a sequence of names “frame020.jpg”, “frame021.jpg”, …, “frame050.jpg”. Each stitch operation combines one of the sequence names with the remaining arguments, and renames the output panorama (by default, to “out0020.jpg” … “out0050.jpg”). Template mode automatically implies -wait -close.

Here are some simple examples using the Autostitch demo images:

  stitch -wait -close 100-0023_img.jpg 100-0024_img.jpg 100-0025_img.jpg

This stitches the bottom 3 images of the “mountain” panorama.

  stitch -path s:/stewart/programs/autostitch/images/test/ \
             -template 100-%04d_img.jpg 38 40 \
             100-0023_img.jpg 100-0024_img.jpg 100-0025_img.jpg

This stitches each of the top three images (38..40) against the bottom three images, producing three outputs, “out0038.jpg” .. “out0040.jpg”. (change the path to reflect your Autostitch installation).

There are a bunch of settings that you might need to change. For example, the system looks for the preview window using one of the standard applications (”pano.jpg - Windows Picture and Fax Viewer” or “Microsoft Photo Editor - [pano.jpg]”). If you have a different preview app, you’ll need to change the title of the preview window using the -output option.

In “template” mode, the system renames each “pano.jpg” to a different file name using the sequence number, but to find the resulting file you need to specify the result directory using -path. Alternatively, run the stitch command from the directory containing the source images.

Options:
-help      Show help message and exit
-version   Show version and exit
-wait      Wait for Autostitch to complete (single stitch only)
-close     Close preview opened by Autostitch (single stitch only)
-template  temp start end Specify template for batch operation
           A range of images is processed for start <= id <= end. Use sprintf
           formatting (eg. id=23, temp=’file%04d.jpg’ -> ‘file0023.jpg’)
-dryrun    Just output batch image lists without calling Autostitch
-path      Path to image directory (for batch stitch). INCLUDE TRAILING ‘/’

Stuff you probably don’t need to change:
-window    Name of Autostitch window (default: autostitch)
-status    Name of Autostitch status window (default: Status)
-output    Name of preview window (default: ‘pano.jpg - Windows Picture and Fax Viewer’)
-fileOpen  Menu name for File->Open dialog (default: ‘File:Open’)
-openTime  Delay (in ms) for open dialog to populate controls (default: 500)
-closeTime Delay (in ms) to wait before closing preview window (default: 2000)
-outjpg    Template (dir,id) for output files (default: ‘%sout%04d.jpg’)
-outtxt    Template (dir,id) for output files (default: ‘%sout%04d.txt’)

Download

This app is fairly minimalist, but it should not be hard to modify if required. I used mingw + gcc which are available for free from mingw.org.

Have fun! And if you manage to create something interesting, please post a comment.

Check here for more fun with Autostitch.

Google’s new Dr Seuss look

Google recently replaced their “big G” favicon with a “little g”. At the same time, they made it transparent, which I think was probably a mistake because it doesn’t look consistent and is hard to read against some backgrounds.

The “little g” is has a kind of archaic, quirky feel. While its used a lot in print, the “looptail” version its not so common in screen fonts which I guess makes it distinctive. Unfortunately, I’m immediately reminded of the typography of Dr Seuss.

Now this is not necessarily a bad thing, but I wonder if that’s what they intended.

Update: The Official Google Blog shows some of the 300 designs they tried. It also confirms the Dr Seuss connection - maybe there’s a fan in the design team. Personally, I think the old one was fine - its immediately recognisable which is all a favicon should be. For the disgruntled, there’s a campaign to bring back the old Google favicon. Or if you have a better idea, Google are inviting submissions.

Spooky Men of the West launch new album

“Created some time ago in 2005, The Spooky Men of the West is Stephen Taberner’s twisted vision for the western chapter of the The Spooky Men’s Chorale.

This now rogue chapter has expanded its repertoire with their own musical masterpieces, drawing on personal feelings and other things.

The Spooky men of the West seems to have been formed with no end in mind - luckily, cos there’s no sign of stopping them now…”

“We never meant to come here” is the brand new EP from The Spooky Men of the West. A sixteen voice male acapella choir, the Spooky Men of the West explore (or should that be “subjugate”?) a range of musical styles from traditional Georgian table singing to contemporary and original works. Their sound has been said to be “gentle and sad, even sweet, but also sexy, powerful and unmistakably male”. One newspaper report aptly describes them as “a group of wierdos who sing”.

“We Never Meant to Come Here” includes six new songs that depart from Stephen Taberner’s Spooky repertoire. “Navigation” is an original song by the Spooks, with music by Spookmeister Ryan Morrison. “Delilah” (Mason & Reed) and “When You Sleep” (CAKE) are surprisingly recognisable after being given a Spooky makeover. “Varjele” was written by Digby Hill, loosely based on a Finnish folk song, and “Mirangula” is a traditional Georgian lament. The “Norwegian Sailors Chorus” is Wagner as you have never heard him before, and possibly never want to hear him again.

Rather than trying to explain what this is about, check this out:

“When You Sleep” is Simon Nield’s beautiful interpretation of the song by CAKE. To call it a cover is almost unfair because this version actually has a melody, something that is missing from the catchy but rather tuneless original. I guess this song appeals to my sense of strange, which makes it a personal favourite. Another stand-out track for me is Digby Hill’s rousing arrangment of “Varjele”, which perfectly sets the mood for marauding. And who else but the Spooks could turn a Wagnerian drinking chorus into a treatise on the demise of bathtime. I hope they’re not suggesting we drink the bathwater…

I have just two tiny criticisms of this album. Firstly, the opening track “Navigation” is too short. Just as the song gathers momentum its finished - perhaps that’s the point the song is making, but I felt I wanted more of the wonderful “home is where I hang my hat” motif. Secondly, while the CD sounds great it lacks some of the energy of the live performances, but I guess this is always the trade-off with studio recordings.

My advice is to get this CD but go see them live if you can, because part of the Spooky experience is that dissonance between the warm, wonderful evocative sound and their strange understated deadpan humour. If you’re in Western Australia you can catch them at the upcoming Denmark Festival of Voice, and at the odd gig around Perth. For details and CDs, check their web site.

Repurposing a broken office chair

Cheap office chairs really aren’t built to last.

Here’s what usually goes wrong:

  • The arm rests are screwed into the plywood base of the seat. Any sort of load on the arm rests tends to split the whole side off the seat. Not good when you have kids about - they love to swing on these things which really hastens their demise.
  • The gas-lift stops working. These are not really repairable, although they can sometimes be replaced if you can find the right part.
  • The back adjustment works using a clutch-like mechanism. The clutch is made of thin steel plates which are welded to the base of the chair. These plates can snap off, and once they’ve all gone the back of the chair is completely floppy. In our chair, all of the plates have snapped of just before the weld with the base. Unfortunately, the mechanism is not replacable.

Rather than chucking it out, I tried to think of something I could do with the parts, most of which were still OK. The result looks something like this, and we’ll come to what exactly it does later:

The conversion is pretty simple, though obviously it depends a bit on the chair and how its made. The first step is to remove the seat post and mechanism. On my chair, the seat post is a light steel tube which is press-fitted into the plastic caster base. Once you remove a locking bolt the post can be removed with a few belts of a mallet.

The seat and back are just bolted on to the main mechanism. Once these are removed you can check them for usability. To mount onto the caster base you want whichever one has the flattest back. On my chair this was the back rather than the seat, though this may vary between chairs.

To fix the seat/back onto the base, juggle the spacing until its right and then drill some holes through the caster base. I just used some large-gague self-tappers to hold the seat in position. If its curved you might need to add some spacers between the base and the seat (eg. using washers or cutting short lengths of tubing).

I thought this would be fun for the kids to play with, and indeed it was for a short while. Since then, I’ve found several other uses.

  • Moving potplants, or other heavy objects. Once you’ve lifted it on its pretty stable, though you may have to hold your load in place top stop it falling off.
  • Moving furniture. For items that are large but not too heavy (eg. sofas), you can lift one end onto the device, and then carry the other end yourself.
  • A foot-rest. My wife claims that this is the best foot-rest she has ever had, which given her initial skepticism is saying something. An added benefit is that she keeps it under her desk, so I don’t have to find somewhere else to store it.
  • A cat throne. (suggested by Kathryn) Providing your cat somewhere to sit may stop it trying to sit in inconvenient places. If you’re lucky, it may even scratch here rather than destroying the sofa.

Its pretty easy to get raw materials for these things. If you can’t scavenge some broken chairs from a workplace, you can usually find them in kerb-side junk collections.

How to make a WiiFit Exercise Bike

Perhaps you too have an unused exercise bike languishing in a dark corner. Lets face it, its pretty boring exercising on one of these things. How to get motivated? Make it fun using WiiFit!

Here’s what to do:

  1. Stick your bike in front of the TV.
  2. Fire up WiiFit, and select Jogging (under Training -> Aerobic Exercises -> Jogging).
  3. Attach the Wiimote to the lower part of your leg. Its normally meant to go in your hand or pocket so its pretty insensitive to orientation but does need a good amount of movement. If you’re wearing socks, you can just slide the Wiimote in - remember to face the buttons away from your leg so you can press “A” through your sock. It also works to put it the cuff of track pants, though it tends to flop about too much for my liking.
  4. Press “A” and start riding. It can take a couple of seconds for the Wii to learn the motion pattern.

Wiifit gives you some nice visual feedback that helps you keep a constant cadence. As you ride, your avatar runs along a path, following your training guide. The landscape is quite pleasant, and you can see other runners and dogs exercising too. If you slow down, your avatar starts to lag behind your guide and it will prompt you to keep a steady pace. You can select your desired activity level as you start the game. If your bike has a variable load, you can adjust this if you find the jogging pace too easy.

Have fun!

Migrating to Wordpress MU

Notice some activity in my RSS feed? No, don’t get too excited - I’m not actually blogging. However, I did move my blog from Wordpress to Wordpress MU. Here are some thoughts on why and how to do this.

Wordpress MU is the multi-user version of Wordpress which is used for sites like wordpress.com and edublogs.org. A single Wordpress MU site can host many blogs at once. If you have more than one blog this simplifies the process of maintaining, updating, and backup because you can handle all your blogs in one hit. According to the official docs, a single box running both web server and MySQL will get you about 10-20 thousand blogs. Wordpress.com currently has over 3 million blogs.

Continue reading ‘Migrating to Wordpress MU’ »

Vote The Bastards Out

With the Australian Federal Election looming, Stephen Taberner, has hit the campaign trail with some advice for voters. Considering how hard it can be to sing outdoors, I think these “flash mob” choral performances are pretty good. Check out the original Spooky Men’s Chorale version below, or on their album Tooled Up.

Well, if I wasn’t convinced before I certainly am now…

Update: actually, we did vote the bastards out. The first acts of the new Rudd government were to ratify the Kyoto protocol, apologise to the Stolen Generations, and consult the people on the nation’s future. Seems like a good start to me.

Free Album made with Tenori-On

Norman Fairbanks has released his latest album “7 Days Microsleep”. Eight tracks are available for free download from his web site. Its pure electronica - calming, mellow, yet full of motion and melody. For some reason I’m reminded of gamelan.

What’s unusual about these compositions is that they are produced entirely on Yamaha’s new gesture-based synth, the Tenori-On. Designed by Toshio Iwai, the Tenori-On is a hand-held device boasting a 256 pixel (16×16) LED display. By touching the display in different ways, the performer can build sequences of sounds that can be layered into complex soundscapes. The novelty of the interface is that it allows relatively complex sequences to be controlled through intuitive gestures. Unlike a traditional multitrack sequencer, the Tenori-On is a live performance instrument. This stuff is all real-time.

This video shows some of the different gestures that can be used to generate tone sequences : Score Mode, Push Mode, Changing Loop Points, Bounce Mode, and Solo Mode. Yamaha have some neat videos explaining these and other interactions here. Some technical details are available in this NIME06 paper.

I was quite intrigued by this gadget when it was released earlier this year, but I admit to being underwhelmed by some of the demo music I heard. Having listened to Norman’s album a couple of times now its definitely growing on me. The standout tracks for me are “The Glam Machines Arrive” and “The Freedom Loop”, but all the tracks have something to offer, sharing a unique tranquil hypnotic style. If you like this sort of thing, or are simply intrigued by the possibilities of this instrument, give “7 Days Microsleep” a try. A brief interview with Norman Fairbanks is available at Create Digital Music.

Viddler drops streaming playback

I’ve been using Viddler a fair bit to host videos of talks from local events such as Perth Barcamp and Podcamp. You can check out these and other offerings at my Viddler page.

For long videos Viddler offered several advantages over sites like Youtube.

  • Viddler supports videos longer that 10 minutes, and up to 500mb in size.
  • Viddler has timed comments, which allow you to annotate important moments in the video
  • Viddler had streaming playback, which allowed you to jump to arbitrary times by clicking in the seek bar. Also, you could click on a comment and jump to that point in the playback. This is very useful for picking out highlights.

Since I originally compared Viddler and Youtube in September 2007, several things have happened. Firstly, Youtube added support for seekable playback. Download is still “progressive” but can be restarted at any point by clicking in the seek bar. Recently Viddler turned off streaming support in their player, saying that it was “expensive and unreliable”. They plan to move to a progressive seek player similar to those now offered by Youtube and Google.

So while Viddler still supports timed comments, its no longer possible to jump to the comment time. This was a very useful feature and IMO a key differentiator between their offerings and the many other video sharing sites out there. Lets hope they get this fixed soon.

Update: Viddler have added progressive seek to their player, so you can now jump to any time in a video. It does seem to be more stable than the old streaming player.

Crowded House rocks Perth

Crowded House are back. They farewelled the world in 1996, and now they have reformed with a new line up : Neil Finn, Nick Seymour, Mark Hart and Matt Sherrod.

Last night Crowded House performed to a packed Supreme Court Gardens in Perth. The concert was a mixture of classic pieces, along with some of the songs from their new album “Time On Earth”. The band gave a solid performance and encouraged the audience to sing along with favourites like “Fall At Your Feet”, “Don’t Dream It’s Over”, “Weather With You”, “Four Seasons In One Day”, and “Better Be Home Soon”. Of course, these were the songs that got the biggest reaction, but folks were also singing along with the new songs too.

Many of the songs from “Time On Earth” deal with loss, and are no doubt at least partly inspired by the sad passing of drummer Paul Hester who took his own life in 2005 after a battle with depression. Songs like “Nobody Wants To”, “You’re The One to Make Me Cry”, “People Are Like Suns”, and “Silent House” reflect on the transience of life. While not popular themes in pop music these are things which eventually we will all experience. It’s great to see someone prepared to tackle them head on. On the night Neil said in his introduction to “Nobody Wants To”:

“We want to sing about everything. There are no no-go zones with Crowded House. We’ll sing about anything or anyone or anytime, anyhow”

That’s one of the things I love about Neil Finn as a songwriter. He’s not afraid to write about whatever is on his mind, no matter what that is. People respect that, because it comes across as honesty and openness. There’s a little touch of insanity there too (”Hey don’t look now but there goes God with his sexy pants and his sausage dog”…WTF?) but that adds to the general level of mayhem - there’s nothing worse than predictability. There are definitely niches in rock that have become very manufactured and formulaic. Crowded House provides a refreshing alternative to this trend.

The evening was peppered with moments of musical mischief. Mark gave a brief rendition of “Oh Susannah” on the harmonica before cranking up “There Goes God”. Also fun was a lead break on the melodica in “Don’t Dream It’s Over”. Neil introduced “When You Come” with the line “This song is not about sex, or maybe…” which of course just confirmed what I had always suspected. At one point, Nick Seymour chased onto the stage a small pack of greyhounds in red racing jackets. This was a great absurdist moment, but also a set-up for the line “Nick Seymour, Best in Breed”. A highlight for me was the juxtaposition of two of my favourite songs: “Distant Sun” and “People Are Like Suns”. During the final number “Pineapple Head” a “half naked man” climbed onto the stage only to be escorted away by security guards. Ever the showman, Neil worked it into the chorus so seamlessly that I was left wondering if the whole thing had been staged.

(Download 1Mb) Half Naked Man On The Stage
(Download 2Mb) Half Naked Man On The Stage (extended with entire chorus)
Recorded in glorious 8Khz mono on my cell phone.

Here is the set list from the night. I for one enjoyed not just the songs but the energy and humour.

Great work guys! I hope to see you back some time soon.

  1. Private Universe
  2. Mean To Me
  3. Don’t Stop Now
  4. Fall At Your Feet
  5. Everything is Good For You
  6. You’re the One to Make me Cry
  7. Nobody Wants To
  8. When you Come
  9. Silent House
  10. There Goes God
  11. Don’t Dream It’s Over
  12. People are like Suns
  13. Walked Her Way Down
  14. Distant Sun
  15. Weather WIth You

1st encore

  1. Locked Out
  2. Something So Strong

2nd encore

  1. Fingers of Love
  2. Four Seasons in one day
  3. Better be home soon

3rd encore

  1. World Where You Live
  2. Pineapple Head