From 08b73def2f0e365c7bbcfc4f2557b78855890565 Mon Sep 17 00:00:00 2001 From: Scott Klum Date: Wed, 9 Nov 2016 12:20:58 -0700 Subject: [PATCH] Generalized the raw format --- openbr/plugins/format/raw.cpp | 44 +++++++++----------------------------------- 1 file changed, 9 insertions(+), 35 deletions(-) diff --git a/openbr/plugins/format/raw.cpp b/openbr/plugins/format/raw.cpp index c382f2f..d58c8c4 100644 --- a/openbr/plugins/format/raw.cpp +++ b/openbr/plugins/format/raw.cpp @@ -26,49 +26,25 @@ namespace br * \ingroup formats * \brief RAW format * - * \br_link http://www.nist.gov/srd/nistsd27.cfm - * \author Josh Klontz \cite jklontz + * \author Scott Klum \cite sklum */ class rawFormat : public Format { Q_OBJECT - static QHash > imageSizes; // QHash > Template read() const { - QString path = file.path(); - if (!imageSizes.contains(path)) { - static QMutex mutex; - QMutexLocker locker(&mutex); - - if (!imageSizes.contains(path)) { - const QString imageSize = path+"/ImageSize.txt"; - QStringList lines; - if (QFileInfo(imageSize).exists()) { - lines = QtUtils::readLines(imageSize); - lines.removeFirst(); // Remove header - } - - QHash sizes; - QRegExp whiteSpace("\\s+"); - foreach (const QString &line, lines) { - QStringList words = line.split(whiteSpace); - if (words.size() != 3) continue; - sizes.insert(words[0], QSize(words[2].toInt(), words[1].toInt())); - } - - imageSizes.insert(path, sizes); - } - } - QByteArray data; QtUtils::readFile(file, data); - QSize size = imageSizes[path][file.baseName()]; - if (!size.isValid()) size = QSize(800,768); - if (data.size() != size.width() * size.height()) - qFatal("Expected %d*%d bytes, got %d.", size.height(), size.width(), data.size()); - return Template(file, Mat(size.height(), size.width(), CV_8UC1, data.data()).clone()); + // The raw file format has no header information, so one must specify resolution + QSize size = size = QSize(file.get("width"),file.get("height")); + Template t(file); + QList matrices; + const int bytes = size.width()*size.height(); + for (int i=0; i > rawFormat::imageSizes; - BR_REGISTER(Format, rawFormat) } // namespace br -- libgit2 0.21.4