Commit f207c6884845d3d648d02b894bca78dcda01f900

Authored by Brendan Klare
2 parents 228938c5 6a9e4eb0

Merge branch 'master' of https://github.com/biometrics/openbr

openbr/openbr_plugin.cpp
@@ -137,6 +137,8 @@ QVariant File::parse(const QString &value) @@ -137,6 +137,8 @@ QVariant File::parse(const QString &value)
137 if (ok) return point; 137 if (ok) return point;
138 const QRectF rect = QtUtils::toRect(value, &ok); 138 const QRectF rect = QtUtils::toRect(value, &ok);
139 if (ok) return rect; 139 if (ok) return rect;
  140 + const int i = value.toInt(&ok);
  141 + if (ok) return i;
140 const float f = value.toFloat(&ok); 142 const float f = value.toFloat(&ok);
141 if (ok) return f; 143 if (ok) return f;
142 return value; 144 return value;
openbr/plugins/algorithms.cpp
@@ -44,7 +44,7 @@ class AlgorithmsInitializer : public Initializer @@ -44,7 +44,7 @@ class AlgorithmsInitializer : public Initializer
44 Globals->abbreviations.insert("AgeEstimation", "AgeRegression"); 44 Globals->abbreviations.insert("AgeEstimation", "AgeRegression");
45 Globals->abbreviations.insert("FaceRecognition2", "{PP5Register+Affine(128,128,0.25,0.35)+Cvt(Gray)}+(Gradient+Bin(0,360,9,true))/(Blur(1)+Gamma(0.2)+DoG(1,2)+ContrastEq(0.1,10)+LBP(1,2,true)+Bin(0,10,10,true))+Merge+Integral+RecursiveIntegralSampler(4,2,8,LDA(.98)+Normalize(L1))+Cat+PCA(768)+Normalize(L1)+Quantize:UCharL1"); 45 Globals->abbreviations.insert("FaceRecognition2", "{PP5Register+Affine(128,128,0.25,0.35)+Cvt(Gray)}+(Gradient+Bin(0,360,9,true))/(Blur(1)+Gamma(0.2)+DoG(1,2)+ContrastEq(0.1,10)+LBP(1,2,true)+Bin(0,10,10,true))+Merge+Integral+RecursiveIntegralSampler(4,2,8,LDA(.98)+Normalize(L1))+Cat+PCA(768)+Normalize(L1)+Quantize:UCharL1");
46 Globals->abbreviations.insert("CropFace", "Open+Cvt(Gray)+Cascade(FrontalFace)+ASEFEyes+Affine(128,128,0.25,0.35)"); 46 Globals->abbreviations.insert("CropFace", "Open+Cvt(Gray)+Cascade(FrontalFace)+ASEFEyes+Affine(128,128,0.25,0.35)");
47 - Globals->abbreviations.insert("4SF", "Open+Cvt(Gray)+Cascade(FrontalFace)+ASEFEyes+Affine(128,128,0.33,0.45)+(Grid(10,10)+SIFTDescriptor(12)+ByRow)/(Blur(1.1)+Gamma(0.2)+DoG(1,2)+ContrastEq(0.1,10)+LBP(1,2)+RectRegions(8,8,6,6)+Hist(59))+PCA(0.95)+Normalize(L2)+Dup(12)+RndSubspace(0.05,1)+LDA(0.98)+Cat+PCA(0.95)+Normalize(L1)+Quantize:NegativeLogPlusOne(ByteL1)"); 47 + Globals->abbreviations.insert("4SF", "Open+Cvt(Gray)+Cascade(FrontalFace)+ASEFEyes+Affine(128,128,0.33,0.45)+(Grid(10,10)+SIFTDescriptor(12)+ByRow)/(Blur(1.1)+Gamma(0.2)+DoG(1,2)+ContrastEq(0.1,10)+LBP(1,2)+RectRegions(8,8,6,6)+Hist(59))+PCA(0.95)+Cat+Normalize(L2)+Dup(12)+RndSubspace(0.05,1)+LDA(0.98)+Cat+PCA(0.95)+Normalize(L1)+Quantize:NegativeLogPlusOne(ByteL1)");
48 48
49 // Video 49 // Video
50 Globals->abbreviations.insert("DisplayVideo", "Stream(FPSLimit(30)+Show(false,[FrameNumber])+Discard)"); 50 Globals->abbreviations.insert("DisplayVideo", "Stream(FPSLimit(30)+Show(false,[FrameNumber])+Discard)");
openbr/plugins/gallery.cpp
@@ -506,38 +506,55 @@ BR_REGISTER(Gallery, csvGallery) @@ -506,38 +506,55 @@ BR_REGISTER(Gallery, csvGallery)
506 * \brief Treats each line as a file. 506 * \brief Treats each line as a file.
507 * \author Josh Klontz \cite jklontz 507 * \author Josh Klontz \cite jklontz
508 * 508 *
509 - * The entire line is treated as the file path. 509 + * The entire line is treated as the file path. An optional label may be specified using a space ' ' separator:
510 * 510 *
  511 +\verbatim
  512 +<FILE>
  513 +<FILE>
  514 +...
  515 +<FILE>
  516 +\endverbatim
  517 + * or
  518 +\verbatim
  519 +<FILE> <LABEL>
  520 +<FILE> <LABEL>
  521 +...
  522 +<FILE> <LABEL>
  523 +\endverbatim
