Commit bd31789dc16ca53b5be191c0b274e99c2d001e6f

Authored by Josh Klontz
1 parent dbad1bf2

remove imposteruniquenessmeasure

openbr/plugins/metadata/imposteruniquenessmeasure.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   -
20   -namespace br
21   -{
22   -
23   -/*!
24   - * \ingroup transforms
25   - * \brief Impostor Uniqueness Measure
26   - * \author Josh Klontz \cite jklontz
27   - */
28   -class ImpostorUniquenessMeasureTransform : public Transform
29   -{
30   - Q_OBJECT
31   - Q_PROPERTY(br::Distance* distance READ get_distance WRITE set_distance RESET reset_distance STORED false)
32   - Q_PROPERTY(double mean READ get_mean WRITE set_mean RESET reset_mean)
33   - Q_PROPERTY(double stddev READ get_stddev WRITE set_stddev RESET reset_stddev)
34   - Q_PROPERTY(QString inputVariable READ get_inputVariable WRITE set_inputVariable RESET reset_inputVariable STORED false)
35   - BR_PROPERTY(br::Distance*, distance, Distance::make("Dist(L2)", this))
36   - BR_PROPERTY(double, mean, 0)
37   - BR_PROPERTY(double, stddev, 1)
38   - BR_PROPERTY(QString, inputVariable, "Label")
39   -
40   - TemplateList impostors;
41   -
42   - float calculateIUM(const Template &probe, const TemplateList &gallery) const
43   - {
44   - const QString probeLabel = probe.file.get<QString>(inputVariable);
45   - TemplateList subset = gallery;
46   - for (int j=subset.size()-1; j>=0; j--)
47   - if (subset[j].file.get<QString>(inputVariable) == probeLabel)
48   - subset.removeAt(j);
49   -
50   - QList<float> scores = distance->compare(subset, probe);
51   - float min, max;
52   - Common::MinMax(scores, &min, &max);
53   - double mean = Common::Mean(scores);
54   - return (max-mean)/(max-min);
55   - }
56   -
57   - void train(const TemplateList &data)
58   - {
59   - distance->train(data);
60   - impostors = data;
61   -
62   - QList<float> iums; iums.reserve(impostors.size());
63   - for (int i=0; i<data.size(); i++)
64   - iums.append(calculateIUM(impostors[i], impostors));
65   -
66   - Common::MeanStdDev(iums, &mean, &stddev);
67   - }
68   -
69   - void project(const Template &src, Template &dst) const
70   - {
71   - dst = src;
72   - float ium = calculateIUM(src, impostors);
73   - dst.file.set("Impostor_Uniqueness_Measure", ium);
74   - dst.file.set("Impostor_Uniqueness_Measure_Bin", ium < mean-stddev ? 0 : (ium < mean+stddev ? 1 : 2));
75   - }
76   -
77   - void store(QDataStream &stream) const
78   - {
79   - distance->store(stream);
80   - stream << mean << stddev << impostors;
81   - }
82   -
83   - void load(QDataStream &stream)
84   - {
85   - distance->load(stream);
86   - stream >> mean >> stddev >> impostors;
87   - }
88   -};
89   -
90   -BR_REGISTER(Transform, ImpostorUniquenessMeasureTransform)
91   -
92   -} // namespace br
93   -
94   -#include "metadata/imposteruniquenessmeasure.moc"