From 298a68aaab66a84ca2f6ef906606df3d87c59a19 Mon Sep 17 00:00:00 2001 From: Charles Otto Date: Wed, 17 Jul 2013 11:51:05 -0400 Subject: [PATCH] Traverse the transform tree using properties --- openbr/openbr_plugin.cpp | 15 +++++++++++++++ openbr/openbr_plugin.h | 10 +++++++++- openbr/plugins/meta.cpp | 6 ------ openbr/plugins/openbr_internal.h | 13 ------------- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/openbr/openbr_plugin.cpp b/openbr/openbr_plugin.cpp index 82e5e15..d33a297 100644 --- a/openbr/openbr_plugin.cpp +++ b/openbr/openbr_plugin.cpp @@ -1192,6 +1192,21 @@ void Transform::backProject(const TemplateList &dst, TemplateList &src) const futures.waitForFinished(); } +QList Transform::getChildren() +{ + QList output; + for (int i=0; i < metaObject()->propertyCount(); i++) { + const char * prop_name = metaObject()->property(i).name(); + const QVariant & variant = this->property(prop_name); + + if (variant.canConvert()) + output.append(variant.value()); + if (variant.canConvert >()) + output.append(variant.value >()); + } + return output; +} + /* Distance - public methods */ Distance *Distance::make(QString str, QObject *parent) { diff --git a/openbr/openbr_plugin.h b/openbr/openbr_plugin.h index 29f0836..702614e 100644 --- a/openbr/openbr_plugin.h +++ b/openbr/openbr_plugin.h @@ -1164,11 +1164,19 @@ public: */ virtual TemplateEvent * getEvent(const QString & name) { - (void) name; + foreach(Transform * child, getChildren()) + { + TemplateEvent * probe = child->getEvent(name); + if (probe) + return probe; + } + return NULL; } protected: + QList getChildren(); + Transform(bool independent = true, bool trainable = true); /*!< \brief Construct a transform. */ inline Transform *make(const QString &description) { return make(description, this); } /*!< \brief Make a subtransform. */ }; diff --git a/openbr/plugins/meta.cpp b/openbr/plugins/meta.cpp index 749b4d9..f00676c 100644 --- a/openbr/plugins/meta.cpp +++ b/openbr/plugins/meta.cpp @@ -615,12 +615,6 @@ public: return output; } - virtual TemplateEvent * getEvent(const QString & name) - { - return transform->getEvent(name); - } - - void train(const TemplateList &data) { transform->train(data); diff --git a/openbr/plugins/openbr_internal.h b/openbr/plugins/openbr_internal.h index 7376990..fb7a1b5 100644 --- a/openbr/plugins/openbr_internal.h +++ b/openbr/plugins/openbr_internal.h @@ -234,19 +234,6 @@ public: return output; } - virtual TemplateEvent * getEvent(const QString & name) - { - foreach(Transform* t, transforms ) - { - TemplateEvent * probe = t->getEvent(name); - if (probe) - return probe; - } - - return NULL; - } - - protected: bool isTimeVarying; -- libgit2 0.21.4