Hello, there!
I know Hugin since a long time ago and I have used it many times to stitch panoramas. This is a great tool very versatile, a big *thank you* to all developers that made this possible.
But now I am trying to align some photos, and it works nicely when using the GUI (I have latest 2019.02 on Pop!_OS 20.04 that is like Ubuntu 20.04), but I cannot reproduce it in a batch script, even if I use the same steps, or at least I think so... The pictures aren't common fotos, but frames from different videos. One of the videos is the reference, and I use it as anchor, the other 2 are projections of the first movie so it shows the same image but in a different plane/distance/colors, and the third one is a slightly different version of the first that the only difference is that is has a crosshair marking the center of the area I want to analyse, and I want to align all three images with the first one. And it works if I use the GUI:
1. Load four photos, the reference one is the anchor, use default FOV=50, rectilinear lens
2. Use Hugin's CPFind to find the control points
3. Select all 4 images and use Clean Control Points
4. Select Otimize Geometric = Custom Parameters
5. Then I go to Optimizer tab, select just Use Only Control Points between activated images, select just the anchor image and then the other images one by one, and click on Optimize Now! (so I do this 3 times, of course)
6. In Stitcher, select only Remapped Images No Exposure Correction LDR, Projection Rectilinear, and then click on Calculate Field of View
7. Open Preview OpenGL, Center > Fit > Straighten > HDR Autocrop
8 Finally, in Stitcher again, click on Stictch! and the images are saved, just like what I need.
But the problem is that I need to do this with thousands of frames, from many movies, so I created a script to reproduce this, for each group of four frames:
#!/bin/sh
pto_gen *.png -o align.pto
pano_modify -o align.pto --projection=0 --fov=50 align.pto
cpfind --fullscale -o align.pto align.pto
cpclean -o align.pto align.pto
pto_var --opt="y1, p1, r1, TrX1, TrY1, TrZ1" -o align.pto align.pto
autooptimiser -n -o align.pto align.pto
pto_var --opt="y2, p2, r2, TrX2, TrY2, TrZ2" -o align.pto align.pto
autooptimiser -n -o align.pto align.pto
pto_var --opt="y3, p3, r3, TrX3, TrY3, TrZ3" -o align.pto align.pto
autooptimiser -n -o align.pto align.pto
pano_modify -o align.pto --projection=0 --fov=AUTO --center --canvas=AUTO --crop=AUTOHDR --output-type=REMAPORIG align.pto
nona -m PNG_m -o aligned align.pto
Should have worked, right? But it doesn't! I have tried many combinations, because also optimizing with all the four images at once does not work well as they are very different from the view point. I also tried to create one pto for each of the two photos, then use pto_merge, and it didn't work either. And even if I save the pairs aligned, they will have different sizes, so I have to align them again and the same problem happen!
It is really driving me crazy as it should be a simple thing since it works almost perfect using the GUI, but I could not find a way to reproduce it in a batch. What I am doing wrong?
Kind regards,
LFOM