From 4f89a819d36c071292004d47a25e9fff5ac5bb31 Mon Sep 17 00:00:00 2001 From: Josh Klontz Date: Wed, 27 Feb 2013 13:29:05 -0500 Subject: [PATCH] added raw format --- sdk/plugins/format.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+), 0 deletions(-) diff --git a/sdk/plugins/format.cpp b/sdk/plugins/format.cpp index 5a4fea2..47f10b8 100644 --- a/sdk/plugins/format.cpp +++ b/sdk/plugins/format.cpp @@ -509,6 +509,34 @@ BR_REGISTER(Format, matFormat) /*! * \ingroup formats + * \brief RAW format + * + * http://www.nist.gov/srd/nistsd27.cfm + * \author Josh Klontz \cite jklontz + */ +class rawFormat : public Format +{ + Q_OBJECT + + Template read() const + { + QByteArray data; + QtUtils::readFile(file, data); + if (data.size() != 768*800) + qFatal("Expected 768*800 bytes."); + return Template(file, Mat(768, 800, CV_8UC1, data.data()).clone()); + } + + void write(const Template &t) const + { + QtUtils::writeFile(file, QByteArray().setRawData((const char*)t.m().data, t.m().total() * t.m().elemSize())); + } +}; + +BR_REGISTER(Format, rawFormat) + +/*! + * \ingroup formats * \brief Retrieves an image from a webcam. * \author Josh Klontz \cite jklontz */ -- libgit2 0.21.4