#!/bin/bash if [ "$3" == "" ]; then echo 'use: getstack.sh [name]' exit 1 fi minus=$1 plus=$2 step=$3 snapname=`date +%y%m%d%H%M` if [ "$4" ]; then snapname="$4-$snapname"; fi snapext=".jpg" SERVER=3Dprinter PORT=8080 SLEEPSHORT=0.8 SLEEPLONG=1 FSPEED=3000 SIM=0 function xsleep { if [ "$SIM" == "0" ]; then sleep $1 fi } function snapshot { xsleep $SLEEPSHORT name="$snapname-$1`printf "%06.2f" "$2"`$snapext" # echo "SNAP:$name" curl -s "http://$SERVER:$PORT/?action=snapshot" > $name identify "$name" } snapshot '0' 0 for z in `seq 1 $plus`; do 8jog -$step snapshot '-' `echo "$z * $step"|bc` done for z in `seq 1 $plus`; do 8jog $step done xsleep $SLEEPLONG for z in `seq 1 $minus`; do 8jog $step snapshot '+' `echo "$z * $step"|bc` done for z in `seq 1 $minus`; do 8jog -$step done align_image_stack -a st_ -m -v $snapname*.jpg enfuse -o "$snapname-FocusStacked.jpg" --contrast-weight=1.00 --exposure-weight=0.00 --saturation-weight=0.00 --contrast-window-size=5 --hard-mask --gray-projector=luminance st*.tif rm -vf st*.tif