Fun with Autostitch : Panoramic video

In a previous experiment, we found that images can be embedded into a background panorama. Now its time to see if we can use this to make a stitched panoramic movie.

Step 1. Record a background panorama

I made a movie of my lounge room using a Panasonic NS-DV50A digital video (DV) camera. I captured this to DV-AVI format, then used VirtualDub to de-interlace and convert frames to JPEG images.

I took a couple of overlapping pans around the room. Nothing fancy here. Just think “painting with camera”. Next I selected every 10th frame and made the background panorama using Autostitch:

Panorama generated from video using Autostitch

Step 2. Record some action

Next, I took some video of the kids playing in the room. Again, I de-interlaced and converted the frames to JPEG images. You can see this video in the output below.

Step 3. Stitch frames against panorama

Here’s the tricky part. We want to take each frame of the video, and stitch it together with all of the frames for the background panorama. This will generate one panorama per input frame, which we will then combine to produce the output.

The catch is that Autostitch is a GUI application. Doing this by hand using the GUI is way too time consuming, so I wrote some black-magic code to control Autostitch via a batch process.

This produces images with a fixed width but variable height. I resized these to a consistent size.

Step 4. Convert panoramas to movie

Next, I loaded the panorama image sequence into VirtualDub and converted it to a movie file. Additionally, I combined the panoramic image with the original movie, and exported these frames as a movie.

Results

Here’s the stitched panoramic movie along side the input movie:

I tried to stretch the capabilities of the matching by doing some zooms and rotations with the camera. Towards the end of the movie is a section where the matching breaks down because there is probably too much transformation of the image. Although the SIFT should be able to handle this, there may be orientation-dependent differences in the characteristics of the features that cause it problems. This is due to the de-interlacing of the original image, which means that scan lines are duplicated so the detail in the horizontal and vertical directions are not the same.

Overall, I’m pretty happy with the result. Its not perfect, and could probably be improved with some specific support for this sort of thing. We are asking Autostitch to do a few things it was not designed to do. Basically, we don’t want to re-stitch the entire panorama for each new foreground frame. We want the background to be stable, but can be more lenient when stitching the foreground frame. Also, with specific knowledge about which frame should go on top, it should be possible to smoothly blend the frames without losing the foreground.

Being able to embed video into a panorama suggests interesting possibilities for immersive media browsing environments based on 3D panoramas. See: “Browsing personal media archives with spatial context using panoramas”.

6 Comments

  1. Kathryn Greenhill:

    What cute children, but why do you let them run all over the furniture like that?

  2. Stewart:

    Kathryn, I asked the dinosaur but she wouldn’t do it.

  3. Ben:

    wow. nice. i have been trying to get autostitch in batch. i want to do a film shot with four cameras…. can you give anymore info on how you do this? thanks!

  4. Stewart:

    Hi Ben,

    The process is a little tricky, but I automated it as best I could given the constraints. I wrote some code to send a bunch of events to the controls in the AutoStitch GUI. Basically it does the same sequence you do when you operate it manually: File->Open in the Autostitch window, then insert a bunch of file names into the “Edit” control, then click “Open”, then (optionally) wait for Autostitch to open the image and close the resulting window, then rename “pano.jpg” to something useful. So you can do a single stitch from the command line like this:

    $ stitch.exe file1.jpg file2.jpg ... fileN.jpg

    Or you can use a batch option which looks like this:

    $ stitch.exe "frame%03d.jpg" 0 100 file1.jpg ... fileN.jpg

    Which means: for frames M from 0 to 100, stitch “frameMMM.jpg” against file1.jpg … fileN.jpg, copying output to “outMMM.jpg”. This is basically the process I used to make the panoramic movie.

    If you have four cameras shooting the action, then you probably just want to stitch four images per frame which would be a simple mod. Or you can use another program to generate a sequence of single stitch commands. I ran the stitcher from a Java application, but you could use any app capable of launching a WIN32 command.

    The main limitation is that all of the images have to be in one directory, and Autostitch has to be first “pointed” to that directory (via a File->Open dialog).

    If you’re interested I can dig out the binaries and source code for you. I was intending to post them anyway, but never got around to cleaning them up.

  5. Ben:

    thanks, i am going to try to do this, it would be helpful to see your code when you get a chance to post.

  6. Stewart:

    Hi Ben,

    My code is now on-line. Check here for source and binaries.

Leave a comment