Commit f7e019305e756cae0c86709ad5f4f5714e963df5

Authored by Josh Klontz
1 parent f67af1ff

remove scorelevelfusion

openbr/plugins/metadata/scorelevelfusion.cpp deleted
1   -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2   - * Copyright 2015 Rank One Computing 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 <opencv2/core/core.hpp>
19   -
20   -using namespace cv;
21   -
22   -namespace br
23   -{
24   -
25   -/*!
26   - * \ingroup transforms
27   - * \brief Fuses together scores from a single metadata key or multiple keys and sets the computed values in the specified key.
28   - * \br_property QString keys The meta-data key(s) to fuse on.
29   - * \br_property QString outputKey The output metadata key.
30   - * \br_property bool listOfList Flag that tells the program how to parse the metadata key that contains the score values.
31   - * \author Keyur Patel \cite kpatel
32   - */
33   -class ScoreLevelFusionTransform : public UntrainableMetadataTransform
34   -{
35   - Q_OBJECT
36   - Q_PROPERTY(QStringList keys READ get_keys WRITE set_keys RESET reset_keys STORED false)
37   - Q_PROPERTY(int numClasses READ get_numClasses WRITE set_numClasses RESET reset_numClasses STORED false)
38   - Q_PROPERTY(QString outputKey READ get_outputKey WRITE set_outputKey RESET reset_outputKey STORED false)
39   - Q_PROPERTY(bool listOfList READ get_listOfList WRITE set_listOfList RESET reset_listOfList STORED false)
40   -
41   - BR_PROPERTY(QStringList, keys, QStringList())
42   - BR_PROPERTY(int, numClasses, 2)
43   - BR_PROPERTY(QString, outputKey, "ScoreLevelFusion")
44   - BR_PROPERTY(bool, listOfList, false)
45   -
46   - void projectMetadata(const File &src, File &dst) const
47   - {
48   - dst = src;
49   - QList<QList<float> > scoresList = QList<QList<float> >();
50   - if (listOfList){ //format [[.8,.2],[.45,.55],[.3,.7]]
51   - foreach (QString key, keys){
52   - if (src.contains(key)){
53   - QList<QString > keyScoresList = src.getList<QString >(key);
54   - for (int d = 0; d < keyScoresList.size(); d++){
55   - QList<QString> tmpList = keyScoresList[d].split(",");
56   - QList<float> tmpScoreList = QList<float>();
57   - for (int f = 0; f < tmpList.size(); f++){
58   - tmpScoreList.append(tmpList[f].remove('"').remove("]").remove("[").toFloat());
59   - }
60   - scoresList.append(tmpScoreList);
61   - }
62   - } else{
63   - dst.fte = true;
64   - return;
65   - }
66   - }
67   - } else { //format = [.8,.2,.45,.55,.3.,7]
68   - QList<float> scores = QList<float>();
69   - foreach (QString key, keys){
70   - if (src.contains(key)){
71   - QList<float> templateScores = src.getList<float>(key);
72   - scores.append(templateScores);
73   - } else{
74   - dst.fte = true;
75   - return;
76   - }
77   - }
78   - for (int i = 0; i < scores.size(); i+=numClasses){
79   - QList<float> tmpList = QList<float>();
80   - for (int b = 0; b < numClasses; b++){
81   - tmpList.append(scores[i+b]);
82   - }
83   - scoresList.append(tmpList);
84   - }
85   - }
86   - Mat m = toMat(scoresList);
87   - Mat avgDist;
88   - cv::reduce(m, avgDist, 0, 1);
89   - dst.setList(outputKey,matrixToVector(avgDist));
90   - }
91   -
92   - cv::Mat toMat(const QList<QList<float> > &src) const
93   - {
94   - cv::Mat dst(src.size(), src[0].size(), CV_32F);
95   - for (int i=0; i<src.size(); i++)
96   - for (int j=0; j<src[i].size(); j++)
97   - dst.at<float>(i, j) = src[i][j];
98   - return dst;
99   - }
100   -
101   - QList<float> matrixToVector(const cv::Mat &m) const
102   - {
103   - QList<float> results;
104   - for (int i=0; i<m.cols; i++)
105   - results.append(m.at<float>(0, i));
106   - return results;
107   - }
108   -
109   -};
110   -
111   -BR_REGISTER(Transform, ScoreLevelFusionTransform)
112   -
113   -} // namespace br
114   -
115   -#include "metadata/scorelevelfusion.moc"
116   -