Commit dde90f19fdb244247cc6ccfa55145492a7849e4f

Authored by Josh Klontz
1 parent d022425a

Revert "added some additional functionality to turkGallery"

This reverts commit f63a47d95f731d95bc8694ba802e84ffbf9f3d1d.
openbr/core/common.h
@@ -116,24 +116,15 @@ T Max(const QList<T> &vals) @@ -116,24 +116,15 @@ T Max(const QList<T> &vals)
116 } 116 }
117 117
118 /*! 118 /*!
119 - * \brief Returns the sum of a vector of values.  
120 - */  
121 -template <template<class> class V, typename T>  
122 -double Sum(const V<T> &vals)  
123 -{  
124 - double sum = 0;  
125 - foreach (T val, vals) sum += val;  
126 - return sum;  
127 -}  
128 -  
129 -/*!  
130 * \brief Returns the mean and standard deviation of a vector of values. 119 * \brief Returns the mean and standard deviation of a vector of values.
131 */ 120 */
132 template <template<class> class V, typename T> 121 template <template<class> class V, typename T>
133 double Mean(const V<T> &vals) 122 double Mean(const V<T> &vals)
134 { 123 {
135 if (vals.isEmpty()) return 0; 124 if (vals.isEmpty()) return 0;
136 - return Sum(vals) / vals.size(); 125 + double sum = 0;
  126 + foreach (T val, vals) sum += val;
  127 + return sum / vals.size();
137 } 128 }
138 129
139 /*! 130 /*!
openbr/plugins/turk.cpp
1 #include "openbr_internal.h" 1 #include "openbr_internal.h"
2 -#include "openbr/core/common.h"  
3 #include "openbr/core/qtutils.h" 2 #include "openbr/core/qtutils.h"
4 3
5 namespace br 4 namespace br
@@ -13,10 +12,6 @@ namespace br @@ -13,10 +12,6 @@ namespace br
13 class turkGallery : public Gallery 12 class turkGallery : public Gallery
14 { 13 {
15 Q_OBJECT 14 Q_OBJECT
16 - Q_PROPERTY(bool flat READ get_flat WRITE set_flat RESET reset_flat STORED false)  
17 - Q_PROPERTY(bool normalize READ get_normalize WRITE set_normalize RESET reset_normalize STORED false)  
18 - BR_PROPERTY(bool, flat, false)  
19 - BR_PROPERTY(bool, normalize, false)  
20 15
21 struct Attribute : public QStringList 16 struct Attribute : public QStringList
22 { 17 {
@@ -28,23 +23,6 @@ class turkGallery : public Gallery @@ -28,23 +23,6 @@ class turkGallery : public Gallery
28 if (i != -1) 23 if (i != -1)
29 append(str.mid(i+1, str.length()-i-2).split(",")); 24 append(str.mid(i+1, str.length()-i-2).split(","));
30 } 25 }
31 -  
32 - Attribute normalized() const  
33 - {  
34 - bool ok;  
35 - QList<float> values;  
36 - foreach (const QString &value, *this) {  
37 - values.append(value.toFloat(&ok));  
38 - if (!ok)  
39 - qFatal("Can't normalize non-numeric vector!");  
40 - }  
41 -  
42 - Attribute normal(name);  
43 - const float sum = Common::Sum(values);  
44 - for (int i=0; i<values.size(); i++)  
45 - normal.append(QString::number(values[i] / sum));  
46 - return normal;  
47 - }  
48 }; 26 };
49 27
50 TemplateList readBlock(bool *done) 28 TemplateList readBlock(bool *done)
@@ -70,18 +48,10 @@ class turkGallery : public Gallery @@ -70,18 +48,10 @@ class turkGallery : public Gallery
70 if (type.size() != rating.size()) 48 if (type.size() != rating.size())
71 qFatal(".turk Gallery incorrect ratings count."); 49 qFatal(".turk Gallery incorrect ratings count.");
72 50
73 - if (normalize)  
74 - rating = rating.normalized();  
75 -  
76 - if (flat) {  
77 - for (int j=0; j<type.size(); j++)  
78 - f.set(type.name + "_" + type[j], rating[j]);  
79 - } else {  
80 - QMap<QString,QVariant> categoryMap;  
81 - for (int j=0; j<type.size(); j++)  
82 - categoryMap.insert(type[j], rating[j]);  
83 - f.set(type.name, categoryMap);  
84 - } 51 + QMap<QString,QVariant> categoryMap;
  52 + for (int j=0; j<type.size(); j++)
  53 + categoryMap.insert(type[j], rating[j]);
  54 + f.set(type.name, categoryMap);
85 } 55 }
86 templates.append(f); 56 templates.append(f);
87 } 57 }