Commit 4f89a819d36c071292004d47a25e9fff5ac5bb31

Authored by Josh Klontz
1 parent fbc931c8

added raw format

Showing 1 changed file with 28 additions and 0 deletions
sdk/plugins/format.cpp
... ... @@ -509,6 +509,34 @@ BR_REGISTER(Format, matFormat)
509 509  
510 510 /*!
511 511 * \ingroup formats
  512 + * \brief RAW format
  513 + *
  514 + * http://www.nist.gov/srd/nistsd27.cfm
  515 + * \author Josh Klontz \cite jklontz
  516 + */
  517 +class rawFormat : public Format
  518 +{
  519 + Q_OBJECT
  520 +
  521 + Template read() const
  522 + {
  523 + QByteArray data;
  524 + QtUtils::readFile(file, data);
  525 + if (data.size() != 768*800)
  526 + qFatal("Expected 768*800 bytes.");
  527 + return Template(file, Mat(768, 800, CV_8UC1, data.data()).clone());
  528 + }
  529 +
  530 + void write(const Template &t) const
  531 + {
  532 + QtUtils::writeFile(file, QByteArray().setRawData((const char*)t.m().data, t.m().total() * t.m().elemSize()));
  533 + }
  534 +};
  535 +
  536 +BR_REGISTER(Format, rawFormat)
  537 +
  538 +/*!
  539 + * \ingroup formats
512 540 * \brief Retrieves an image from a webcam.
513 541 * \author Josh Klontz \cite jklontz
514 542 */
... ...