Skip to content

Instantly share code, notes, and snippets.

@stoermerjp
Created July 12, 2012 12:24
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stoermerjp/3097813 to your computer and use it in GitHub Desktop.
Save stoermerjp/3097813 to your computer and use it in GitHub Desktop.
DroneMapper.com: Automated 2D Mosaic Construction using Hugin/Panotools
#!/bin/bash
###
### DroneMapper.com
### Jon-Pierre Stoermer 04-01-2012
###
### Cleanup
rm ./project_*.tif
rm ./project.pto
### Check for cache directory, if not -- build
if [ ! -e ./cache ]; then
/bin/mkdir cache
for FILE in ./*.JPG ;
do
FILE480x480=`echo $FILE | sed 's/.JPG$/.png/'` ;
FILE25x25=`echo $FILE | sed 's/.JPG$/_25x25.png/'`;
/usr/bin/convert -compress LZW -resize 480x480 $FILE cache/$FILE480x480;
/usr/bin/convert -compress LZW -resize 25x25 $FILE cache/$FILE25x25;
done
fi
###
### Command Line Args
###
### File Type
ARG1=$1
### Compression
ARG2=$2
### Depth
ARG3=$3
### Watermarks
WATERMARKS=$4
## Match
HOW=$5
## Generate Order
ls -v ./*.$ARG1 > ./orderh5.out
###
### FHOV = 360 / # Of Images
###
IMGC=`ls -l ./*.$ARG1 | wc -l`
FHOV=$((360 / $IMGC))
### Generate Project
if [ -e ./order.out ] ; then
/usr/local/hugin5/bin/pto_gen -o ./project.pto -f 10 -p 0 `cat ./order.out`
else
/usr/local/hugin5/bin/pto_gen -o ./project.pto -f 10 -p 0 `cat ./orderh5.out`;
fi
### Generate Control Points
sleep 1
if [ $HOW == linearmatch ] ; then
/usr/local/hugin5/bin/cpfind -n 1 --linearmatch --minmatches 20 -o ./project.pto ./project.pto
elif [ $HOW == multirow ]; then
/usr/local/hugin5/bin/cpfind -n 1 --multirow --minmatches 20 -o ./project.pto ./project.pto
else
/usr/local/hugin5/bin/cpfind -n 1 --minmatches 20 -o ./project.pto ./project.pto
fi
### Optimiser
sleep 1
/usr/local/hugin5/bin/autooptimiser -p -a -n -o ./project.pto ./project.pto
sleep 1
/usr/local/hugin5/bin/pano_modify --projection=0 -c -o ./project.pto ./project.pto
### Nona
sleep 1
/usr/local/hugin5/bin/nona -z $ARG2 -m TIFF_m -o ./project_ project.pto
echo "FHOV Calculated: " $FHOV
echo "IMG Count: " $IMGC
### Enblend
sleep 1
enblend --compression=$ARG2 -d $ARG3 --wrap=NONE --fine-mask -a -o ./project5m.tif ./project_*.tif
convert ./project5m.tif -trim ./output.tif
convert ./output.tif -compress $ARG2 -depth $ARG3 -transparent white ./output.png
convert ./output.png -scale 20% output_20.png
zip output.zip output.tif
if [ $WATERMARKS == watermarks ] ; then
composite -dissolve 25 -tile /www/html/files/dm_watermark.png ./output.tif ./output.tif
composite -gravity center -dissolve 25 /www/html/files/dm_watermark_small.png ./output.png ./output.png
fi
### Clean Up
rm ./project_*.tif
rm ./project.pto
rm ./project5m.tif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment