Monday, July 2, 2012

Panorama photo creation in an easy (lazy) way

Q: Have you ever faced the challenge of creating panorama from the set of photos? Did you try to create it manually using your favorite graphics editor? Did you face problem of spending too much time on that?

A: There might be a solution for you. It's called Hugin.

As the homepage ( says: "With Hugin you can assemble a mosaic of photographs into a complete immersive panorama, stitch any series of overlapping pictures and much more."

As I'm used to run my favorite programs on Linux as well as Windows, I like the fact that it's capable of running on both, moreover it's open source (which I'm really excited for).

OK, so how it works for me? Maybe some motivating/demotivating pics in the beginning. 
Shots show the views of Ramadevara Betta (Hill) in India I took

Still interested? Let's go then...

Adventure part
Take photos of your interest in a sequence.
My rules follow:
- take at least 2 rows one above each other (make the left-to-right / right-to-left sequence)
- if required, reorder pics after downloading them from camera
- make sure the pics overlap (to be able to identify conneciton points there), rule might be to overlap like 1/4 or up to 1/3 or so

Boring part
1. make sure you have Hugin installed and start it
2. click "1. Load Images..." button
3.  click "2. Align..." button,
4. then be veeery patient, depending on the pics quality and count it might take quite some time
5. after done, "Fast panorama preview is shown" where you can do some final addaptions on the panorama (I usually don't need to do here anything at all)
6. when done close it and click "3. Create panorama..." button
7. when done, you should have your panorama present in tif file
8. that's it

Problem solving
If you're unlucky you might experience the problem that process fails during point 4. No controll points are found and you get error in the aligning console saying: "An error happened while loading image : caught exception: bad allocation"
It seems I was not the only one facing the issue and finally solution has been found:!msg/hugin-ptx/HPt0lIFFRr0/3fwBzt-EUJMJ

Problem, based on the discussions, seems to be that cpfind process, one that tries to find the controll points crashes due to problems with memory management.
OK, for me however the fix was, to slow the process a bit down (as by default it seems to be running on 8 parallel threads) and use less threads (also less memory) for analysis.
I anyway preffer the idea of someone else doing the boring job (connecting the pics in this case) rather than me, regardless how long it will take him :)

All right, but how to decrease thread count?
1. go to menu "File" -> "Preferences"
2. go to "Control points detector" tab
3. choose "Hugin CPFind (Default)" and click "Edit..." button
4. update "Arguments" from "--multirow -o %o %s" to "--ncores=1 --multirow -o %o %s"
5. click "OK" buttons
6. I also restarted Hugin (not sure if required)

I tried with switch "--ncores=4" first, but that didn't work for me so I changed to "--ncores=1" and it finally solved/workarounded the problem

What's next?
If interested, give it a try and see.
Feel free to link your panororamas/experiences on creating these in comments :)

No comments: