From 3f860cc99bf609824a70362eb974e20b6b3a3d51 Mon Sep 17 00:00:00 2001 From: Josh Klontz Date: Wed, 10 Apr 2013 22:34:17 -0400 Subject: [PATCH] added matrixGallery --- openbr/plugins/gallery.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+), 0 deletions(-) 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 */ -- libgit2 0.21.4