How to set stacks from the command line?

148 views
Skip to first unread message

Brandon

unread,
Nov 29, 2014, 1:32:56 AM11/29/14
to hugi...@googlegroups.com
What is the correct way to set stacks from the command line? I have a script that reads a pto file looks at the overlap and if any images overlaps too much it tries to stack them.(it makes it easier for me to set masks, if they are stacked, but there can be some movement between them so I wish to have hugin arrange each one.)

I have been trying to use
pto_lensstack --change-stack i1=0 input.pto

It does work in that it changes the stack of an image, but I have yet to figure out how to tell it which stack it is going to. The first time I call it I can generally get right. After the first call I often get the target stack wrong as the target seems to change as I set stacks.

Question 2 is there a way to set the stacks, without linking the position variables? I could do the above way then unlink them, but that seems a waste as I would then need to re optimize image positions.


Question 3, what is j mean on the i lines of a pto file?
i w3456 h5184 f10 v=0 Ra=0 Rb=0 Rc=0 Rd=0 Re=0 Eev13.580494060253 Er1 Eb1 r0.795541422974953 p9.80002443579522 y176.612097040948 TrX0 TrY0 TrZ0 j=0 a=0 b=0 c=0 d=0 e=0 g=0 t=0 Va=0 Vb=0 Vc=0 Vd=0 Vx=0 Vy=0  Vm5 n"long_beach0033.TIF"


I know what all of the other things do, but have not been able to find any documentation on j. The j=0 in that last one seems to be the thing that makes this image stack with the first without messing up the positions. If true how does a person set it and if I can is there a reliable way to figure out where to set the stack to.(It would be real nice if I could tell it stack image a to have the same stack number as image b, without me having to know what stack b already is in, as that appears to be a moving target)

All thought and comments welcome,

Thanks,
Brandon

Terry Duell

unread,
Nov 29, 2014, 3:06:27 AM11/29/14
to hugi...@googlegroups.com
Hello Brandon,

On Sat, 29 Nov 2014 17:32:56 +1100, Brandon <bra...@flyingtsalers.com>
wrote:

[snip]

>
>
> I know what all of the other things do, but have not been able to find
> any documentation on j. The j=0 in that last one seems to be the thing
> that
> makes this image stack with the first without messing up the positions.
> If true how does a person set it and if I can is there a reliable way to
> figure out where to set the stack to.(It would be real nice if I could
> tell it stack image a to have the same stack number as image b, without
> me
> having to know what stack b already is in, as that appears to be a moving
> target)
>

If I understand it correctly, and I probably don't, the man page for
"pto_lensstack" suggests to me that you could use "--new-stack a,b" to
ensure both image a and image b are in the same stack...but I guess you
would have tried that?
I can't offer any help on your other questions, sorry.


Cheers,
--
Regards,
Terry Duell

Terry Duell

unread,
Nov 29, 2014, 7:02:13 PM11/29/14
to hugi...@googlegroups.com
Hello Brandon,

On Sat, 29 Nov 2014 17:32:56 +1100, Brandon <bra...@flyingtsalers.com>
wrote:

[snip]

>
> Question 3, what is j mean on the i lines of a pto file?
> i w3456 h5184 f10 v=0 Ra=0 Rb=0 Rc=0 Rd=0 Re=0 Eev13.580494060253 Er1
> Eb1 r0 .795541422974953 p9.80002443579522 y176.612097040948 TrX0 TrY0
> TrZ0 j=0 a=0 b=0 c=0 d=0 e=0 g=0 t=0 Va=0 Vb=0 Vc=0 Vd=0 Vx=0 Vy=0 Vm5 n
> "long_beach0033.TIF"
>

That is a good question, and as you say it doesn't appear to be documented.
I have done a bit of experimenting, and have a clue, but can't be really
sure.
I loaded 9 images into hugin which comprise 3 exposure stacks (0,1,2;
3,4,5; 6,7,8), and saved the .pto file (teststacks.pto).
I then restarted hugin and loaded the same files but without setting the
stacks, and saved the .pto as testnostacks.pto.
I have attached these .pto files.
If you look at the i lines in teststacks.pto, image 0 has j0, but the rest
of that stack has j=0. Image 3 has j0 and the rest of the stack has j=3.
Image 6 has j0 and the rest of the stack has j=6...so my guess is that the
j0 and j=? has something to do which images are to have control points or
which image is the 'base' image for the stack.
A look at testnostacks.pto shows each image has j0 which fits with the
above...but there may be more to this.
I have been snooping in the code to see if I can find where a .pto file is
parsed, to see if there any clues there, but I don't really know my way
around well enough to have found anything useful yet.
Not sure if that helps.
testnostacks.pto
teststacks.pto

