diff --git a/scripts/downloadDatasets.sh b/scripts/downloadDatasets.sh index 95f9a74..22fb149 100755 --- a/scripts/downloadDatasets.sh +++ b/scripts/downloadDatasets.sh @@ -102,3 +102,21 @@ if [ ! -d ../data/MEDS/img ]; then mv data/*/*.jpg ../data/MEDS/img rm -r data NIST_SD32_MEDS-II_face.zip fi + +#LFPW +if [ ! -d ../data/lfpw/trainset ]; then + echo "Downloading LFPW..." + if hash curl 2>/dev/null; then + curl -OL http://ibug.doc.ic.ac.uk/media/uploads/competitions/lfpw.zip + else + wget http://ibug.doc.ic.ac.uk/media/uploads/competitions/lfpw.zip + fi + + unzip lfpw.zip + mv lfpw ../data + cd ../data/lfpw + python ../../scripts/lfpwToSigset.py + cd ../../scripts + rm lfpw.zip +fi + diff --git a/scripts/lfpwToSigset.py b/scripts/lfpwToSigset.py new file mode 100644 index 0000000..39e6fe0 --- /dev/null +++ b/scripts/lfpwToSigset.py @@ -0,0 +1,43 @@ +#!/usr/bin/python + +# This scripts converts the LFPW .pts files into xml sigsets that can be readily +# used within openbr. + +from xml.dom.minidom import Document +import glob +import os + +for lfpwType in ['train','test']: + files = glob.glob('%sset/*.pts' % lfpwType) + files.sort() + cnt = 0 + + xmlDoc = Document() + xmlRoot = xmlDoc.createElement('biometric-signature-set') + for ptsFile in files: + cnt += 1 + ini = open(ptsFile) + lines = ini.readlines() + ini.close() + + pntStrList = [] + n = int(lines[1].split()[1]) + for i in range(3,3+n): + pntStrList.append('(%s)' % (','.join(lines[i].split()))) + pntStr = '[%s]' % ','.join(pntStrList) + + xmlSubj = xmlDoc.createElement('biometric-signature') + xmlSubj.setAttribute('name','subj_%05d' % cnt) + xmlPres = xmlDoc.createElement('presentation') + xmlPres.setAttribute('file-name','%sset/%s.png' % (lfpwType,os.path.splitext(ptsFile)[0])) + xmlPres.setAttribute('Points',pntStr) + xmlSubj.appendChild(xmlPres) + xmlRoot.appendChild(xmlSubj) + + if not os.path.exists('sigset'): + os.mkdir('sigset') + out = open('sigset/%s.xml' % lfpwType,'w') + print >> out, xmlRoot.toprettyxml() + out.close() + +