Commit 3b2c44070edb1f24bfa1b9701eca3a945d452b48
1 parent
65ab2622
New Transform to remove a meta-data field
Showing
1 changed file
with
7 additions
and
23 deletions
openbr/plugins/template.cpp
| ... | ... | @@ -52,39 +52,23 @@ BR_REGISTER(Transform, RemoveTemplatesTransform) |
| 52 | 52 | |
| 53 | 53 | /*! |
| 54 | 54 | * \ingroup transforms |
| 55 | - * \brief Filters a gallery based on the value of a metadata field. | |
| 55 | + * \brief Removes a metadata field from all templates | |
| 56 | 56 | * \author Brendan Klare \cite bklare |
| 57 | 57 | */ |
| 58 | -class FilterOnMetadataTransform : public UntrainableMetaTransform | |
| 58 | +class RemoveMetadataTransform : public UntrainableTransform | |
| 59 | 59 | { |
| 60 | 60 | Q_OBJECT |
| 61 | 61 | Q_PROPERTY(QString attributeName READ get_attributeName WRITE set_attributeName RESET reset_attributeName STORED false) |
| 62 | - Q_PROPERTY(float threshold READ get_threshold WRITE set_threshold RESET reset_threshold STORED false) | |
| 63 | - Q_PROPERTY(bool isGreaterThan READ get_isGreaterThan WRITE set_isGreaterThan RESET reset_isGreaterThan STORED false) | |
| 64 | - BR_PROPERTY(QString, attributeName, "Confidence") | |
| 65 | - BR_PROPERTY(float, threshold, 0) | |
| 66 | - BR_PROPERTY(bool, isGreaterThan, true) | |
| 67 | - | |
| 68 | - void project(const TemplateList &src, TemplateList &dst) const | |
| 69 | - { | |
| 70 | - QList<Template> filtered; | |
| 71 | - foreach (Template t, src) { | |
| 72 | - if (!t.file.contains(attributeName)) | |
| 73 | - continue; | |
| 74 | - bool pass = t.file.get<float>(attributeName) > threshold; | |
| 75 | - if (isGreaterThan ? pass : !pass) | |
| 76 | - filtered.append(t); | |
| 77 | - } | |
| 78 | - dst = TemplateList(filtered); | |
| 79 | - } | |
| 62 | + BR_PROPERTY(QString, attributeName, "None") | |
| 80 | 63 | |
| 81 | 64 | void project(const Template &src, Template &dst) const |
| 82 | 65 | { |
| 83 | - (void) src; (void) dst; qFatal("shouldn't be here"); | |
| 66 | + dst = src; | |
| 67 | + if (dst.file.contains(attributeName)) | |
| 68 | + dst.file.remove(attributeName); | |
| 84 | 69 | } |
| 85 | 70 | }; |
| 86 | - | |
| 87 | -BR_REGISTER(Transform, FilterOnMetadataTransform) | |
| 71 | +BR_REGISTER(Transform, RemoveMetadataTransform) | |
| 88 | 72 | |
| 89 | 73 | } // namespace br |
| 90 | 74 | ... | ... |