Brandon

unread,
Nov 29, 2014, 11:08:32 PM11/29/14
to hugi...@googlegroups.com
Keep in mind that I have not found it in the documentation and am just guessing by trial and error as I write this. If anyone has better thoughts, please speak up.

I load 3 images into a file my third image:
On Load
i w5184 h3456 f0 v=0 Ra=0 Rb=0 Rc=0 Rd=0 Re=0 Eev1.52160036448132 Er1 Eb1 r270 p0 y0 TrX0 TrY0 TrZ0 j0 a=0 b=0 c=0 d=0 e=0 g=0 t=0 Va=0 Vb=0 Vc=0 Vd=0 Vx=0 Vy=0  Vm5 n"W:\zoober\source\weekend B\bridge\IMG_5303.JPG"
I set control points and optimize for starting at anchor.
i w5184 h3456 f0 v=0 Ra=0 Rb=0 Rc=0 Rd=0 Re=0 Eev1.52160036448132 Er1 Eb1 r-79.5612487857035 p7.99448156318547 y109.37396929857 TrX0 TrY0 TrZ0 j0 a=0 b=0 c=0 d=0 e=0 g=0 t=0 Va=0 Vb=0 Vc=0 Vd=0 Vx=0 Vy=0  Vm5 n"W:\zoober\source\weekend B\bridge\IMG_5303.JPG"
I optimize all.
i w5184 h3456 f0 v=0 Ra=0 Rb=0 Rc=0 Rd=0 Re=0 Eev1.52160036448132 Er1 Eb1 r-91.0853510851596 p0.839286712216139 y115.117872304818 TrX0 TrY0 TrZ0 j0 a=0 b=0 c=0 d=0 e=0 g=0 t=0 Va=0 Vb=0 Vc=0 Vd=0 Vx=0 Vy=0  Vm5 n"W:\zoober\source\weekend B\bridge\IMG_5303.JPG"

Now looking at the first image.
Loaded
i w5184 h3456 f0 v105 Ra0 Rb0 Rc0 Rd0 Re0 Eev1.52160036448132 Er1 Eb1 r270 p0 y0 TrX0 TrY0 TrZ0 j0 a0 b0 c0 d0 e0 g0 t0 Va1 Vb0 Vc0 Vd0 Vx0 Vy0  Vm5 n"W:\zoober\source\weekend B\bridge\IMG_5301.JPG"
optimized position, no change
i w5184 h3456 f0 v105 Ra0 Rb0 Rc0 Rd0 Re0 Eev1.52160036448132 Er1 Eb1 r270 p0 y0 TrX0 TrY0 TrZ0 j0 a0 b0 c0 d0 e0 g0 t0 Va1 Vb0 Vc0 Vd0 Vx0 Vy0  Vm5 n"W:\zoober\source\weekend B\bridge\IMG_5301.JPG"
optimized all
i w5184 h3456 f0 v112.42242938554 Ra0 Rb0 Rc0 Rd0 Re0 Eev1.52160036448132 Er1 Eb1 r270 p0 y0 TrX0 TrY0 TrZ0 j0 a0.0234907215216856 b-0.0197428064061075 c-0.375993809538199 d-607.606164547881 e8.53622220734315 g0 t0 Va1 Vb0 Vc0 Vd0 Vx0 Vy0  Vm5 n"W:\zoober\source\weekend B\bridge\IMG_5301.JPG"

Looking around hugin I know what most of those do. I have not seen j or Vm5 before in hugin. I am guessing that Vm5 has something to do with Vignetting, but I could be wrong. Just looking around I have no idea what j does, from looking at my pto files in the past I have a good idea that it has something to do with stacks, beyond that I do not know.
--------------------
Just for the heck of it I changed both anchors to the third image(2 as it is zero based)

Near as I can tell it added "k2" (That is the exposure anchor,I tested it) to the output line and changed which variables should be optimized in the v lines.

--------------------
Back on the main topic I started changing the j value on the third image in a text editor.

j1 does nothing
 
 jany# does nothing

j=1 stacks my third image to my second image.

Any thoughts on why some vars use an = and some do not?

p0 y0 TrX0 TrY0 TrZ0 j0 all equal null?

To my eye it appears that anyvar0 is the same as null. To test it I have tried deleting most of them from an image and hugin opens it just fine. If I save it and open with text editor again they are back.


I copy and pasted my 2nd and 3rd i lines enough times to make 10 images. I then played with those more extensively. I thought that I was having some problems in the past figuring out the target. Just editing the text file I get it right every time. Just set the image number that I want to link to and it works. No mater how the other images are linked.  If I remember right and was correct in what I was seeing that is not how "pto_lensstack" works. I was having a very hard time figuring out the correct targets for it.

