Commit 169c866a73f3d128572af7d32037c1d887f4c7c4

Authored by Josh Klontz
1 parent f72a4fb4

removed heatmap distance

openbr/plugins/distance/heatmap.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   -
19   -namespace br
20   -{
21   -
22   -/*!
23   - * \ingroup distances
24   - * \brief 1v1 heat map comparison
25   - * \author Scott Klum \cite sklum
26   - */
27   -class HeatMapDistance : public Distance
28   -{
29   - Q_OBJECT
30   - Q_PROPERTY(QString description READ get_description WRITE set_description RESET reset_description STORED false)
31   - Q_PROPERTY(int step READ get_step WRITE set_step RESET reset_step STORED false)
32   - Q_PROPERTY(QString inputVariable READ get_inputVariable WRITE set_inputVariable RESET reset_inputVariable STORED false)
33   - BR_PROPERTY(QString, description, "IdenticalDistance")
34   - BR_PROPERTY(int, step, 1)
35   - BR_PROPERTY(QString, inputVariable, "Label")
36   -
37   - QList<br::Distance*> distances;
38   -
39   - void train(const TemplateList &src)
40   - {
41   - QList<TemplateList> patches;
42   -
43   - // Split src into list of TemplateLists of corresponding patches across all Templates
44   - for (int i=0; i<step; i++) {
45   - TemplateList patchBuffer;
46   - for (int j=0; j<src.size(); j++)
47   - patchBuffer.append(Template(src[j].file, src[j][i]));
48   - patches.append(patchBuffer);
49   - patchBuffer.clear();
50   - }
51   -
52   - while (distances.size() < patches.size())
53   - distances.append(make(description));
54   -
55   - // Train on a distance for each patch
56   - for (int i=0; i<distances.size(); i++)
57   - distances[i]->train(patches[i]);
58   - }
59   -
60   - float compare(const cv::Mat &target, const cv::Mat &query) const
61   - {
62   - (void) target;
63   - (void) query;
64   - qFatal("Heatmap Distance not compatible with Template to Template comparison.");
65   -
66   - return 0;
67   - }
68   -
69   - void compare(const TemplateList &target, const TemplateList &query, Output *output) const
70   - {
71   - for (int i=0; i<target.size(); i++) {
72   - if (target[i].size() != step || query[i].size() != step) qFatal("Heatmap step not equal to the number of patches.");
73   - for (int j=0; j<step; j++)
74   - output->setRelative(distances[j]->compare(target[i][j],query[i][j]), j, 0);
75   - }
76   - }
77   -
78   - void store(QDataStream &stream) const
79   - {
80   - stream << distances.size();
81   - foreach (Distance *distance, distances)
82   - distance->store(stream);
83   - }
84   -
85   - void load(QDataStream &stream)
86   - {
87   - int numDistances;
88   - stream >> numDistances;
89   - while (distances.size() < numDistances)
90   - distances.append(make(description));
91   - foreach (Distance *distance, distances)
92   - distance->load(stream);
93   - }
94   -};
95   -
96   -BR_REGISTER(Distance, HeatMapDistance)
97   -
98   -} // namespace br
99   -
100   -#include "distance/heatmap.moc"