diff --git a/openbr/plugins/gallery.cpp b/openbr/plugins/gallery.cpp index f0bb614..7c2f17b 100644 --- a/openbr/plugins/gallery.cpp +++ b/openbr/plugins/gallery.cpp @@ -212,10 +212,52 @@ class DefaultGallery : public Gallery format->write(t); } }; + BR_REGISTER(Gallery, DefaultGallery) /*! * \ingroup galleries + * \brief Combine all templates into one large matrix and process it as a br::Format + * \author Josh Klontz \cite jklontz + */ +class matrixGallery : public Gallery +{ + Q_OBJECT + Q_PROPERTY(const QString extension READ get_extension WRITE set_extension RESET reset_extension STORED false) + BR_PROPERTY(QString, extension, "mtx") + + TemplateList templates; + + ~matrixGallery() + { + if (templates.isEmpty()) + return; + + QScopedPointer format(Factory::make(getFormat())); + format->write(Template(file, OpenCVUtils::toMat(templates.data()))); + } + + File getFormat() const + { + return file.name.left(file.name.size() - file.suffix().size()) + extension; + } + + TemplateList readBlock(bool *done) + { + *done = true; + return TemplateList() << getFormat(); + } + + void write(const Template &t) + { + templates.append(t); + } +}; + +BR_REGISTER(Gallery, matrixGallery) + +/*! + * \ingroup galleries * \brief Treat a video as a gallery, making a single template from each frame * \author Charles Otto \cite caotto */