Editing the pto file in a text editor, I can even link to an image that is linked to another image. When I open hugin, hugin is able to figure it out that all three are linked together. Then if I save it and open as text, it will have saved everything with the correct links instead of the chain of links that I set.

j does appear to be what I want. If I link j the masks work on each image, but each is left in their own position and can be optimized. If I put in the wrong number for j anything bigger than the current image and try to open with hugin, hugin crashes.


On Saturday, November 29, 2014 4:02:13 PM UTC-8, Tduell wrote:
Hello Brandon,

[snip]
Cheers,
--
Regards,
Terry Duell

A big thanks Terry. Mostly motivation to get me to do the work. I had not changed the pto  file in a text editor before that is actually a lot of fun. I think we have solved Question 2 and Question 3. Anyone have thoughts on Question 1? How does a person normally go about changing the j var from the command line?

 
optimizedallplay.pto
loaded.pto
optimized.pto
optimizedall.pto
optimizedallanchor3.pto

Terry Duell

unread,
Nov 29, 2014, 11:22:21 PM11/29/14
to hugi...@googlegroups.com
On Sun, 30 Nov 2014 15:08:32 +1100, Brandon <bra...@flyingtsalers.com>
wrote:

[snip]

>
> A big thanks Terry. Mostly motivation to get me to do the work. I had not
> changed the pto file in a text editor before that is actually a lot of
> fun. I think we have solved Question 2 and Question 3. Anyone have
> thoughts on Question 1? How does a person normally go about changing the
> j var from the command line?
>

Perhaps I've missed something in the subsequent discussion, but isn't that
"pto_lenstack --new-stack i1, i2, ix?".

Brandon

unread,
Nov 29, 2014, 11:39:47 PM11/29/14
to hugi...@googlegroups.com


On Saturday, November 29, 2014 8:22:21 PM UTC-8, Tduell wrote:

Perhaps I've missed something in the subsequent discussion, but isn't that  
"pto_lenstack --new-stack i1, i2, ix?".


I would think so, but no. With out running pto_lenstack again(it has been a week or two since I last tried it) I remember it linking the yaw, pitch, and role as well as the j var, which is what got me pointed in that direction.

If we can figure that out I still have one heck of a time figuring out where to set the target. Reading the documentation again I think I figured out my problem there. pto_lenstack does not use which image to link to, but which stack to link with. With a file that has 60 pictures and the stacks can be different numbers, it is hard to keep track of which image is in which stack. I am sure there is a work around, I am just wondering if there is a clean one?

Now that j appears to do what I hopped it would do, I am starting to think it would be easiest to have my script open the pto file and change it directly without bothering with the command line.

T. Modes

unread,
Nov 30, 2014, 7:01:55 AM11/30/14
to hugi...@googlegroups.com


Am Sonntag, 30. November 2014 05:39:47 UTC+1 schrieb Brandon:
Now that j appears to do what I hopped it would do, I am starting to think it would be easiest to have my script open the pto file and change it directly without bothering with the command line.

Or much easier to do this on the images tab. The context menu have options to modify stacks.
And when display "group by stack" you can simply drag and drop the images to the corresponding stacks.
But that's to obviously?

Brandon

unread,
Nov 30, 2014, 12:00:00 PM11/30/14
to hugi...@googlegroups.com

On Sunday, November 30, 2014 4:01:55 AM UTC-8, T. Modes wrote:
Or much easier to do this on the images tab. The context menu have options to modify stacks.
And when display "group by stack" you can simply drag and drop the images to the corresponding stacks.
But that's to obviously?

Hmm I did not know about the drag and drop before. That is actually kind of fun.

 It still has the problem of linking all of the images positions, I then need to set custom parameters for optimizing and then go to the optimizer tab and unlink them all. Then go back to the images tab and re-optimize. If I forget to unlink one or more and stitch it, I generally will end up with a part that looks like the camera was shook during a long exposure(There is often a small amount of wiggle between my stacked shots) 

T. Modes

unread,
Nov 30, 2014, 12:14:24 PM11/30/14
to hugi...@googlegroups.com


Am Sonntag, 30. November 2014 18:00:00 UTC+1 schrieb Brandon:
 It still has the problem of linking all of the images positions, I then need to set custom parameters for optimizing and then go to the optimizer tab and unlink them all. Then go back to the images tab and re-optimize.
Why? You can also unlink the position on the image tab (group by stack, display image position, context menu on the yaw/pitch/roll value)

Terry Duell

unread,
Nov 30, 2014, 5:56:04 PM11/30/14
to hugi...@googlegroups.com
Hello Brandon,

