Batch script cannot reproduce what I do in GUI

161 views
Skip to first unread message

LF Martins

unread,
May 20, 2020, 3:12:02 AM5/20/20
to hugin and other free panoramic software
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

Carlos Eduardo G. Carvalho (Cartola)

unread,
May 20, 2020, 7:52:05 PM5/20/20
to hugi...@googlegroups.com
Hi LFOM,

I've already done a script once for video frames, but I have some doubts about what you are doing.

I didn't really understand how you get your images, you said the second is a projection of the first and so on, but anyway, I also don't know if this is relevant. Maybe you can make some samples available somewhere.

Maybe a more important question is: Did the camera move between frames? If not then you can do a stitch just for the first 4 images and then use the PTO file as a template for the rest, just doing the final image rendering.

Bests,


--
A list of frequently asked questions is available at: http://wiki.panotools.org/Hugin_FAQ
---
You received this message because you are subscribed to the Google Groups "hugin and other free panoramic software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hugin-ptx+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hugin-ptx/cab3dcd5-6fbb-4322-abfe-24123e782ea8%40googlegroups.com.

LF Martins

unread,
May 21, 2020, 11:33:53 PM5/21/20
to hugi...@googlegroups.com
Hello, Carlos!

Yes, I can provide some samples of it helps... But the main point here is that I need a way to reproduce what I did in GUI and it is not working. I forgot to mention that in the Optimizer step I selected only y, p, r, TrX, TrY and TrZ for each pair.

There are two images that are almost the same: the anchor and another one that is the exact same images but with a crosshair at some point and even in this case if I run the script I shared these imagens won't be aligned anymore. In some cases even the anchor image is modified... How is it possible? 

I think the problem happens when autooptimiser is run for each image, it does not work like it does in GUI but I have no idea how to fix it. I was hoping some developer could help here... 

Regards

You received this message because you are subscribed to a topic in the Google Groups "hugin and other free panoramic software" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hugin-ptx/t7JxXLf2erc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hugin-ptx+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hugin-ptx/CALW1f7gPk-TVqGAehRmDmuDqg3-ozLuZ42E93ApPKAhfkH1h5Q%40mail.gmail.com.
--
Sent from Gmail Mobile

Stanley Green

unread,
May 22, 2020, 10:41:22 AM5/22/20
to hugi...@googlegroups.com
In the past I used Hugin to make simple panos and then I stopped making panos.  I recently decided to teach my granddaughter how to shoot and stitch panos so I loaded Hugin onto my Mac. (Hugin 2019.2.0, iMac 2019, Catalina).  When I first downloaded Hugin, I had a problem with PTBatcherGUI freezing my Mac.  Thanks to advice that I received from the user forum, that is no longer an issue.

I have a set of four images that I took from the South Rim of the Grand Canyon.  This not a particularly exciting scene, but I already have the images. I first tried generating the pano with Hugin. As can be seen below the resulting pano is less than satisfactory.  

Hugin Pano Rectilinear

Then I tried Hugin Cylindrical (Better than Rectilinear, but still not very good)

I then tried generating the pano using Affinity Photo.  The Affinity pano has some minor artifacts at the horizon where the images are merged, but it stitched successfully. And, from my prospectives, looks considerably better than either of the Hugin panos

Affinity Photo Pano

Terry Duell

unread,
May 22, 2020, 8:34:02 PM5/22/20
to hugi...@googlegroups.com
On Sat, 23 May 2020 00:40:51 +1000, 'Stanley Green' via hugin and other
free panoramic software <hugi...@googlegroups.com> wrote:


[snip]

> As can be seen below the resulting pano is less than satisfactory.

Surely it isn't necessary to have images comprising 6.3MB to convey your
story.
It is not good etiquette to add large attachments to mailing list posts.
Not all members will wish to see them, and if the images can't be suitably
downsized they should be available via a link.

Cheers,
--
Regards,
Terry Duell

Stanley Green

unread,
May 22, 2020, 9:50:51 PM5/22/20
to hugi...@googlegroups.com
please accept my apology re: file size. I will be more concerned in the future

Do you have any advice regarding the problem that I am experiencing

