Commit cabb12d4c5cd9f0bcb6bbc066b5077ea94bd4cf9
1 parent
05f974da
Helper transform to write current mat as image on disk
Showing
1 changed file
with
33 additions
and
0 deletions
openbr/plugins/draw.cpp
| @@ -527,6 +527,39 @@ class DrawSegmentation : public UntrainableTransform | @@ -527,6 +527,39 @@ class DrawSegmentation : public UntrainableTransform | ||
| 527 | }; | 527 | }; |
| 528 | BR_REGISTER(Transform, DrawSegmentation) | 528 | BR_REGISTER(Transform, DrawSegmentation) |
| 529 | 529 | ||
| 530 | +/*! | ||
| 531 | + * \ingroup transforms | ||
| 532 | + * \brief Write all mats to disk as images. | ||
| 533 | + * \author Brendan Klare \bklare | ||
| 534 | + */ | ||
| 535 | +class WriteImageTransform : public TimeVaryingTransform | ||
| 536 | +{ | ||
| 537 | + Q_OBJECT | ||
| 538 | + Q_PROPERTY(QString outputDirectory READ get_outputDirectory WRITE set_outputDirectory RESET reset_outputDirectory STORED false) | ||
| 539 | + Q_PROPERTY(QString imageName READ get_imageName WRITE set_imageName RESET reset_imageName STORED false) | ||
| 540 | + Q_PROPERTY(QString imgExtension READ get_imgExtension WRITE set_imgExtension RESET reset_imgExtension STORED false) | ||
| 541 | + BR_PROPERTY(QString, outputDirectory, "Temp") | ||
| 542 | + BR_PROPERTY(QString, imageName, "image") | ||
| 543 | + BR_PROPERTY(QString, imgExtension, "jpg") | ||
| 544 | + | ||
| 545 | + int cnt; | ||
| 546 | + | ||
| 547 | + void init() { | ||
| 548 | + cnt = 0; | ||
| 549 | + if (! QDir(outputDirectory).exists()) | ||
| 550 | + QDir().mkdir(outputDirectory); | ||
| 551 | + } | ||
| 552 | + | ||
| 553 | + void projectUpdate(const Template &src, Template &dst) | ||
| 554 | + { | ||
| 555 | + dst = src; | ||
| 556 | + OpenCVUtils::saveImage(dst.m(), QString("%1/%2_%3.%4").arg(outputDirectory).arg(imageName).arg(cnt++, 5, QChar('0')).arg(imgExtension)); | ||
| 557 | +qDebug() << "AT " << cnt; | ||
| 558 | + } | ||
| 559 | + | ||
| 560 | +}; | ||
| 561 | +BR_REGISTER(Transform, WriteImageTransform) | ||
| 562 | + | ||
| 530 | // TODO: re-implement EditTransform using Qt | 563 | // TODO: re-implement EditTransform using Qt |
| 531 | #if 0 | 564 | #if 0 |
| 532 | /*! | 565 | /*! |