Commit 3f860cc99bf609824a70362eb974e20b6b3a3d51
1 parent
331ac40a
added matrixGallery
Showing
1 changed file
with
42 additions
and
0 deletions
openbr/plugins/gallery.cpp
| ... | ... | @@ -212,10 +212,52 @@ class DefaultGallery : public Gallery |
| 212 | 212 | format->write(t); |
| 213 | 213 | } |
| 214 | 214 | }; |
| 215 | + | |
| 215 | 216 | BR_REGISTER(Gallery, DefaultGallery) |
| 216 | 217 | |
| 217 | 218 | /*! |
| 218 | 219 | * \ingroup galleries |
| 220 | + * \brief Combine all templates into one large matrix and process it as a br::Format | |
| 221 | + * \author Josh Klontz \cite jklontz | |
| 222 | + */ | |
| 223 | +class matrixGallery : public Gallery | |
| 224 | +{ | |
| 225 | + Q_OBJECT | |
| 226 | + Q_PROPERTY(const QString extension READ get_extension WRITE set_extension RESET reset_extension STORED false) | |
| 227 | + BR_PROPERTY(QString, extension, "mtx") | |
| 228 | + | |
| 229 | + TemplateList templates; | |
| 230 | + | |
| 231 | + ~matrixGallery() | |
| 232 | + { | |
| 233 | + if (templates.isEmpty()) | |
| 234 | + return; | |
| 235 | + | |
| 236 | + QScopedPointer<Format> format(Factory<Format>::make(getFormat())); | |
| 237 | + format->write(Template(file, OpenCVUtils::toMat(templates.data()))); | |
| 238 | + } | |
| 239 | + | |
| 240 | + File getFormat() const | |
| 241 | + { | |
| 242 | + return file.name.left(file.name.size() - file.suffix().size()) + extension; | |
| 243 | + } | |
| 244 | + | |
| 245 | + TemplateList readBlock(bool *done) | |
| 246 | + { | |
| 247 | + *done = true; | |
| 248 | + return TemplateList() << getFormat(); | |
| 249 | + } | |
| 250 | + | |
| 251 | + void write(const Template &t) | |
| 252 | + { | |
| 253 | + templates.append(t); | |
| 254 | + } | |
| 255 | +}; | |
| 256 | + | |
| 257 | +BR_REGISTER(Gallery, matrixGallery) | |
| 258 | + | |
| 259 | +/*! | |
| 260 | + * \ingroup galleries | |
| 219 | 261 | * \brief Treat a video as a gallery, making a single template from each frame |
| 220 | 262 | * \author Charles Otto \cite caotto |
| 221 | 263 | */ | ... | ... |