Commit fbc931c834c3e44e7c999197b07d28c68cae7887

Authored by Josh Klontz
1 parent 05383a8c

better reduction support

sdk/openbr_plugin.cpp
@@ -452,6 +452,7 @@ TemplateList TemplateList::fromGallery(const br::File &gallery) @@ -452,6 +452,7 @@ TemplateList TemplateList::fromGallery(const br::File &gallery)
452 foreach (const br::File &file, gallery.split()) { 452 foreach (const br::File &file, gallery.split()) {
453 QScopedPointer<Gallery> i(Gallery::make(file)); 453 QScopedPointer<Gallery> i(Gallery::make(file));
454 TemplateList newTemplates = i->read(); 454 TemplateList newTemplates = i->read();
  455 + if (gallery.getBool("reduce")) newTemplates = newTemplates.reduced();
455 const int crossValidate = gallery.getInt("crossValidate"); 456 const int crossValidate = gallery.getInt("crossValidate");
456 if (crossValidate > 0) srand(0); 457 if (crossValidate > 0) srand(0);
457 458
sdk/openbr_plugin.h
@@ -393,6 +393,17 @@ struct TemplateList : public QList&lt;Template&gt; @@ -393,6 +393,17 @@ struct TemplateList : public QList&lt;Template&gt;
393 labelCounts[file.label()]++; 393 labelCounts[file.label()]++;
394 return labelCounts; 394 return labelCounts;
395 } 395 }
  396 +
  397 + /*!
  398 + * \brief Merge all the templates together.
  399 + */
  400 + TemplateList reduced() const
  401 + {
  402 + Template reduced;
  403 + foreach (const Template &t, *this)
  404 + reduced.merge(t);
  405 + return TemplateList() << reduced;
  406 + }
396 }; 407 };
397 408
398 /*! 409 /*!
sdk/plugins/gallery.cpp
@@ -135,7 +135,7 @@ BR_REGISTER(Gallery, EmptyGallery) @@ -135,7 +135,7 @@ BR_REGISTER(Gallery, EmptyGallery)
135 135
136 /*! 136 /*!
137 * \ingroup galleries 137 * \ingroup galleries
138 - * \brief Treats the gallery as a single image. 138 + * \brief Treats the gallery as a br::Format.
139 * \author Josh Klontz \cite jklontz 139 * \author Josh Klontz \cite jklontz
140 */ 140 */
141 class DefaultGallery : public Gallery 141 class DefaultGallery : public Gallery
@@ -150,8 +150,8 @@ class DefaultGallery : public Gallery @@ -150,8 +150,8 @@ class DefaultGallery : public Gallery
150 150
151 void write(const Template &t) 151 void write(const Template &t)
152 { 152 {
153 - QtUtils::touchDir(QFileInfo(file.name));  
154 - OpenCVUtils::saveImage(t, file.name); 153 + QScopedPointer<Format> format(Factory<Format>::make(file));
  154 + format->write(t);
155 } 155 }
156 }; 156 };
157 BR_REGISTER(Gallery, DefaultGallery) 157 BR_REGISTER(Gallery, DefaultGallery)