Commit c8c71156d1b4617125d4eaf3d8aef35f41a47eea
1 parent
5b3c7a8e
Removed redundant code in DisplayGUI
Showing
2 changed files
with
17 additions
and
23 deletions
openbr/plugins/format.cpp
| @@ -706,8 +706,21 @@ class xmlFormat : public Format | @@ -706,8 +706,21 @@ class xmlFormat : public Format | ||
| 706 | 706 | ||
| 707 | void write(const Template &t) const | 707 | void write(const Template &t) const |
| 708 | { | 708 | { |
| 709 | - (void) t; | ||
| 710 | - qFatal("Not supported."); | 709 | + QStringList lines; |
| 710 | + lines.append("<?xml version=\"1.0\" standalone=\"yes\"?>"); | ||
| 711 | + lines.append("<openbr-xml-format>"); | ||
| 712 | + lines.append("\t<xml-data>"); | ||
| 713 | + foreach (const QString &key, t.file.localKeys()) { | ||
| 714 | + if ((key == "Index") || (key == "Label")) continue; | ||
| 715 | + lines.append("\t\t<"+key+">"+QtUtils::toString(t.file.value(key))+"</"+key+">"); | ||
| 716 | + } | ||
| 717 | + std::vector<uchar> data; | ||
| 718 | + imencode(".jpg",t.m(),data); | ||
| 719 | + QByteArray byteArray = QByteArray::fromRawData((const char*)data.data(), data.size()); | ||
| 720 | + lines.append("\t\t<FORMAL_IMG>"+byteArray.toBase64()+"</FORMAL_IMG>"); | ||
| 721 | + lines.append("\t</xml-data>"); | ||
| 722 | + lines.append("</openbr-xml-format>"); | ||
| 723 | + QtUtils::writeFile(file, lines); | ||
| 711 | } | 724 | } |
| 712 | }; | 725 | }; |
| 713 | 726 |
openbr/plugins/gui.cpp
| @@ -523,33 +523,26 @@ BR_REGISTER(Transform, ManualTransform) | @@ -523,33 +523,26 @@ BR_REGISTER(Transform, ManualTransform) | ||
| 523 | * \brief Elicits metadata for templates in a pretty GUI | 523 | * \brief Elicits metadata for templates in a pretty GUI |
| 524 | * \author Scott Klum \cite sklum | 524 | * \author Scott Klum \cite sklum |
| 525 | */ | 525 | */ |
| 526 | -class ElicitTransform : public TimeVaryingTransform | 526 | +class ElicitTransform : public ShowTransform |
| 527 | { | 527 | { |
| 528 | Q_PROPERTY(QStringList keys READ get_keys WRITE set_keys RESET reset_keys STORED false) | 528 | Q_PROPERTY(QStringList keys READ get_keys WRITE set_keys RESET reset_keys STORED false) |
| 529 | BR_PROPERTY(QStringList, keys, QStringList()) | 529 | BR_PROPERTY(QStringList, keys, QStringList()) |
| 530 | 530 | ||
| 531 | Q_OBJECT | 531 | Q_OBJECT |
| 532 | 532 | ||
| 533 | - MainThreadCreator creator; | ||
| 534 | DisplayGUI *gui; | 533 | DisplayGUI *gui; |
| 535 | - QImage qImageBuffer; | ||
| 536 | - QPixmap *displayBuffer; | ||
| 537 | 534 | ||
| 538 | public: | 535 | public: |
| 539 | - ElicitTransform() : TimeVaryingTransform(false, false) | 536 | + ElicitTransform() : ShowTransform() |
| 540 | { | 537 | { |
| 541 | - displayBuffer = NULL; | ||
| 542 | gui = NULL; | 538 | gui = NULL; |
| 543 | } | 539 | } |
| 544 | 540 | ||
| 545 | ~ElicitTransform() | 541 | ~ElicitTransform() |
| 546 | { | 542 | { |
| 547 | - delete displayBuffer; | ||
| 548 | delete gui; | 543 | delete gui; |
| 549 | } | 544 | } |
| 550 | 545 | ||
| 551 | - void train(const TemplateList &data) { (void) data; } | ||
| 552 | - | ||
| 553 | void project(const TemplateList &src, TemplateList &dst) const | 546 | void project(const TemplateList &src, TemplateList &dst) const |
| 554 | { | 547 | { |
| 555 | Transform * non_const = (ElicitTransform *) this; | 548 | Transform * non_const = (ElicitTransform *) this; |
| @@ -575,12 +568,6 @@ public: | @@ -575,12 +568,6 @@ public: | ||
| 575 | } | 568 | } |
| 576 | } | 569 | } |
| 577 | 570 | ||
| 578 | - void finalize(TemplateList & output) | ||
| 579 | - { | ||
| 580 | - (void) output; | ||
| 581 | - emit hideWindow(); | ||
| 582 | - } | ||
| 583 | - | ||
| 584 | void init() | 571 | void init() |
| 585 | { | 572 | { |
| 586 | initActual<DisplayGUI>(); | 573 | initActual<DisplayGUI>(); |
| @@ -608,12 +595,6 @@ public: | @@ -608,12 +595,6 @@ public: | ||
| 608 | connect(this, SIGNAL(updateImage(QPixmap)), gui,SLOT(showImage(QPixmap))); | 595 | connect(this, SIGNAL(updateImage(QPixmap)), gui,SLOT(showImage(QPixmap))); |
| 609 | connect(this, SIGNAL(hideWindow()), gui, SLOT(hide())); | 596 | connect(this, SIGNAL(hideWindow()), gui, SLOT(hide())); |
| 610 | } | 597 | } |
| 611 | - | ||
| 612 | -signals: | ||
| 613 | - | ||
| 614 | - void updateImage(const QPixmap & input); | ||
| 615 | - void hideWindow(); | ||
| 616 | - | ||
| 617 | }; | 598 | }; |
| 618 | BR_REGISTER(Transform, ElicitTransform) | 599 | BR_REGISTER(Transform, ElicitTransform) |
| 619 | 600 |