From 2fee7df6549b4612cf2891cf5c7d614332711a7e Mon Sep 17 00:00:00 2001 From: Scott Klum Date: Wed, 15 Apr 2015 09:30:50 -0400 Subject: [PATCH] Added ListDistance --- openbr/plugins/distance/fuse.cpp | 12 +----------- openbr/plugins/distance/pipe.cpp | 12 +----------- openbr/plugins/distance/sum.cpp | 12 +----------- openbr/plugins/openbr_internal.h | 20 ++++++++++++++++++++ 4 files changed, 23 insertions(+), 33 deletions(-) diff --git a/openbr/plugins/distance/fuse.cpp b/openbr/plugins/distance/fuse.cpp index 9fb8f55..b2c38cd 100644 --- a/openbr/plugins/distance/fuse.cpp +++ b/openbr/plugins/distance/fuse.cpp @@ -29,11 +29,10 @@ namespace br * \author Scott Klum \cite sklum * \note Operation: Mean, sum, min, max are supported. */ -class FuseDistance : public Distance +class FuseDistance : public ListDistance { Q_OBJECT Q_ENUMS(Operation) - Q_PROPERTY(QList distances READ get_distances WRITE set_distances RESET reset_distances) Q_PROPERTY(Operation operation READ get_operation WRITE set_operation RESET reset_operation STORED false) Q_PROPERTY(QList weights READ get_weights WRITE set_weights RESET reset_weights STORED false) @@ -42,18 +41,9 @@ public: enum Operation {Mean, Sum, Max, Min}; private: - BR_PROPERTY(QList, distances, QList()) BR_PROPERTY(Operation, operation, Mean) BR_PROPERTY(QList, weights, QList()) - bool trainable() - { - for (int i=0; itrainable()) - return true; - return false; - } - void train(const TemplateList &src) { // Partition the templates by matrix diff --git a/openbr/plugins/distance/pipe.cpp b/openbr/plugins/distance/pipe.cpp index 1548815..123d681 100644 --- a/openbr/plugins/distance/pipe.cpp +++ b/openbr/plugins/distance/pipe.cpp @@ -30,19 +30,9 @@ namespace br * If the result of the comparison with any given distance is -FLOAT_MAX then this result is returned early. * Otherwise the returned result is the value of comparing the templates using the last br::Distance. */ -class PipeDistance : public Distance +class PipeDistance : public ListDistance { Q_OBJECT - Q_PROPERTY(QList distances READ get_distances WRITE set_distances RESET reset_distances) - BR_PROPERTY(QList, distances, QList()) - - bool trainable() - { - for (int i=0; itrainable()) - return true; - return false; - } void train(const TemplateList &data) { diff --git a/openbr/plugins/distance/sum.cpp b/openbr/plugins/distance/sum.cpp index f6e2865..29c273b 100644 --- a/openbr/plugins/distance/sum.cpp +++ b/openbr/plugins/distance/sum.cpp @@ -26,19 +26,9 @@ namespace br * \brief Sum match scores across multiple distances * \author Scott Klum \cite sklum */ -class SumDistance : public Distance +class SumDistance : public ListDistance { Q_OBJECT - Q_PROPERTY(QList distances READ get_distances WRITE set_distances RESET reset_distances) - BR_PROPERTY(QList, distances, QList()) - - bool trainable() - { - for (int i=0; itrainable()) - return true; - return false; - } void train(const TemplateList &data) { diff --git a/openbr/plugins/openbr_internal.h b/openbr/plugins/openbr_internal.h index fa9e3c6..08cb026 100644 --- a/openbr/plugins/openbr_internal.h +++ b/openbr/plugins/openbr_internal.h @@ -485,6 +485,26 @@ private: void train(const TemplateList &data) { (void) data; } }; +/*! + * \brief A br::Distance that does not require training data. + */ +class BR_EXPORT ListDistance : public Distance +{ + Q_OBJECT + +public: + Q_PROPERTY(QList distances READ get_distances WRITE set_distances RESET reset_distances) + BR_PROPERTY(QList, distances, QList()) + + bool trainable() + { + for (int i=0; itrainable()) + return true; + return false; + } +}; + } #endif // OPENBR_INTERNAL_H -- libgit2 0.21.4