Pto var

From PanoTools.org Wiki
Revision as of 11:19, 22 May 2020 by Thomas (talk | contribs) (General options)
Jump to: navigation, search

Pto_var can manipulate image variables in Hugin .pto project files. The intended use of Pto_var is in Scripting. Pto_var can set image variables to a given value, it can change the link status and it can mark variables for optimisation.

The general use is:

   pto_var [switches] --output=output.pto --opt|--link|--unlink|--set|--set-from-file images input.pto

Optimisation variables

Pto_var can mark image variables for optimisation. (This information is stored in the v lines in the pto file.) This information is used by autooptimiser and vig_optimize to do the actual optimisation.

Running without other switches will only mark the variables given on the command line for optimisation. If you want to modify the marked variables add --modify-opt to the command line.

The usage is:

  pto_var --opt="image variables list" input.pto

The image variable list consist of a comma separated list of image variables:

   [!]name[image number]

The following image variables are allowed:

  • position: y, p, r, TrX, TrY, TrZ, Tpy, Tpp
  • lens parameters: v, a, b, c, d, e, g, t
  • photometric parameters: Eev, Er, Eb, Vb, Vc, Vd, Vx, Vy, Ra, Rb, Rc, Rd, Re (Vignetting and response parameter will treated as group.)

The image numbers start with zero. If no number is given, the variables will be applied to all images. (In this case a special treatment applies to the position of the anchor image.)

An exclamation mark before the variable will remove the variable from the list of variables to optimised.

Examples:

  • --opt=y,p,r will optimize position for all images.
  • --opt=v,!v0 will optimize field of view for all images except the first.
  • --opt=Vb1,Ra1 will optimize vignetting and response curve for the second image.
  • --modify-opt --opt=!v will not optimize field of view.

Link or unlink image variables

To modify the link status of an image variable use --link or -unlink. Supply a list of comma separated image variables with corresponding image number.

Examples:

  • --link=v3 will link field of view of image 3.
  • --link=a1,b1,c1 will link lens distortion for second image.
  • --unlink=v0 will unlink field of view for the first image.
  • --unlink=Vb3,Ra3 will unlink vignetting and response curve for image 3.

Set image variables

With this switch you can set the image variable to the given value. This applies to all the image variables of that sort or only to a single image, when the image number is given.

Examples:

  • --set=y=0,p=0,r=0 will reset all image positions.
  • --set=a1=0,b1=-0.05,c1=0 will set the lens distortion parameters for the second image.

You can also give a mathematical expression. Supported are:

  • the operators +-*/% and ^ (addition, subtraction, multiplication, division, modulo and exponentiation),
  • parentheses,
  • the functions abs, sin, cos, tan, asin, acos, atan, exp, ceil, floor and sqrt (trigonometric functions use the angle in radians),
  • the constant pi and the functions deg and rad to convert to degrees or radians,
  • the constant i holds the image number,
  • the constant val contains the old value,
  • a if statement: x?y:z. For the comparison statement you can use <, >, <=, >=, == (equal) and != (not equal)
  • since 2018.2: access to all image variables with the panotools syntax: e.g. y1 is the yaw value of the second image (These constants contains the values of the panorama when the parser is started. They don't change when you modify them in between.)

The expression should return exactly one value. It may be necessary to quote the string to correctly get the special characters read.

See some examples:

  • --set=y1=val+10 will increase yaw of the second image by 10 degrees.
  • --set=r2=val-90 will decrease the roll angle of third image by 90 degrees.
  • --set=v=1.1*val will increase field of view for all images by 10 %.
  • --set=Er=val/1.1,Eb=val/1.2 will divide the red multiplier by 1.1, and the blue multiplier by 1.2 respective for all images.
  • --set=y=i*90,p=-1^i*20,r=0 a more complicated example for a fisheye panorama, sets yaw, pitch and roll
  • --set="r=i<4?val+45:val" rotate the first 3 images by 45 degree individual (note: quoting for Windows)

You can also read the string from a text file. Use

  pto_var --set-from-file filename --output=output.pto project.pto

In the text file the individual variables can be separated by comma or a line break.

Crop

You can change the crop of images in the pto file with pto_var. There are several variants possible, depending on the use case

  • --crop=left,right,top,bottom Sets the crop for all images to the given coordinates.
  • --crop=width,height Sets the crop for all images to the given width and height and activates autocenter for crop. Relative values for width and height can be used with %, e.g. --crop=90%,80%
  • --crop=iNUM=left,right,top,bottom Sets the crop for image NUM to the given coordinates.
  • --crop=iNUM=width,height Sets the crop for image NUM to the given width and height and activate autocenter for crop.

The switches which refers to single images can be used several times and set the crop for several images in one go.

Anchor

For geometric and photometric optimisation one image is used as anchor. The image which is used as anchor can be set with --anchor=NUM for the geometric optimisation and with --color-anchor=NUM for the photometric optimisation.

General options

  • -o|--output output.pto Output a pto file with the given filename. If not given it will append "_var" to the input filename.
  • -h | --help Display help.