Commit 8a444f8c010bbb091c5e90553975f6713953bfc3
1 parent
86b72c69
remove rank
Showing
1 changed file
with
0 additions
and
98 deletions
openbr/plugins/output/rank.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 | -#include <openbr/core/opencvutils.h> | |
| 21 | - | |
| 22 | -namespace br | |
| 23 | -{ | |
| 24 | - | |
| 25 | -struct RankResult | |
| 26 | -{ | |
| 27 | - int rank; | |
| 28 | - float score; | |
| 29 | - File probe, target; | |
| 30 | - | |
| 31 | - bool operator<(const RankResult &other) const | |
| 32 | - { | |
| 33 | - return this->rank < other.rank; | |
| 34 | - } | |
| 35 | - | |
| 36 | - QString toLine(const QChar &separator) const | |
| 37 | - { | |
| 38 | - return probe.fileName() + separator + QString::number(rank) + separator + QString::number(score) + separator+ target.fileName(); | |
| 39 | - } | |
| 40 | -}; | |
| 41 | - | |
| 42 | -/*! | |
| 43 | - * \ingroup outputs | |
| 44 | - * \brief Outputs highest ranked matches with scores. | |
| 45 | - * \author Scott Klum \cite sklum | |
| 46 | - */ | |
| 47 | -class rankOutput : public MatrixOutput | |
| 48 | -{ | |
| 49 | - Q_OBJECT | |
| 50 | - | |
| 51 | - ~rankOutput() | |
| 52 | - { | |
| 53 | - if (targetFiles.isEmpty() || queryFiles.isEmpty()) return; | |
| 54 | - | |
| 55 | - QList<int> ranks; | |
| 56 | - QList<int> positions; | |
| 57 | - QList<float> scores; | |
| 58 | - QStringList lines; | |
| 59 | - | |
| 60 | - QList<RankResult> results; | |
| 61 | - | |
| 62 | - for (int i=0; i<queryFiles.size(); i++) { | |
| 63 | - typedef QPair<float,int> Pair; | |
| 64 | - int rank = 1; | |
| 65 | - foreach (const Pair &pair, Common::Sort(OpenCVUtils::matrixToVector<float>(data.row(i)), true)) { | |
| 66 | - // Check if target files are marked as allParitions, and make sure target and query files are in the same partition | |
| 67 | - if (Globals->crossValidate > 0 ? (targetFiles[pair.second].get<int>("Partition",-1) == -1 || targetFiles[pair.second].get<int>("Partition",-1) == queryFiles[i].get<int>("Partition",-1)) : true) { | |
| 68 | - if (QString(targetFiles[pair.second]) != QString(queryFiles[i])) { | |
| 69 | - if (targetFiles[pair.second].get<QString>("Label") == queryFiles[i].get<QString>("Label")) { | |
| 70 | - RankResult result; | |
| 71 | - result.rank = rank; | |
| 72 | - result.score = pair.first; | |
| 73 | - result.probe = queryFiles[i]; | |
| 74 | - result.target = targetFiles[pair.second]; | |
| 75 | - results.append(result); | |
| 76 | - break; | |
| 77 | - } | |
| 78 | - rank++; | |
| 79 | - } | |
| 80 | - } | |
| 81 | - } | |
| 82 | - } | |
| 83 | - | |
| 84 | - std::sort(results.begin(), results.end(), std::less<RankResult>()); | |
| 85 | - | |
| 86 | - foreach (const RankResult &result, results) | |
| 87 | - lines.append(result.toLine('\t')); | |
| 88 | - | |
| 89 | - | |
| 90 | - QtUtils::writeFile(file, lines); | |
| 91 | - } | |
| 92 | -}; | |
| 93 | - | |
| 94 | -BR_REGISTER(Output, rankOutput) | |
| 95 | - | |
| 96 | -} // namespace br | |
| 97 | - | |
| 98 | -#include "output/rank.moc" |