Skip to content

Instantly share code, notes, and snippets.

@ebadawy
Created June 18, 2016 17:58
Show Gist options
  • Save ebadawy/d5de93ed74679c3a3034296e3b0cd068 to your computer and use it in GitHub Desktop.
Save ebadawy/d5de93ed74679c3a3034296e3b0cd068 to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
DATABASE_ROOT=/path/to/dataset/root
OUT=/path/to/OF/output
MATLAB_OF_DIR=/path/to/compute_OF/function
MATLAB_OUT_FILE=/path/to/matlab/output/file
if [ -d $OUT/flow_dir ]; then
echo "You alreay have flow_dir in $OUT"
echo "Remove it first if you want to recompute OF."
exit 1
fi
if [ -f $MATLAB_OUT_FILE/flow.m ]; then
rm $MATLAB_OUT_FILE/flow.m
fi
mkdir $OUT/flow_dir
touch $MATLAB_OUT_FILE/flow.m
echo "addpath '/home/ebadawy/actiontubes/'" >> "$MATLAB_OUT_FILE/flow.m"
selected_actions=('jump' 'climb_stairs' 'run' 'shoot_gun' 'throw');
for action in $(ls $DATABASE_ROOT)
do
if ! [[ " ${selected_actions[@]} " =~ " ${action} " ]]; then
continue
fi
mkdir $OUT/flow_dir/$action
for video in $(ls $DATABASE_ROOT/$action)
do
mkdir $OUT/flow_dir/$action/$video
prev="$DATABASE_ROOT/$action/$video/$(ls $DATABASE_ROOT/$action/$video | sort -n | head -1)"
for frame in $(ls $DATABASE_ROOT/$action/$video)
do
nxt="$DATABASE_ROOT/$action/$video/$frame"
if [ $prev == $nxt ]; then
continue
fi
CMD="imwrite(compute_OF(imread('$prev'),imread('$nxt')),'$OUT/flow_dir/$action/$video/$frame');"
echo $CMD >> "$MATLAB_OUT_FILE/flow.m"
prev=$nxt
done
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment