From 91eff7dd38b595f097b07e7d35b698005218ce8a Mon Sep 17 00:00:00 2001 From: Scott Klum Date: Sat, 1 Mar 2014 10:19:43 -0500 Subject: [PATCH] Refactored from gallery a bit --- openbr/openbr_plugin.cpp | 62 ++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/openbr/openbr_plugin.cpp b/openbr/openbr_plugin.cpp index 91c4d70..d5b56bf 100644 --- a/openbr/openbr_plugin.cpp +++ b/openbr/openbr_plugin.cpp @@ -392,42 +392,41 @@ TemplateList TemplateList::fromGallery(const br::File &gallery) const int crossValidate = gallery.get("crossValidate"); - if (gallery.getBool("leaveOneImageOut")) { - QStringList labels; - for (int i=newTemplates.size()-1; i>=0; i--) { + for (int i=newTemplates.size()-1; i>=0; i--) { newTemplates[i].file.set("Index", i+templates.size()); newTemplates[i].file.set("Gallery", gallery.name); - QString label = newTemplates.at(i).file.get("Label"); - // Have we seen this subject before? - if (!labels.contains(label)) { - labels.append(label); - // Get indices belonging to this subject - QList labelIndices = newTemplates.find("Label",label); - for (int j = 0; j < labelIndices.size(); j++) { - // Set subject partitions - newTemplates[labelIndices[j]].file.set("Partition",j%crossValidate); - } - // Extend the gallery for each partition - for (int j=0; j("Partition")) { - leaveOneImageOutTemplate.file.set("Partition", k); - leaveOneImageOutTemplate.file.set("testOnly", true); - newTemplates.insert(i+1,leaveOneImageOutTemplate); + if (crossValidate > 0) { + if (gallery.getBool("leaveOneImageOut")) { + QStringList labels; + for (int i=newTemplates.size()-1; i>=0; i--) { + newTemplates[i].file.set("Index", i+templates.size()); + newTemplates[i].file.set("Gallery", gallery.name); + + QString label = newTemplates.at(i).file.get("Label"); + // Have we seen this subject before? + if (!labels.contains(label)) { + labels.append(label); + // Get indices belonging to this subject + QList labelIndices = newTemplates.find("Label",label); + for (int j = 0; j < labelIndices.size(); j++) { + // Set subject partitions + newTemplates[labelIndices[j]].file.set("Partition",j%crossValidate); + } + // Extend the gallery for each partition + for (int j=0; j("Partition")) { + leaveOneImageOutTemplate.file.set("Partition", k); + leaveOneImageOutTemplate.file.set("testOnly", true); + newTemplates.insert(i+1,leaveOneImageOutTemplate); + } + } + } } } - } - } - } - } else { - for (int i=newTemplates.size()-1; i>=0; i--) { - newTemplates[i].file.set("Index", i+templates.size()); - newTemplates[i].file.set("Gallery", gallery.name); - - if (crossValidate > 0) { - if (newTemplates[i].file.getBool("duplicatePartitions")) { + } else if (newTemplates[i].file.getBool("duplicatePartitions")) { // The duplicatePartitions flag is used to add target images // crossValidate times to the simmat/mask // when multiple training sets are being used @@ -454,7 +453,6 @@ TemplateList TemplateList::fromGallery(const br::File &gallery) } } } - } } if (!templates.isEmpty() && gallery.get("merge", false)) { -- libgit2 0.21.4