diff --git a/openbr/core/core.cpp b/openbr/core/core.cpp index 30efd3d..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],readMode=DistributeFrames)", NULL)); + QScopedPointer trainingWrapper(Transform::make("DirectStream([Identity], readMode=DistributeFrames)", NULL)); + CompositeTransform * downcast = dynamic_cast(trainingWrapper.data()); if (downcast == NULL) qFatal("downcast failed?"); 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/openbr_internal.h b/openbr/plugins/openbr_internal.h index 2680873..98fab50 100644 --- a/openbr/plugins/openbr_internal.h +++ b/openbr/plugins/openbr_internal.h @@ -260,9 +260,19 @@ public: newTransform = true; QString name = metaObject()->className(); + name.replace("Transform",""); - name += "([])"; + name += "([]"; + + QStringList arguments = this->arguments(); + if (!arguments.isEmpty()) { + name += ","; + name += this->arguments().join(","); + } + + name += ")"; name.replace("br::",""); + CompositeTransform * output = dynamic_cast(Transform::make(name, NULL)); if (output == NULL)