Commit aaf27b692cb2f3d786d3247923873dc134b344fb

Authored by Charles Otto
1 parent de26fcbb

Move default train implementations to openbr_plugin.cpp

openbr/openbr_plugin.cpp
@@ -1225,6 +1225,26 @@ TemplateEvent * Transform::getEvent(const QString & name) @@ -1225,6 +1225,26 @@ TemplateEvent * Transform::getEvent(const QString & name)
1225 return NULL; 1225 return NULL;
1226 } 1226 }
1227 1227
  1228 +void Transform::train(const TemplateList &data)
  1229 +{
  1230 + if (!trainable) {
  1231 + qWarning("Train called on untrainable transform %s", this->metaObject()->className());
  1232 + return;
  1233 + }
  1234 + QList<TemplateList> input;
  1235 + input.append(data);
  1236 + train(input);
  1237 +}
  1238 +
  1239 +void Transform::train(const QList<TemplateList> &data)
  1240 +{
  1241 + TemplateList combined;
  1242 + foreach(const TemplateList & set, data) {
  1243 + combined.append(set);
  1244 + }
  1245 + train(combined);
  1246 +}
  1247 +
1228 /* Distance - public methods */ 1248 /* Distance - public methods */
1229 Distance *Distance::make(QString str, QObject *parent) 1249 Distance *Distance::make(QString str, QObject *parent)
1230 { 1250 {
openbr/openbr_plugin.h
@@ -1074,6 +1074,9 @@ public: @@ -1074,6 +1074,9 @@ public:
1074 1074
1075 virtual Transform *clone() const; /*!< \brief Copy the transform. */ 1075 virtual Transform *clone() const; /*!< \brief Copy the transform. */
1076 1076
  1077 + /*!< \brief Train the transform. */
  1078 + virtual void train(const TemplateList &data);
  1079 +
1077 /*!< \brief Train the transform, separate list items represent the way calls to project would be broken up 1080 /*!< \brief Train the transform, separate list items represent the way calls to project would be broken up
1078 * Transforms that have to call train on another transform should implement train(QList), the strucutre of the 1081 * Transforms that have to call train on another transform should implement train(QList), the strucutre of the
1079 * list should mirror the calls that would be made to project by the parent transform. For example, DistributeTemplates 1082 * list should mirror the calls that would be made to project by the parent transform. For example, DistributeTemplates
@@ -1082,26 +1085,7 @@ public: @@ -1082,26 +1085,7 @@ public:
1082 * This version of train(QList) is appropriate for transforms that perform training on themselves, and don't call train 1085 * This version of train(QList) is appropriate for transforms that perform training on themselves, and don't call train
1083 * on other transforms. It combines everything in data into a single TemplateList, then calls train(TemplateList) 1086 * on other transforms. It combines everything in data into a single TemplateList, then calls train(TemplateList)
1084 */ 1087 */
1085 - virtual void train(const QList<TemplateList> &data)  
1086 - {  
1087 - TemplateList combined;  
1088 - foreach(const TemplateList & set, data) {  
1089 - combined.append(set);  
1090 - }  
1091 - train(combined);  
1092 - }  
1093 -  
1094 - /*!< \brief Train the transform. */  
1095 - virtual void train(const TemplateList &data)  
1096 - {  
1097 - if (!trainable) {  
1098 - qWarning("Train called on untrainable transform %s", this->metaObject()->className());  
1099 - return;  
1100 - }  
1101 - QList<TemplateList> input;  
1102 - input.append(data);  
1103 - train(input);  
1104 - } 1088 + virtual void train(const QList<TemplateList> &data);
1105 1089
1106 /*!< \brief Apply the transform to a single template. Typically used by independent transforms */ 1090 /*!< \brief Apply the transform to a single template. Typically used by independent transforms */
1107 virtual void project(const Template &src, Template &dst) const = 0; 1091 virtual void project(const Template &src, Template &dst) const = 0;