511 * \see csvGallery 524 * \see csvGallery
512 */ 525 */
513 class txtGallery : public Gallery 526 class txtGallery : public Gallery
514 { 527 {
515 Q_OBJECT 528 Q_OBJECT
516 - Q_PROPERTY(QString metadataKey READ get_metadataKey WRITE set_metadataKey RESET reset_metadataKey STORED false)  
517 - BR_PROPERTY(QString, metadataKey, "") 529 + Q_PROPERTY(QString label READ get_label WRITE set_label RESET reset_label STORED false)
  530 + BR_PROPERTY(QString, label, "")
518 531
519 QStringList lines; 532 QStringList lines;
520 533
521 ~txtGallery() 534 ~txtGallery()
522 { 535 {
523 - if (!lines.isEmpty()) QtUtils::writeFile(file.name, lines); 536 + if (!lines.isEmpty())
  537 + QtUtils::writeFile(file.name, lines);
524 } 538 }
525 539
526 TemplateList readBlock(bool *done) 540 TemplateList readBlock(bool *done)
527 { 541 {
528 - *done = true;  
529 TemplateList templates; 542 TemplateList templates;
530 - if (!file.exists()) return templates;  
531 -  
532 - foreach (const QString &line, QtUtils::readLines(file))  
533 - templates.append(File(line)); 543 + foreach (const QString &line, QtUtils::readLines(file)) {
  544 + int splitIndex = line.lastIndexOf(' ');
  545 + if (splitIndex == -1) templates.append(File(line));
  546 + else templates.append(File(line.mid(0, splitIndex), line.mid(splitIndex+1)));
  547 + }
534 *done = true; 548 *done = true;
535 return templates; 549 return templates;
536 } 550 }
537 551
538 void write(const Template &t) 552 void write(const Template &t)
539 { 553 {
540 - lines.append(metadataKey.isEmpty() ? t.file.flat() : t.file.get<QString>(metadataKey)); 554 + QString line = t.file.name;
  555 + if (!label.isEmpty())
  556 + line += " " + t.file.get<QString>(label);
  557 + lines.append(line);
541 } 558 }
542 }; 559 };
543 560
@@ -687,7 +704,9 @@ class dbGallery : public Gallery @@ -687,7 +704,9 @@ class dbGallery : public Gallery
687 if (!subset.isEmpty()) { 704 if (!subset.isEmpty()) {
688 const QStringList &words = subset.split(":"); 705 const QStringList &words = subset.split(":");
689 QtUtils::checkArgsSize("Input", words, 2, 4); 706 QtUtils::checkArgsSize("Input", words, 2, 4);
690 - seed = QtUtils::toInt(words[0]); 707 + if (words[0] == "train") seed = 0;
  708 + else if (words[0] == "test" ) seed = 1;
  709 + else seed = QtUtils::toInt(words[0]);
691 if (words[1].startsWith('{') && words[1].endsWith('}')) { 710 if (words[1].startsWith('{') && words[1].endsWith('}')) {
692 foreach (const QString &regexp, words[1].mid(1, words[1].size()-2).split(",")) 711 foreach (const QString &regexp, words[1].mid(1, words[1].size()-2).split(","))
693 metadataFields.append(QRegExp(regexp)); 712 metadataFields.append(QRegExp(regexp));
@@ -813,16 +832,10 @@ class googleGallery : public Gallery @@ -813,16 +832,10 @@ class googleGallery : public Gallery
813 return templates; 832 return templates;
814 } 833 }
815 834
816 - void write(const Template &t) 835 + void write(const Template &)
817 { 836 {
818 - (void) t;  
819 qFatal("Not supported."); 837 qFatal("Not supported.");
820 } 838 }
821 -  
822 - void init()  
823 - {  
824 - //  
825 - }  
826 }; 839 };
827 840
828 BR_REGISTER(Gallery, googleGallery) 841 BR_REGISTER(Gallery, googleGallery)
openbr/plugins/stream.cpp
@@ -1285,11 +1285,18 @@ public: @@ -1285,11 +1285,18 @@ public:
1285 qWarning("Attempted to train untrainable transform, nothing will happen."); 1285 qWarning("Attempted to train untrainable transform, nothing will happen.");
1286 return; 1286 return;
1287 } 1287 }
  1288 + QList<TemplateList> separated;
  1289 + foreach (const TemplateList & list, data) {
  1290 + foreach(const Template & t, list) {
  1291 + separated.append(TemplateList());
  1292 + separated.last().append(t);
  1293 + }
  1294 + }
1288 1295
1289 for (int i=0; i < transforms.size(); i++) { 1296 for (int i=0; i < transforms.size(); i++) {
1290 // OK we have a trainable transform, we need to get input data for it. 1297 // OK we have a trainable transform, we need to get input data for it.
1291 if (transforms[i]->trainable) { 1298 if (transforms[i]->trainable) {
1292 - QList<TemplateList> copy = data; 1299 + QList<TemplateList> copy = separated;
1293 // Project from the start to the trainable stage. 1300 // Project from the start to the trainable stage.
1294 subProject(copy,i); 1301 subProject(copy,i);
1295 1302