Commit 2bd7e154223ba7e37a4d55da18d11bca5a3e6874

Authored by Scott Klum
1 parent 2f89b3f6

Only write files to sigsets that are non-null

Showing 1 changed file with 24 additions and 18 deletions
openbr/core/bee.cpp
@@ -71,7 +71,11 @@ FileList BEE::readSigset(const File &sigset, bool ignoreMetadata) @@ -71,7 +71,11 @@ FileList BEE::readSigset(const File &sigset, bool ignoreMetadata)
71 for (int i=0; i<attributes.length(); i++) { 71 for (int i=0; i<attributes.length(); i++) {
72 const QString key = attributes.item(i).nodeName(); 72 const QString key = attributes.item(i).nodeName();
73 const QString value = attributes.item(i).nodeValue(); 73 const QString value = attributes.item(i).nodeValue();
74 - if (key == "file-name") file.name = value; 74 + if (key == "url") file.name = value.split('/').last();
  75 + else if (key == "Rect") {
  76 + QStringList points = value.split(',');
  77 + file.appendRect(QRect(points.at(0).toInt(),points.at(1).toInt(),points.at(2).toInt()-points.at(0).toInt(),value.split(',').at(3).toInt()-points.at(1).toInt()));
  78 + }
75 else if (!ignoreMetadata) file.set(key, value); 79 else if (!ignoreMetadata) file.set(key, value);
76 } 80 }
77 81
@@ -111,25 +115,27 @@ void BEE::writeSigset(const QString &amp;sigset, const br::FileList &amp;files, bool ign @@ -111,25 +115,27 @@ void BEE::writeSigset(const QString &amp;sigset, const br::FileList &amp;files, bool ign
111 lines.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); 115 lines.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
112 lines.append("<biometric-signature-set>"); 116 lines.append("<biometric-signature-set>");
113 foreach (const File &file, files) { 117 foreach (const File &file, files) {
114 - QStringList metadata;  
115 - if (!ignoreMetadata) {  
116 - foreach (const QString &key, file.localKeys()) {  
117 - if ((key == "Index") || (key == "Label") || (key == "Points") || (key == "Rects")) continue;  
118 - metadata.append(key+"=\""+QtUtils::toString(file.value(key))+"\"");  
119 - }  
120 - QStringList landmarks;  
121 - if (!file.points().isEmpty()) {  
122 - foreach (const QPointF &point, file.points()) landmarks.append(QtUtils::toString(point));  
123 - metadata.append("Points=\"["+landmarks.join(",")+"]\""); landmarks.clear();  
124 - }  
125 - if (!file.rects().isEmpty()) {  
126 - foreach (const QRectF &rect, file.rects()) landmarks.append(QtUtils::toString(rect));  
127 - metadata.append("Rects=\"["+landmarks.join(",")+"]\""); 118 + if (!file.isNull()) {
  119 + QStringList metadata;
  120 + if (!ignoreMetadata) {
  121 + foreach (const QString &key, file.localKeys()) {
  122 + if ((key == "Index") || (key == "Label") || (key == "Points") || (key == "Rects")) continue;
  123 + metadata.append(key+"=\""+QtUtils::toString(file.value(key))+"\"");
  124 + }
  125 + QStringList landmarks;
  126 + if (!file.points().isEmpty()) {
  127 + foreach (const QPointF &point, file.points()) landmarks.append(QtUtils::toString(point));
  128 + metadata.append("Points=\"["+landmarks.join(",")+"]\""); landmarks.clear();
  129 + }
  130 + if (!file.rects().isEmpty()) {
  131 + foreach (const QRectF &rect, file.rects()) landmarks.append(QtUtils::toString(rect));
  132 + metadata.append("Rects=\"["+landmarks.join(",")+"]\"");
  133 + }
128 } 134 }
  135 + lines.append("\t<biometric-signature name=\"" + file.get<QString>("Label",file.baseName()) +"\">");
  136 + lines.append("\t\t<presentation file-name=\"" + file.name + "\" " + metadata.join(" ") + "/>");
  137 + lines.append("\t</biometric-signature>");
129 } 138 }
130 - lines.append("\t<biometric-signature name=\"" + file.get<QString>("Label",file.baseName()) +"\">");  
131 - lines.append("\t\t<presentation file-name=\"" + file.name + "\" " + metadata.join(" ") + "/>");  
132 - lines.append("\t</biometric-signature>");  
133 } 139 }
134 lines.append("</biometric-signature-set>"); 140 lines.append("</biometric-signature-set>");
135 QtUtils::writeFile(sigset, lines); 141 QtUtils::writeFile(sigset, lines);