Thanks for publishing this. I've used what I've learned from your script to 
make this much simpler much more rigid script for a panorama poor in 
features that I'm currently trying to stich togetether:

#!/bin/bash

pto_gen -o scripting_step1_images.pto IMG_*.JPG

# https://wiki.panotools.org/Panorama_scripting_in_a_nutshell

# https://groups.google.com/g/hugin-ptx/c/ImcaDTH7KMY/m/GcHI-wNnFAAJ
# https://wiki.panotools.org/Pto_var
# simplified layout asuming 360° panorama
# rows are not needed in calculation, it's assumed that rows = number of 
pictures / columns
columns=8
degrees_below_horizon=55 # how far below the horizon does the panorama 
start?
field_of_view_horizontal=$((360/$columns)) # not the real field_of_view, 
subtract half of the overlap..
echo "field_of_view_horizontal = $field_of_view_horizontal"
field_of_view_vertical=$(($field_of_view_horizontal/4*3))
pto_var 
--set="y=(i%$columns)*$field_of_view_horizontal,p=floor(i/$columns)*$field_of_view_vertical-$degrees_below_horizon,r=0"
 
--output=scripting_step2_align_rows_and_columns.pto 
scripting_step1_images.pto

pto_mask --process=CLIP --mask=mask.msk@0 --mask=mask.msk@1 
--mask=mask.msk@2 --mask=mask.msk@3 --mask=mask.msk@4 --mask=mask.msk@5 
--mask=mask.msk@6 --mask=mask.msk@7 --output=scripting_step3_masks.pto 
scripting_step2_align_rows_and_columns.pto

# https://wiki.panotools.org/Cpfind
# --multirow --sieve2width=10 --sieve2height=10 --sieve2size=20 
--minmatches=1
cpfind --verbose --prealigned --fullscale --cache 
--output=scripting_step4_prealigned_cpfind.pto scripting_step3_masks.pto

linefind --output=scripting_step5_vertical-lines.pto 
scripting_step4_prealigned_cpfind.pto

# https://wiki.panotools.org/Geocpset
geocpset --each-overlap --output=scripting_step6_geocpset.pto 
scripting_step5_vertical-lines.pto

autooptimiser -a -m --output=scripting_step7_autoptimized.pto 
scripting_step6_geocpset.pto

hugin scripting_step7_autoptimized.pto


Thank you :)

mfc.s...@gmail.com schrieb am Samstag, 7. November 2015 um 13:45:39 UTC+1:

>
>> Ah!!  That works perfectly!   Very many thanks.   Presumably I can add 
>> that step to the script by calling cpfind  again (with --prealigned?) ?
>>
>
> Ignore that last question .. I see that won't work.
>
> Here, as promised, is the script I put together.  Plenty of room for 
> improvement...
>
> /* --------------------------------------------------------------- */
> /* huginpan.rex --- run Hugin with layout hints                    */
> /* --------------------------------------------------------------- */
> /*                                                                 */
> /* Call as:                                                        */
> /*                                                                 */
> /*   huginpan pattern lens columns rows order                      */
> /*                                                                 */
> /* where:                                                          */
> /*                                                                 */
> /*   pattern -- source files pattern (e.g., P*.jpg)                */
> /*   lens    -- lens length (mm, 35mm equivalent)                  */
> /*   columns -- number of images in X dimension                    */
> /*   rows    -- ditto in Y                                         */
> /*   order   -- mapping of image sequence to rectangle             */
> /*                                                                 */
> /* pattern, lens, and columns are required                         */
> /* rows default=1, order default=0                                 */
> /*                                                                 */
> /* order is:                                                       */
> /*                                                                 */
> /*   0 -- rows, left->right, top->bottom (start top-left)          */
> /*   1 -- columns, top->bottom, left->right (start top-left)       */
> /*                                                                 */
> /* Before using this, it is suggested that you copy the source     */
> /* files to their own subdirectory, then run this command with     */
> /* that as the current directory.                                  */
> /*                                                                 */
> /* Return codes from pto_ commands are not documented, so ignored. */
> /* --------------------------------------------------------------- */
> -- 2015.11.04 mfc initial vesrion
> -- 2015.11.06 add lens length as parameter
>
> -- ensure path to Hugin 64-bit programs [needed for cpfind]
> 'SET PATH=c:\Program Files\Hugin\bin;%PATH%'
>
> parse arg pattern lens columns rows order .
> if columns='' then do
>   say 'Pattern, lens, and columns must be specified'
>   exit -1
>   end
> if rows='' then rows=1
> if order='' then order=0
>
> -- set up constants (could be parameters or options, later)
> -- short-edge equivanet sensor size is assumed to be as 4:3 35mm (27mm)
> aspect=4/3          -- sensor horizontal:vertical ratio
> portrait=0          -- 1 if camera in portrait (vertical) format
> overlap=0.4         -- overlap between images as a fraction
>
> -- calculate total degrees vertical and horizontal
> h=2*arctan((27*aspect) / (2*lens)) -- sensor horizontal degrees
> v=2*arctan(27 / (2*lens))          -- ditto vertical
> if portrait then do                -- swap if portrait
>   temp=h
>   h=v
>   v=temp
>   end
> -- now have degrees for h and v for one image
> say 'Image degrees:' h 'x' v
>
> totalh=h*(columns - overlap*(columns-1))
> totalv=v*(rows    - overlap*(rows-1))
> say 'Total degrees:' totalh 'x' totalv
>
> -- set up the pitch and yaw formulae
> -- absolute origin non-critical
> eh=h*(1-overlap)                   -- effective horizontal degrees
> ev=v*(1-overlap)                   -- effective vertical degrees
> offseth=totalh/2 - h/2             -- offset for 0,0 image
> offsetv=totalv/2 - v/2             -- ..
>
> select
>   when order=0 then do             -- TL, by row, left->right
>     yaw='(i%'columns')*'eh'-'offseth
>     pitch=offsetv'-(floor(i/'columns')*'ev')'
>     end
>   when order=1 then do             -- TL, by column, top->bottom
>     yaw='(floor(i/'rows')*'eh')-'offseth
>     pitch=offsetv'-(i%'rows')*'ev
>     end
>   otherwise do
>     say 'Bad order specified:' order
>     exit -1
>     end
>   end
> say 'yaw='yaw 'pitch='pitch
>
>
> ----- process the images using Hugin commands -----
>
> profile='project.pto'         -- project filename
> call sysfiledelete profile
>
> -- create the Hugin project file
> 'pto_gen -o' profile pattern
>
> -- update/set rough geometricals
> 'pto_var "--set=y='yaw',p='pitch'" --output='profile profile
>
> -- find control points
> 'cpfind --output='profile '--prealigned' profile
>
> -- add missing control points using geometry
> 'geocpset --output='profile profile
>
> -- done
> say
> say 'Starting Hugin.  Open' profile', Align, and Generate Panorama'
> 'start "Hugin" Hugin'
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/hugin-ptx/3f05364a-ef79-4b2c-9b24-a1ec0c92cf1cn%40googlegroups.com.

Reply via email to