Commit 10d6fd414e9c4cd06aee93b1ae228ec1c121c0df
1 parent
01a923b2
Add comments to INRIAPerson sigset generator script
Showing
1 changed file
with
15 additions
and
1 deletions
scripts/writeINRIAPersonSigset.sh
| 1 | #!/bin/bash | 1 | #!/bin/bash |
| 2 | 2 | ||
| 3 | +# prints out a <presentation> element | ||
| 4 | +# additional arguments after the first two are rectangle coordinates | ||
| 5 | +# from that, it will create a nested <data:bbox> element (from the ViPER standard) | ||
| 6 | +# http://viper-toolkit.sourceforge.net/docs/file/ | ||
| 3 | writePresentation() | 7 | writePresentation() |
| 4 | { | 8 | { |
| 5 | pres="\t\t<presentation Label=\"pos\" file-name=\"$1/pos/$2\"" | 9 | pres="\t\t<presentation Label=\"pos\" file-name=\"$1/pos/$2\"" |
| @@ -14,27 +18,37 @@ writePresentation() | @@ -14,27 +18,37 @@ writePresentation() | ||
| 14 | fi | 18 | fi |
| 15 | printf "$pres\n" | 19 | printf "$pres\n" |
| 16 | } | 20 | } |
| 17 | -# for xargs calling bash below | 21 | +# export writePresentation so xargs can call it using bash -c below |
| 18 | export -f writePresentation | 22 | export -f writePresentation |
| 19 | SEDREGEX='s/.*(\([0-9]*\), \([0-9]*\)) - (\([0-9]*\), \([0-9]*\))/writeIt \1 \2 \3 \4/' | 23 | SEDREGEX='s/.*(\([0-9]*\), \([0-9]*\)) - (\([0-9]*\), \([0-9]*\))/writeIt \1 \2 \3 \4/' |
| 20 | 24 | ||
| 21 | echo '<?xml version="1.0" encoding="UTF-8"?>' | 25 | echo '<?xml version="1.0" encoding="UTF-8"?>' |
| 22 | echo '<biometric-signature-set>' | 26 | echo '<biometric-signature-set>' |
| 27 | + | ||
| 28 | +# print out the positive image sigs | ||
| 23 | for fullpath in INRIAPerson/$1/pos/*; do | 29 | for fullpath in INRIAPerson/$1/pos/*; do |
| 30 | + # get just the filename, minus the path | ||
| 24 | filename=$(basename "$fullpath") | 31 | filename=$(basename "$fullpath") |
| 25 | echo -e "\t<biometric-signature name=\"${filename%.*}\">" | 32 | echo -e "\t<biometric-signature name=\"${filename%.*}\">" |
| 33 | + | ||
| 34 | + # if this folder has annotations, add bounding boxes | ||
| 26 | if [ -d INRIAPerson/$1/annotations ]; then | 35 | if [ -d INRIAPerson/$1/annotations ]; then |
| 27 | annotation="INRIAPerson/$1/annotations/${filename%.*}.txt" | 36 | annotation="INRIAPerson/$1/annotations/${filename%.*}.txt" |
| 28 | grep 'Bounding box' $annotation | sed "$SEDREGEX" | xargs -n 5 bash -c "writePresentation $1 $filename \$@" | 37 | grep 'Bounding box' $annotation | sed "$SEDREGEX" | xargs -n 5 bash -c "writePresentation $1 $filename \$@" |
| 38 | + # otherwise, just the normal presentation | ||
| 29 | else | 39 | else |
| 30 | writePresentation $1 $filename | 40 | writePresentation $1 $filename |
| 31 | fi | 41 | fi |
| 42 | + | ||
| 32 | echo -e '\t</biometric-signature>' | 43 | echo -e '\t</biometric-signature>' |
| 33 | done | 44 | done |
| 45 | + | ||
| 46 | +# print out the negative image sigs | ||
| 34 | for fullpath in INRIAPerson/$1/neg/*; do | 47 | for fullpath in INRIAPerson/$1/neg/*; do |
| 35 | filename=$(basename "$fullpath") | 48 | filename=$(basename "$fullpath") |
| 36 | echo -e "\t<biometric-signature name=\"${filename%.*}\">" | 49 | echo -e "\t<biometric-signature name=\"${filename%.*}\">" |
| 37 | echo -e "\t\t<presentation Label=\"neg\" file-name=\"$1/neg/$filename\" />" | 50 | echo -e "\t\t<presentation Label=\"neg\" file-name=\"$1/neg/$filename\" />" |
| 38 | echo -e '\t</biometric-signature>' | 51 | echo -e '\t</biometric-signature>' |
| 39 | done | 52 | done |
| 53 | + | ||
| 40 | echo '</biometric-signature-set>' | 54 | echo '</biometric-signature-set>' |