Commit ab191399edb40dcc03b2f9a57a9f458b2e1bcabe

Authored by Josh Klontz
1 parent 54a81a89

removed metadata distance

openbr/plugins/distance/metadata.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/qtutils.h>  
19 -  
20 -namespace br  
21 -{  
22 -  
23 -/*!  
24 - * \ingroup distances  
25 - * \brief Checks target metadata against query metadata.  
26 - * \author Scott Klum \cite sklum  
27 - */  
28 -class MetadataDistance : public UntrainableDistance  
29 -{  
30 - Q_OBJECT  
31 -  
32 - Q_PROPERTY(QStringList filters READ get_filters WRITE set_filters RESET reset_filters STORED false)  
33 - BR_PROPERTY(QStringList, filters, QStringList())  
34 -  
35 - float compare(const Template &a, const Template &b) const  
36 - {  
37 - foreach (const QString &key, filters) {  
38 - QString aValue = a.file.get<QString>(key, QString());  
39 - QString bValue = b.file.get<QString>(key, QString());  
40 -  
41 - // The query value may be a range. Let's check.  
42 - if (bValue.isEmpty()) bValue = QtUtils::toString(b.file.get<QPointF>(key, QPointF()));  
43 -  
44 - if (aValue.isEmpty() || bValue.isEmpty()) continue;  
45 -  
46 - bool keep = false;  
47 - bool ok;  
48 -  
49 - QPointF range = QtUtils::toPoint(bValue,&ok);  
50 -  
51 - if (ok) /* Range */ {  
52 - int value = range.x();  
53 - int upperBound = range.y();  
54 -  
55 - while (value <= upperBound) {  
56 - if (aValue == QString::number(value)) {  
57 - keep = true;  
58 - break;  
59 - }  
60 - value++;  
61 - }  
62 - }  
63 - else if (aValue == bValue) keep = true;  
64 -  
65 - if (!keep) return -std::numeric_limits<float>::max();  
66 - }  
67 - return 0;  
68 - }  
69 -};  
70 -  
71 -  
72 -BR_REGISTER(Distance, MetadataDistance)  
73 -  
74 -} // namespace br  
75 -  
76 -#include "distance/metadata.moc"