Sent from my iPhone

> On May 22, 2020, at 8:34 PM, Terry Duell <tdu...@iinet.net.au> wrote:
> --
> A list of frequently asked questions is available at: http://wiki.panotools.org/Hugin_FAQ
> ---You received this message because you are subscribed to the Google Groups "hugin and other free panoramic software" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to hugin-ptx+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/hugin-ptx/op.0k1h7gulrs0ygh%40localhost.

Luís Henrique Camargo Quiroz

unread,
May 23, 2020, 9:29:38 AM5/23/20
to hugi...@googlegroups.com

  Hi,

  I think that automatic control point detection is to blame here. Have you checked if the control points are right?
  What are the CP errors values?

 




--

Stanley Green

unread,
May 23, 2020, 10:08:17 AM5/23/20
to hugi...@googlegroups.com
Thank you for your response.
This morning, before I received your email, I deleted Hugin, restarted my Mac and then reloaded Hugin.
I may have had a corrupted app, because now Hugin seems to be functioning ok.
“Images are connected by 137 control points.  Mean error after optimization: 1.6 pixel, max:3.9”
Unfortunately, I did not retain a copy of the prior CP data


My only problem now is how best to get the finished pano back into C1. Ideally I’d like it to be in the same catalog that contains the raw images.  But, from what I have read on various forums, that is a lost cause.
Thank you  again,
Stan 

Abrimaal

unread,
May 23, 2020, 1:19:43 PM5/23/20
to hugin and other free panoramic software
About the panorama example:

Yes, the control points at the horizon are most important here. The detector finds control points on the ground, because the details are sharp and high contrast.
Before running the detector, mask out (exclude) the bottom parts (especially the tree). You can leave only the horizon unmasked.
run the detector and optimize.
Now remove masks.

When the horizon is done, you may add manually some points at the bottom and see, compare if it looks better.

I think the 1st example is cylindrical and the 2nd is rectilinear.

Stanley Green

unread,
May 23, 2020, 1:25:37 PM5/23/20
to hugi...@googlegroups.com
Thank you , I’ve got a lot to learn.

Sent from my iPhone

On May 23, 2020, at 1:19 PM, Abrimaal <abri...@wp.pl> wrote:


--
A list of frequently asked questions is available at: http://wiki.panotools.org/Hugin_FAQ
---
You received this message because you are subscribed to the Google Groups "hugin and other free panoramic software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hugin-ptx+...@googlegroups.com.

Abrimaal

unread,
May 23, 2020, 1:40:51 PM5/23/20
to hugin and other free panoramic software
PT Batcher is freezing not only your Mac, it makes Windows inoperable too.
With every new task the PT Batcher icon pops the taskbar up, and I cannot access the tools at the bottom of the screen. When working with many programs at once it becomes a horror, to click and hide the terrible icon every time.
You may change in Preferences>Stitching>Processor the PT Batcher to Hugin_stitch_project
but remember to save project after every change.
Stan 

> To unsubscribe from this group and stop receiving emails from it, send an email to hugi...@googlegroups.com.

> To view this discussion on the web visit https://groups.google.com/d/msgid/hugin-ptx/op.0k1h7gulrs0ygh%40localhost.

--
A list of frequently asked questions is available at: http://wiki.panotools.org/Hugin_FAQ
---
You received this message because you are subscribed to the Google Groups "hugin and other free panoramic software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hugi...@googlegroups.com.


--

--
A list of frequently asked questions is available at: http://wiki.panotools.org/Hugin_FAQ
---
You received this message because you are subscribed to the Google Groups "hugin and other free panoramic software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hugi...@googlegroups.com.

Stanley Green

unread,
May 23, 2020, 1:55:26 PM5/23/20
to hugi...@googlegroups.com
Thanks, I thought that Macs were the only victims

Sent from my iPhone

On May 23, 2020, at 1:40 PM, Abrimaal <abri...@wp.pl> wrote:


To unsubscribe from this group and stop receiving emails from it, send an email to hugin-ptx+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hugin-ptx/376873dc-4faf-4157-87f3-c08b4231a723%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages