Commit 2b9685aeb3dcb3ca43049ac2b0eb953b7b6b461d

Authored by Scott Klum
1 parent 3b89cb25

Updated if to consider the condition false if no metadata exists

Showing 1 changed file with 3 additions and 4 deletions
openbr/plugins/imgproc/if.cpp
@@ -51,14 +51,14 @@ public: @@ -51,14 +51,14 @@ public:
51 if (transform->trainable) { 51 if (transform->trainable) {
52 TemplateList passed; 52 TemplateList passed;
53 for (int i=0; i<data.size(); i++) 53 for (int i=0; i<data.size(); i++)
54 - if (compare(data[i].file.get<QString>(key))) 54 + if (data[i].file.contains(key) && compare(data[i].file.get<QString>(key)))
55 passed.append(data[i]); 55 passed.append(data[i]);
56 transform->train(passed); 56 transform->train(passed);
57 } 57 }
58 } 58 }
59 59
60 void project(const Template &src, Template &dst) const { 60 void project(const Template &src, Template &dst) const {
61 - if (compare(src.file.get<QString>(key))) 61 + if (src.file.contains(key) && compare(src.file.get<QString>(key)))
62 transform->project(src,dst); 62 transform->project(src,dst);
63 else 63 else
64 dst = src; 64 dst = src;
@@ -67,7 +67,7 @@ public: @@ -67,7 +67,7 @@ public:
67 void project(const TemplateList &src, TemplateList &dst) const { 67 void project(const TemplateList &src, TemplateList &dst) const {
68 TemplateList ifTrue, ifFalse; 68 TemplateList ifTrue, ifFalse;
69 foreach (const Template &t, src) { 69 foreach (const Template &t, src) {
70 - if (compare(t.file.get<QString>(key))) 70 + if (t.file.contains(key) && compare(t.file.get<QString>(key)))
71 ifTrue.append(t); 71 ifTrue.append(t);
72 else 72 else
73 ifFalse.append(t); 73 ifFalse.append(t);
@@ -83,4 +83,3 @@ BR_REGISTER(Transform, IfTransform) @@ -83,4 +83,3 @@ BR_REGISTER(Transform, IfTransform)
83 } // namespace br 83 } // namespace br
84 84
85 #include "imgproc/if.moc" 85 #include "imgproc/if.moc"
86 -