Hugin is a great tool for stitching photos together that share common features to create a higher resolution image. In the previous post, we covered stitching two photos together. In this post we’ll cover using video as a source for our stitching base, as well as the requirements.
The Hugin program uses EXIF data in its stitching process. Lets start by creating a 360 panorama using a series of photos taken with an iPhone. The images inherently contain EXIF data that Hugin uses. In this example I’ll load 30 images taken from a single point. I shot the images in two groups with a change in vertical angle. All of the images have a change in horizontal angle. Together, Hugin is able to stitch them into a 12,394 x 3223 pixel high resolution panorama. This would be an impossible shot with the built in pano function of the iPhone.
Here are the steps I took to create the panorama.
1. Load images from camera, they have EXIF data
2. Once they load, the preview may look mixed up. This is normal.
3. Choose Align to start the auto control point detection.
4. It’s a lengthy process. Open the Advanced mode to view all control screens.
5. In the Panorama preview, change the center, fit, and auto options so the image zooms to the correct size.
6. Set Blend Mode to Difference, to avoid moving objects from overlapping and ghosting.
7. Projection should be Cylindrical.
8. Start the stitch, save the project and set the final output file name and format.
9. Takes a while to finish.
10. If the image is flipped, this can be corrected later.
As I mentioned earlier, Hugin uses the EXIF data from the iPhone. This is what was registered with one of the images.
Lens: 4.15mm f/2.2
Focal length: 4.2mm (29 mm)
Shutter Speed and ISO varied
Also, Hugin has some settings that I think are worth mentioning. These are:
Paorama Preview Settings
Projection (f): Cylindrical
Blend mode: Normal
The final image is quite remarkable, but there are some artifacts that could be corrected using non vanilla methods.
Using a Video file as the source presents some challenges since Hugin can not work directly with the file format. To get Hugin to work, we’ll need to convert our video into image frames.
The video that I shot was from a single point and I rotated my field of view along both the horizon and vertical planes. I held the iPhone upright, this resulted in a video with a portrait orientation.
To change from portrait to landscape, I used this command
mencoder SourceMovie.MOV -o LandscapeMovie.MOV -vf rotate=1 -oac pcm -ovc x264
Hugin still can not work with the source file, so the next step was to convert the video to frame files using this command.
avconv -i LandscapeMovie.MOV -r 30 -f image2 ~/Desktop/images/%05d.png
My 50 second video clip became a folder containing over 1,500 image files. Loading all of these images into Hugin would cause the program to hang, if not crash. We want to select a group to use that uses the least amount of image, yet have many common features. The common features will be used by Hugin to create control points for the stitching process. I found that using every 6th image was sufficient.
As a control test, I only picked 10 images to work with to validate the process. This prevented Hugin from being over burdened by too many images to process. The next challenge was the lack of EXIF data with these images.
Hugin uses EXIF data to determine lens angle, exposure, and field of view. It uses these values in its calculations. Since our images were created from a video source, we do not have EXIF data to reference. As a result, Hugin will prompt for the camera and lens data. Since I had taken photos with the iPhone and they have native EXIF data, I referenced this information for those values.
I set the Lens type to Normal (rectilinear) and the Focal length to 4.2 mm. Hugin set the Horizontal Feild of View to 136.79 degrees. Next, I repeated the steps I had with my image group above.
I set the LDR format to PNG and the Output to Exposure corrected, LDR. It appears to have some issue with recognizing control points. I am able to add these manually, however the projection becomes distorted and the final projection is garbage. My take away is creating tile scenes with fewer groups of images. Then use the tile scenes as an image base for Hugin to create the final panorama.
Still, there is a lot more features to cover with Hugin that go way beyond what I’ve covered here.