Commit eeca8e29c34da23523fdf7a31ac72275648ae9d8

Authored by Josh Klontz
1 parent 9a4f7be7

remove turk gallery

Showing 1 changed file with 0 additions and 105 deletions
openbr/plugins/gallery/turk.cpp deleted
1 -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
2 - * Copyright 2012 The MITRE Corporation *  
3 - * *  
4 - * Licensed under the Apache License, Version 2.0 (the "License"); *  
5 - * you may not use this file except in compliance with the License. *  
6 - * You may obtain a copy of the License at *  
7 - * *  
8 - * http://www.apache.org/licenses/LICENSE-2.0 *  
9 - * *  
10 - * Unless required by applicable law or agreed to in writing, software *  
11 - * distributed under the License is distributed on an "AS IS" BASIS, *  
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *  
13 - * See the License for the specific language governing permissions and *  
14 - * limitations under the License. *  
15 - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */  
16 -  
17 -#include <openbr/plugins/openbr_internal.h>  
18 -#include <openbr/core/common.h>  
19 -#include <openbr/core/qtutils.h>  
20 -  
21 -namespace br  
22 -{  
23 -  
24 -/*!  
25 - * \ingroup galleries  
26 - * \brief For Amazon Mechanical Turk datasets  
27 - * \author Scott Klum \cite sklum  
28 - */  
29 -class turkGallery : public Gallery  
30 -{  
31 - Q_OBJECT  
32 -  
33 - struct Attribute : public QStringList  
34 - {  
35 - QString name;  
36 - Attribute(const QString &str = QString())  
37 - {  
38 - const int i = str.indexOf('[');  
39 - name = str.mid(0, i);  
40 - if (i != -1)  
41 - append(str.mid(i+1, str.length()-i-2).split(","));  
42 - }  
43 -  
44 - Attribute normalized() const  
45 - {  
46 - bool ok;  
47 - QList<float> values;  
48 - foreach (const QString &value, *this) {  
49 - values.append(value.toFloat(&ok));  
50 - if (!ok)  
51 - qFatal("Can't normalize non-numeric vector!");  
52 - }  
53 -  
54 - Attribute normal(name);  
55 - float sum = Common::Sum(values);  
56 - if (sum == 0) sum = 1;  
57 - for (int i=0; i<values.size(); i++)  
58 - normal.append(QString::number(values[i] / sum));  
59 - return normal;  
60 - }  
61 - };  
62 -  
63 - TemplateList readBlock(bool *done)  
64 - {  
65 - *done = true;  
66 - QStringList lines = QtUtils::readLines(file);  
67 - QList<Attribute> headers;  
68 - if (!lines.isEmpty())  
69 - foreach (const QString &header, parse(lines.takeFirst()))  
70 - headers.append(header);  
71 -  
72 - TemplateList templates;  
73 - foreach (const QString &line, lines) {  
74 - QStringList words = parse(line);  
75 - if (words.size() != headers.size())  
76 - qFatal("turkGallery invalid column count");  
77 -  
78 - File f;  
79 - f.name = words[0];  
80 - f.set("Label", words[0].mid(0,5));  
81 -  
82 - for (int i=1; i<words.size(); i++) {  
83 - Attribute ratings = Attribute(words[i]).normalized();  
84 - if (headers[i].size() != ratings.size())  
85 - qFatal("turkGallery invalid attribute count");  
86 - for (int j=0; j<ratings.size(); j++)  
87 - f.set(headers[i].name + "_" + headers[i][j], ratings[j]);  
88 - }  
89 - templates.append(f);  
90 - }  
91 -  
92 - return templates;  
93 - }  
94 -  
95 - void write(const Template &)  
96 - {  
97 - qFatal("turkGallery write not implemented.");  
98 - }  
99 -};  
100 -  
101 -BR_REGISTER(Gallery, turkGallery)  
102 -  
103 -} // namespace br  
104 -  
105 -#include "gallery/turk.moc"