diff --git a/openbr/core/core.cpp b/openbr/core/core.cpp index 6b52578..13b4ae3 100644 --- a/openbr/core/core.cpp +++ b/openbr/core/core.cpp @@ -45,7 +45,8 @@ struct AlgorithmCore qDebug("Training on %s%s", qPrintable(input.flat()), model.isEmpty() ? "" : qPrintable(" to " + model)); - QScopedPointer trainingWrapper(Transform::make("DirectStream([Identity])", NULL)); + QScopedPointer trainingWrapper(Transform::make("DirectStream([Identity], readMode=DistributeFrames)", NULL)); + CompositeTransform * downcast = dynamic_cast(trainingWrapper.data()); if (downcast == NULL) qFatal("downcast failed?"); @@ -70,7 +71,7 @@ struct AlgorithmCore if (!distance.isNull()) { qDebug("Projecting Enrollment"); - data >> *downcast; + downcast->projectUpdate(data,data); qDebug("Training Comparison"); distance->train(data); diff --git a/openbr/openbr.cpp b/openbr/openbr.cpp index 067334b..13c648f 100644 --- a/openbr/openbr.cpp +++ b/openbr/openbr.cpp @@ -353,6 +353,17 @@ void br_set_filename(br_template tmpl, const char *filename) t->file.name = filename; } +const char* br_get_metadata_string(br_template tmpl, const char *key) +{ + Template *t = reinterpret_cast(tmpl); + // need an object outside of this scope + // so the char pointer is valid + static QByteArray result; + QVariant qvar = t->file.value(key); + result = QtUtils::toString(qvar).toUtf8(); + return result.data(); +} + br_template_list br_enroll_template(br_template tmpl) { Template *t = reinterpret_cast(tmpl); diff --git a/openbr/openbr.h b/openbr/openbr.h index 64d5be4..6050a1f 100644 --- a/openbr/openbr.h +++ b/openbr/openbr.h @@ -475,6 +475,10 @@ BR_EXPORT bool br_img_is_empty(br_template tmpl); */ BR_EXPORT void br_set_filename(br_template tmpl, const char *filename); /*! + * \brief Get metadata as a string for the given key in the given template. + */ +BR_EXPORT const char* br_get_metadata_string(br_template, const char *key); +/*! * \brief Enroll a br::Template from the C API! Returns a pointer to a br::TemplateList * \param tmpl Pointer to a br::Template. */ diff --git a/openbr/openbr_plugin.cpp b/openbr/openbr_plugin.cpp index 09a9e56..f36780f 100644 --- a/openbr/openbr_plugin.cpp +++ b/openbr/openbr_plugin.cpp @@ -550,20 +550,18 @@ QStringList Object::parameters() const for (int i = firstAvailablePropertyIdx; i < metaObject()->propertyCount();i++) { QMetaProperty property = metaObject()->property(i); - if (property.isStored(this)) continue; parameters.append(QString("%1 %2 = %3").arg(property.typeName(), property.name(), property.read(this).toString())); } + return parameters; } QStringList Object::arguments() const { QStringList arguments; - for (int i=metaObject()->propertyOffset(); ipropertyCount(); i++) { - QMetaProperty property = metaObject()->property(i); - if (property.isStored(this)) continue; + for (int i=metaObject()->propertyOffset(); ipropertyCount(); i++) arguments.append(argument(i)); - } + return arguments; } @@ -705,7 +703,14 @@ void Object::setProperty(const QString &name, QVariant value) int index = metaObject()->indexOfProperty(qPrintable(name)); if (index != -1) type = metaObject()->property(index).typeName(); - if ((type.startsWith("QList<") && type.endsWith(">")) || (type == "QStringList")) { + if (metaObject()->property(index).isEnumType()) { + // This is necessary because setProperty can only set enums + // using their integer value if the QVariant is of type int (or uint) + bool ok; + int v = value.toInt(&ok); + if (ok) + value = v; + } else if ((type.startsWith("QList<") && type.endsWith(">")) || (type == "QStringList")) { QVariantList elements; if (value.canConvert()) { elements = value.value(); @@ -766,8 +771,8 @@ void Object::setProperty(const QString &name, QVariant value) } if (!QObject::setProperty(qPrintable(name), value) && !type.isEmpty()) - qFatal("Failed to set %s::%s to: %s", - metaObject()->className(), qPrintable(name), qPrintable(value.toString())); + qFatal("Failed to set %s %s::%s to: %s", + qPrintable(type), metaObject()->className(), qPrintable(name), qPrintable(value.toString())); } QStringList Object::parse(const QString &string, char split) diff --git a/openbr/plugins/meta.cpp b/openbr/plugins/meta.cpp index bbf6c68..c713c98 100644 --- a/openbr/plugins/meta.cpp +++ b/openbr/plugins/meta.cpp @@ -717,42 +717,6 @@ public: }; BR_REGISTER(Transform, DistributeTemplateTransform) -/*! - * \ingroup transforms - * \brief Filters a gallery based on the value of a metadata field. - * \author Brendan Klare \cite bklare - */ -class FilterOnMetadataTransform : public UntrainableMetaTransform -{ - Q_OBJECT - Q_PROPERTY(QString attributeName READ get_attributeName WRITE set_attributeName RESET reset_attributeName STORED false) - Q_PROPERTY(float threshold READ get_threshold WRITE set_threshold RESET reset_threshold STORED false) - Q_PROPERTY(bool isGreaterThan READ get_isGreaterThan WRITE set_isGreaterThan RESET reset_isGreaterThan STORED false) - BR_PROPERTY(QString, attributeName, "Confidence") - BR_PROPERTY(float, threshold, 0) - BR_PROPERTY(bool, isGreaterThan, true) - - void project(const TemplateList &src, TemplateList &dst) const - { - QList