diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-05-12 18:23:32 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-05-12 18:23:32 +0200 |
| commit | 25892512388d27417815681bd4e4813f1519334d (patch) | |
| tree | ed367bf4a89b703ca2b2485018edf88d30968fa6 /warp-mix-dirs.sh | |
| parent | 896c68de1402e97027d54ef900f596803323cff3 (diff) | |
warp-mix-dirs.sh
Diffstat (limited to 'warp-mix-dirs.sh')
| -rw-r--r-- | warp-mix-dirs.sh | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/warp-mix-dirs.sh b/warp-mix-dirs.sh new file mode 100644 index 0000000..d7c6bfb --- /dev/null +++ b/warp-mix-dirs.sh @@ -0,0 +1,103 @@ +#!/bin/bash + +BASENAME=tmp +ITER=1 +A_ITER=1 +B_ITER=1 +FRAMES=200 +POSITIONAL=() +while [[ $# -gt 0 ]] +do +key="$1" + +case $key in + -f|--frames) + FRAMES=$(expr $2 + 0) + shift # past argument + shift # past value + ;; + -s|--start) + ITER=$(expr $2 + 1) + shift # past argument + shift # past value + ;; + -o|--output) + OUTPUT_DIR="$2" + BASENAME=$(basename $OUTPUT_DIR) + shift # past argument + shift # past value + ;; + # --default) + # DEFAULT=YES + # shift # past argument + # ;; + *) # unknown option + POSITIONAL+=("$1") # save it in an array for later + shift # past argument + ;; +esac +done +set -- "${POSITIONAL[@]}" # restore positional parameters + +rm -rf tmp/ +mkdir tmp/ + +B_DIR="null" + +for A_DIR in "${POSITIONAL[@]}" +do + + echo $A_DIR + if [ $B_DIR -eq 'null' ] + then + B_DIR=$A_DIR + B_ITER=A_ITER + continue + fi + + a=$(printf "%s/frame_%05d.png" $A_DIR $A_ITER) + b=$(printf "%s/frame_%05d.png" $B_DIR $((B_ITER + FRAMES))) + + convert -verbose "$DIRECTORY/$a" PNG24:tmp_normalized_0.png + convert -verbose "$DIRECTORY/$b" PNG24:tmp_normalized_1.png + + ./makeOptFlow.sh tmp_normalized_%01d.png flow 0 + + STEP=$(bc -l <<< "1 / $FRAMES") + SEQUENCE=`seq 0.0 $STEP 1.0` + + for scale in $SEQUENCE; do + scale="${scale/,/.}" + echo "${ITER}: ${scale}" + a_f=$(printf "%s/frame_%05d.png" $A_DIR $A_ITER) + b_f=$(printf "%s/frame_%05d.png" $B_DIR $B_ITER) + th torch_warp.lua \ + -flow_file flow/backward_1_0.flo \ + -source_image $a_f \ + -output_image warp_0.png \ + -scale $scale + th torch_warp.lua \ + -flow_file flow/forward_0_1.flo \ + -source_image $b_f \ + -output_image warp_1.png \ + -scale $(bc <<< "1.0-$scale") + OUT=$(printf "tmp/frame_%05d.png" $ITER) + convert warp_0.png warp_1.png -compose blend -define compose:args=$(bc <<< "100*$scale/1") -composite $OUT + rm warp_0.png warp_1.png + + ITER=$((ITER+1)) + A_ITER=$((A_ITER+1)) + B_ITER=$((B_ITER+1)) + done + + rm -rf flow/ tmp_normalized*.png +done + +ffmpeg -i tmp/frame_%05d.png -vcodec libx264 -pix_fmt yuv420p -profile:v baseline -level 3 "mixed_${BASENAME}.mp4" + +cd tmp/ +mkdir 256 +for i in *; do convert $i -resize '256x256!' 256/$i; done +cd .. +mv tmp mixed_${BASENAME} + |
