Commit d1a001908c227f291493ba7771f52fe425d64f75

Authored by Brendan Klare
1 parent 7a0a9f3e

Added LFPW dataset to the download list, and created script to convert to xml sigset

scripts/downloadDatasets.sh
@@ -102,3 +102,21 @@ if [ ! -d ../data/MEDS/img ]; then @@ -102,3 +102,21 @@ if [ ! -d ../data/MEDS/img ]; then
102 mv data/*/*.jpg ../data/MEDS/img 102 mv data/*/*.jpg ../data/MEDS/img
103 rm -r data NIST_SD32_MEDS-II_face.zip 103 rm -r data NIST_SD32_MEDS-II_face.zip
104 fi 104 fi
  105 +
  106 +#LFPW
  107 +if [ ! -d ../data/lfpw/trainset ]; then
  108 + echo "Downloading LFPW..."
  109 + if hash curl 2>/dev/null; then
  110 + curl -OL http://ibug.doc.ic.ac.uk/media/uploads/competitions/lfpw.zip
  111 + else
  112 + wget http://ibug.doc.ic.ac.uk/media/uploads/competitions/lfpw.zip
  113 + fi
  114 +
  115 + unzip lfpw.zip
  116 + mv lfpw ../data
  117 + cd ../data/lfpw
  118 + python ../../scripts/lfpwToSigset.py
  119 + cd ../../scripts
  120 + rm lfpw.zip
  121 +fi
  122 +
scripts/lfpwToSigset.py 0 → 100644
  1 +#!/usr/bin/python
  2 +
  3 +# This scripts converts the LFPW .pts files into xml sigsets that can be readily
  4 +# used within openbr.
  5 +
  6 +from xml.dom.minidom import Document
  7 +import glob
  8 +import os
  9 +
  10 +for lfpwType in ['train','test']:
  11 + files = glob.glob('%sset/*.pts' % lfpwType)
  12 + files.sort()
  13 + cnt = 0
  14 +
  15 + xmlDoc = Document()
  16 + xmlRoot = xmlDoc.createElement('biometric-signature-set')
  17 + for ptsFile in files:
  18 + cnt += 1
  19 + ini = open(ptsFile)
  20 + lines = ini.readlines()
  21 + ini.close()
  22 +
  23 + pntStrList = []
  24 + n = int(lines[1].split()[1])
  25 + for i in range(3,3+n):
  26 + pntStrList.append('(%s)' % (','.join(lines[i].split())))
  27 + pntStr = '[%s]' % ','.join(pntStrList)
  28 +
  29 + xmlSubj = xmlDoc.createElement('biometric-signature')
  30 + xmlSubj.setAttribute('name','subj_%05d' % cnt)
  31 + xmlPres = xmlDoc.createElement('presentation')
  32 + xmlPres.setAttribute('file-name','%sset/%s.png' % (lfpwType,os.path.splitext(ptsFile)[0]))
  33 + xmlPres.setAttribute('Points',pntStr)
  34 + xmlSubj.appendChild(xmlPres)
  35 + xmlRoot.appendChild(xmlSubj)
  36 +
  37 + if not os.path.exists('sigset'):
  38 + os.mkdir('sigset')
  39 + out = open('sigset/%s.xml' % lfpwType,'w')
  40 + print >> out, xmlRoot.toprettyxml()
  41 + out.close()
  42 +
  43 +