diff --git a/openbr/core/opencvutils.cpp b/openbr/core/opencvutils.cpp index ae59267..047c7df 100644 --- a/openbr/core/opencvutils.cpp +++ b/openbr/core/opencvutils.cpp @@ -345,12 +345,12 @@ QDataStream &operator<<(QDataStream &stream, const Mat &m) stream << rows << cols << type; // Write data - int len = rows*cols*m.elemSize(); + int len = rows * cols * m.elemSize(); stream << len; if (len > 0) { if (!m.isContinuous()) qFatal("Can't serialize non-continuous matrices."); int written = stream.writeRawData((const char*)m.data, len); - if (written != len) qFatal("Serialization failure."); + if (written != len) qFatal("Mat serialization failure, expected: %d bytes, wrote: %d bytes.", len, written); } return stream; } @@ -366,9 +366,9 @@ QDataStream &operator>>(QDataStream &stream, Mat &m) int len; stream >> len; if (len > 0) { - if (!m.isContinuous()) qFatal("opencvutils.cpp operator>> Mat can't deserialize non-continuous matrices."); - int written = stream.readRawData((char*)m.data, len); - if (written != len) qFatal("opencvutils.cpp operator>> Mat serialization failure."); + if (!m.isContinuous()) qFatal("Can't deserialize non-continuous matrices."); + const int read = stream.readRawData((char*)m.data, len); + if (read != len) qFatal("Mat deserialization failure, exptected: %d bytes, read: %d bytes.", len, read); } return stream; } diff --git a/openbr/core/opencvutils.h b/openbr/core/opencvutils.h index 35b16c9..572e214 100644 --- a/openbr/core/opencvutils.h +++ b/openbr/core/opencvutils.h @@ -105,7 +105,6 @@ QDataStream &operator>>(QDataStream &stream, cv::Rect &r); QDataStream &operator<<(QDataStream &stream, const cv::Size &s); QDataStream &operator>>(QDataStream &stream, cv::Size &s); - // As described in "Modern C++ Design" Section 2.5. template struct Type2Type @@ -113,53 +112,20 @@ struct Type2Type typedef T OriginalType; }; -/**** -OpenCVType - Templated OpenCV Mat::type creation. -****/ +// Templated OpenCV Mat::type creation. template class OpenCVType { - static int getDepth(Type2Type) - { - return CV_8U; - } - - static int getDepth(Type2Type) - { - return CV_8S; - } - - static int getDepth(Type2Type) - { - return CV_16U; - } - - static int getDepth(Type2Type) - { - return CV_16S; - } - - static int getDepth(Type2Type) - { - return CV_32S; - } - - static int getDepth(Type2Type) - { - return CV_32F; - } - - static int getDepth(Type2Type) - { - return CV_64F; - } + static int getDepth(Type2Type) { return CV_8U; } + static int getDepth(Type2Type) { return CV_8S; } + static int getDepth(Type2Type) { return CV_16U; } + static int getDepth(Type2Type) { return CV_16S; } + static int getDepth(Type2Type) { return CV_32S; } + static int getDepth(Type2Type) { return CV_32F; } + static int getDepth(Type2Type) { return CV_64F; } public: - static int make() - { - return CV_MAKETYPE((getDepth(Type2Type())),(Channels)); - } + static int make() { return CV_MAKETYPE((getDepth(Type2Type())),(Channels)); } }; #endif // OPENCVUTILS_OPENCVUTILS_H