#!/bin/bash
# prints out a element
# additional arguments after the first two are rectangle coordinates
# from that, it will create a nested element (from the ViPER standard)
# http://viper-toolkit.sourceforge.net/docs/file/
writePresentation()
{
pres="\t\t"
pres="$pres\n\t\t"
else
pres="$pres />"
fi
printf "$pres\n"
}
# export writePresentation so xargs can call it using bash -c below
export -f writePresentation
SEDREGEX='s/.*(\([0-9]*\), \([0-9]*\)) - (\([0-9]*\), \([0-9]*\))/writeIt \1 \2 \3 \4/'
echo ''
echo ''
# print out the positive image sigs
for fullpath in INRIAPerson/$1/pos/*; do
# get just the filename, minus the path
filename=$(basename "$fullpath")
echo -e "\t"
# if this folder has annotations, add bounding boxes
if [ -d INRIAPerson/$1/annotations ]; then
annotation="INRIAPerson/$1/annotations/${filename%.*}.txt"
grep 'Bounding box' $annotation | sed "$SEDREGEX" | xargs -n 5 bash -c "writePresentation $1 $filename \$@"
# otherwise, just the normal presentation
else
writePresentation $1 $filename
fi
echo -e '\t'
done
# print out the negative image sigs
for fullpath in INRIAPerson/$1/neg/*; do
filename=$(basename "$fullpath")
echo -e "\t"
echo -e "\t\t"
echo -e '\t'
done
echo ''