On Mon, 01 Dec 2014 04:00:00 +1100, Brandon <bra...@flyingtsalers.com>
wrote:


>
> Hmm I did not know about the drag and drop before. That is actually kind
> of fun.
>
> It still has the problem of linking all of the images positions, I then
> need to set custom parameters for optimizing and then go to the optimizer
> tab and unlink them all. Then go back to the images tab and re-optimize.
> If I forget to unlink one or more and stitch it, I generally will end up
> with a part that looks like the camera was shook during a long
> exposure(There is often a small amount of wiggle between my stacked
> shots)
>

I see that Thomas has described how to do all this in the photos tab.
For some reason I had concluded that you wanted to do all this via command
line, maybe to be able to script it.
I was on the wrong track, sorry.

Brandon

unread,
Nov 30, 2014, 10:05:36 PM11/30/14
to hugi...@googlegroups.com


On Sunday, November 30, 2014 2:56:04 PM UTC-8, Tduell wrote:
Hello Brandon,
 
I see that Thomas has described how to do all this in the photos tab.
For some reason I had concluded that you wanted to do all this via command  
line, maybe to be able to script it.
I was on the wrong track, sorry.

You were correct I have an autoit script that I am working with that I was hoping to do it all from the command line with. I am hoping to drag and drop a pto file onto my script and it stacks things up that over lap too much.

Thanks to your help, I should be able to do it in the next day or two. I know what needs to be done and will I just code my script to open up the pto file as text and make the changes as needed.

Thomas thanks for your tips as well. I had no idea that hugin did so many different things depending on how the images were grouped. That is good to know for when I need to fine tune what my script gives me back. I can get hugin to crash if I try some really advanced stuff with some of those groupings and it appears to be limited in some ways that the command line is not. For example group 9 images to use the same mask, and subgroup it into three groups of three images that have linked y,p,r. Is that something that can be done in the GUI? From the command line it is easy enough, now that I know which var is the mask stack.

Terry Duell

unread,
Dec 1, 2014, 12:22:07 AM12/1/14
to hugi...@googlegroups.com
Hello Brandon,

On Mon, 01 Dec 2014 14:05:35 +1100, Brandon <bra...@flyingtsalers.com>
wrote:

[snip]

> Thomas thanks for your tips as well. I had no idea that hugin did so many
> different things depending on how the images were grouped.

The tutorial on the new user interface
<http://hugin.sourceforge.net/tutorials/new-gui/en.shtml> does discuss
some of these abilities but doesn't cover them all. The expectation was
that having seen some of the options the reader would check what else was
on offer.

> That is good to know for when I need to fine tune what my script gives
> me back. I can get
> hugin to crash if I try some really advanced stuff with some of those
> groupings and it appears to be limited in some ways that the command line
> is not. For example group 9 images to use the same mask, and subgroup it
> into three groups of three images that have linked y,p,r. Is that
> something that can be done in the GUI? From the command line it is easy
> enough, now
> that I know which var is the mask stack.
>

I think it depends on the mask type.
For an exclude mask you can set 'exclude region from all images of this
lens', and 'exclude region from stack'.
For an include mask you have the option to 'include region from stack'.

bugbear

unread,
Dec 1, 2014, 5:31:07 AM12/1/14
to hugi...@googlegroups.com
T. Modes wrote:

> And when display "group by stack" you can simply drag and drop the images to the corresponding stacks.
> But that's to obviously?

Actually, a pet hate of mine in the modern era of GUI design
is drag and drop.

I also love it.

The problem is that there's no standard way of the GUI
telling you what D'n'D's are allowed.

If I wanted to just try stuff until it worked
I'd play an Adventure game :-)

BugBear

bugbear

unread,
Dec 1, 2014, 5:34:10 AM12/1/14
to hugi...@googlegroups.com
Brandon wrote:
>
> On Sunday, November 30, 2014 4:01:55 AM UTC-8, T. Modes wrote:
>
> Or much easier to do this on the images tab. The context menu have options to modify stacks.
> And when display "group by stack" you can simply drag and drop the images to the corresponding stacks.
> But that's to obviously?
>
>
> Hmm I did not know about the drag and drop before. That is actually kind of fun.

You might find this old thread helpful: "Hugin -> Faux Exposure Brackets -> enfuse"

BugBear

John Muccigrosso

unread,
Dec 2, 2014, 12:50:46 PM12/2/14
to hugi...@googlegroups.com
Then once you figure it out, you can improve the documentation, so the rest of us can benefit!

Note that in addition to the demos on the Hugin site, there are actual docs starting at:

Reply all
Reply to author
Forward
0 new messages