3

I am trying to create a batch process for stitching images together with Hugin, however I end up with distorted images, and can't find out why.

As an example I am using these two images:

enter image description here

enter image description here

And using the process described here with this sequence of commands:

pto_gen -o project.pto image_01.jpg image_02.jpg
cpfind --multirow -o project.pto project.pto

celeste_standalone -i project.pto -o project.pto

cpclean -o project.pto project.pto

linefind -o project.pto project.pto

autooptimiser -v 20 -a -l -s -m -o project.pto project.pto

pano_modify --center --straighten --canvas=AUTO --crop=AUTO -o project.pto project.pto

echo "stitching part 1..."

nona -m TIFF_m -o project project.pto

echo "stitching part 2..."

enblend -o project.tif project0000.tif project0001.tif

rm project0*.tif

However I always end up with an image that's distorted like this:

enter image description here

Why is that? at what stage does the distortion happen, and how can I fix that?

6
  • 1
    Does it help if you add a projection (-p=0 or -p=2) to the pano_modify command?
    – agtoever
    Sep 25 at 19:47
  • I don't use batch scripts so I'm not prepared to stick my neck out here, but why are you using a multi row cp find? Surely this is just a vertical panorama?
    – dmkonlinux
    Sep 26 at 6:16
  • @dmkonlinux - because I don’t know better, and that’s what was in the tutorial. What would you suggest?
    – simone
    Sep 26 at 14:41
  • @agtoever - no it does not
    – simone
    Sep 26 at 14:41
  • Honestly, I'm not sure. In the GUI I would use an ordinary cpfind without celeste - that is only a second run which removes points from the sky that are potentially moving. I would then optimise by ypr, I think, to get a basic stitch. Then I'd optimise for canvas size etc but not straighten, that's for a wonky horizon. I wouldn't use line control points unless the optimiser was strugling to match the pano. I would then check for any wildly out control points, re-optimise at say "everything without translation" and re optimise for canvas etc. 9/10 times that gets me where I want to be.
    – dmkonlinux
    Sep 26 at 15:55
2

I think there are two or three possible issues: one with the commands and two with your photos.

  1. Make sure you (globally) understand the commands you are running. As you have seen for yourself, the resulting picture is a bit disappointing. Check the Hugin components manual for the different commands, their options and their meaning. For example, you use the -s option with the autooptimiser. This automatically tries to pick a suitable projection. I think this is one of the causes for the distorted result. As suggested in the comments, start with a more basic set of commands, and take it from there. For example, this should be a good start:

     # Generate a project file
     pto_gen -o project.pto ./top.jpg ./bottom.jpg
    
     # Auto optimise (note that I don't include the -s option here
     autooptimiser -a -l -m -o ./project.pto ./project.pto
    
     # Set canvas and crop
     pano_modify --canvas=AUTO --crop=AUTO -o ./project.pto ./project.pto
    
     # Process each of the images
     nona -m TIFF_m -o ./project.pto ./project.pto
    
     # Blend the resulting images
     enblend -o project.tif ./project.*.tif
    
  2. I suspect you took the pictures while holding the camera in your hand. As you can see below, I managed to blend the images, but the don't stitch very nicely. This is because there must be a minor shift in the point from where the camera took the first and the second picture. Hugin (or any panorama software) can't correct that. Next time, use a tripod to fixate the point from where the panorama pictures are taken from.

Blended image

  1. It really helps if you put exif info in the file for Hugin. This "metadata" is automatically stored in the image file format by your camera. This includes focal length, which is an important part of the info that Hugin needs to process your photos correctly. Always make sure you use "straight from the camera" images for stitching.

Finally: if you have the opportunity, try the Hugin application (Windows/OSX/X). This guides you through the process and gives you a much more friendly user interface.

0

I walked through your commands and it looks like --straighten is the primary culprit here.

Taking out --straighten produces: rec

I believe this is a default rectilinear.

Using the interim GUI editor to switch to cylindrical produces: cyl

I'm sure there's much more that can be done, but I haven't played with it before now.

0

While scripting may be a fun foray, I would use the GUI since there are a lot of tweaks to get a good looking pano.

Here's the script I used on your project:

pto_gen -o zit.pto 1.jpg 2.jpg
cpfind --multirow -o zit.pto zit.pto
cpclean -o zit.pto zit.pto
autooptimiser -a -l -s -m -o zit.pto zit.pto
pano_modify -o zit.pto --projection=6 --center --straighten --canvas=AUTO --crop=AUTO zit.pto
nona -m TIFF_m -o zit --gpu zit.pto
enblend -o zit.tif zit0000.tif zit0001.tif
  • I added --projection=6 in pano_modify. This corrects the weird projection you got. You may want to try different projections.

  • I added --gpu to nona to speed things up.

  • Since you don't have sky in your project, celeste isn't needed.

  • The image is bowlegged, so you'll need to figure out how to correct that.

  • If you run this through Hugin's GUI interface, things look better.

  • Looking at your images in Hugin's preview, it's readily apparent that you did not take care in panning about the lens entrance pupil (where the apparent lens aperture is located). The pillar on the right did not stitch properly due to parallax issues. When hand-holding your camera, use your finger as the point to pan your camera, usually close to the front element on your lens. You'll need to run some experiments to find where your lens nodal point is. Aperture setting could change your nodal point. Enblend does a pretty good job at hiding parallax issues which is why your image still looks decent. More information about pivot point.

  • In Hugin GUI, you can place vertical control points and remove the vanishing lines to have a nice architectural projection.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.