#!/bin/bash
NUMTRIALS=$1 # number of trials
SINTELDIR="$(pwd)" # root folder of unpacked sintel data
TRAININGDATA="${SINTELDIR}/training" # folder with the training data
OCCLUSIONDATA="${TRAININGDATA}/occlusions" # folder with the occlusion maps
OUTPUTDIR="$(pwd)/output" # where to save all processing steps and the final output
GRAYSCALEOUTPUT=${OUTPUTDIR}/SintelGray
mkdir $OUTPUTDIR/$2
### Create trials
export OCCLOUTPUTDIR="$OUTPUTDIR/$2/occlusion"
mkdir $OCCLOUTPUTDIR
export OCCLUSIONMAPDIR="$OUTPUTDIR/$2/occlusionMaps"
mkdir $OCCLUSIONMAPDIR
export MOTIONOUTPUTDIR="$OUTPUTDIR/$2/motion"
mkdir $MOTIONOUTPUTDIR
export MOTIONMAPDIR="$OUTPUTDIR/$2/motionMaps"
mkdir $MOTIONMAPDIR
## create occlusion trials and occlusion maps
# if you want to skip this step, comment lines below
mkdir parallelres
seq 1 $NUMTRIALS | parallel --eta --joblog occlusion.log ./createTrial.sh $GRAYSCALEOUTPUT $OCCLUSIONDATA "occlusion" {} $NUMTRIALS
find parallelres -name "stdout*" | xargs cat | sort | echo -e "trial, xOffset, yOffset, sequence, startFrame\n$(cat -)" > OcclCreation.log
rm -r parallelres
## create motion trials and corresponding occlusion maps
# if you want to skip this step, comment lines below
mkdir parallelres
seq 1 $NUMTRIALS | parallel --eta --joblog motion.log ./createTrial.sh $GRAYSCALEOUTPUT $OCCLUSIONDATA "motion" {} $NUMTRIALS
find parallelres -name "stdout*" | xargs cat | sort | echo -e "trial, xOffset, yOffset, sequence, startFrame\n$(cat -)" > motionCreation.log
rm -r parallelres
# END creation of occlusion data