Commit 6594914818c2a08bdbe6cd6bd55c01f57d076306
1 parent
4e621b83
removed scores format
Showing
1 changed file
with
0 additions
and
79 deletions
openbr/plugins/format/scores.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 | -#include <openbr/core/opencvutils.h> | ||
| 20 | -#include <openbr/core/bee.h> | ||
| 21 | - | ||
| 22 | -using namespace cv; | ||
| 23 | - | ||
| 24 | -namespace br | ||
| 25 | -{ | ||
| 26 | - | ||
| 27 | -/*! | ||
| 28 | - * \ingroup formats | ||
| 29 | - * \brief Reads in scores or ground truth from a text table. | ||
| 30 | - * \author Josh Klontz \cite jklontz | ||
| 31 | - * \br_format Example of the format: | ||
| 32 | - * | ||
| 33 | - * 2.2531514 FALSE 99990377 99990164 | ||
| 34 | - * 2.2549822 TRUE 99990101 99990101 | ||
| 35 | - */ | ||
| 36 | -class scoresFormat : public Format | ||
| 37 | -{ | ||
| 38 | - Q_OBJECT | ||
| 39 | - Q_PROPERTY(int column READ get_column WRITE set_column RESET reset_column STORED false) | ||
| 40 | - Q_PROPERTY(bool groundTruth READ get_groundTruth WRITE set_groundTruth RESET reset_groundTruth STORED false) | ||
| 41 | - Q_PROPERTY(QString delimiter READ get_delimiter WRITE set_delimiter RESET reset_delimiter STORED false) | ||
| 42 | - BR_PROPERTY(int, column, 0) | ||
| 43 | - BR_PROPERTY(bool, groundTruth, false) | ||
| 44 | - BR_PROPERTY(QString, delimiter, "\t") | ||
| 45 | - | ||
| 46 | - Template read() const | ||
| 47 | - { | ||
| 48 | - QFile f(file.name); | ||
| 49 | - if (!f.open(QFile::ReadOnly | QFile::Text)) | ||
| 50 | - qFatal("Failed to open %s for reading.", qPrintable(f.fileName())); | ||
| 51 | - QList<float> values; | ||
| 52 | - while (!f.atEnd()) { | ||
| 53 | - const QStringList words = QString(f.readLine()).split(delimiter); | ||
| 54 | - if (words.size() <= column) qFatal("Expected file to have at least %d columns.", column+1); | ||
| 55 | - const QString &word = words[column]; | ||
| 56 | - bool ok; | ||
| 57 | - float value = word.toFloat(&ok); | ||
| 58 | - if (!ok) value = (QtUtils::toBool(word) ? BEE::Match : BEE::NonMatch); | ||
| 59 | - values.append(value); | ||
| 60 | - } | ||
| 61 | - if (values.size() == 1) | ||
| 62 | - qWarning("Only one value read, double check file line endings."); | ||
| 63 | - Mat result = OpenCVUtils::toMat(values); | ||
| 64 | - if (groundTruth) result.convertTo(result, CV_8U); | ||
| 65 | - return result; | ||
| 66 | - } | ||
| 67 | - | ||
| 68 | - void write(const Template &t) const | ||
| 69 | - { | ||
| 70 | - (void) t; | ||
| 71 | - qFatal("Not implemented."); | ||
| 72 | - } | ||
| 73 | -}; | ||
| 74 | - | ||
| 75 | -BR_REGISTER(Format, scoresFormat) | ||
| 76 | - | ||
| 77 | -} // namespace br | ||
| 78 | - | ||
| 79 | -#include "format/scores.moc" |