From c88c297f40f0715c16b53749e743ef931acec9dc Mon Sep 17 00:00:00 2001 From: Charles Otto Date: Thu, 29 May 2014 14:28:52 -0400 Subject: [PATCH] Read bee format galleries row by row instead of as a single blob --- openbr/core/bee.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/openbr/core/bee.cpp b/openbr/core/bee.cpp index a5a0030..facafe9 100644 --- a/openbr/core/bee.cpp +++ b/openbr/core/bee.cpp @@ -164,23 +164,30 @@ Mat BEE::readMat(const br::File &matrix, QString *targetSigset, QString *querySi int typeSize = isMask ? sizeof(BEE::Mask_t) : sizeof(BEE::Simmat_t); // Get matrix data - qint64 bytesExpected = (qint64)rows*(qint64)cols*(qint64)typeSize; Mat m; if (isMask) m.create(rows, cols, OpenCVType::make()); else m.create(rows, cols, OpenCVType::make()); - qint64 read = file.read((char*)m.data, bytesExpected); - if (read != bytesExpected) - qFatal("Invalid matrix size."); + qint64 bytesPerRow = m.cols * typeSize; + + for (int i=0; i < m.rows;i++) + { + cv::Mat aRow = m.row(i); + qint64 bytesRead = file.read((char *)aRow.data, bytesPerRow); + if (bytesRead != bytesPerRow) + { + qFatal("Didn't read complete row!"); + } + } if (!file.atEnd()) qFatal("Expected matrix end of file."); file.close(); - Mat result; + Mat result = m; if (isDistance ^ matrix.get("negate", false)) m.convertTo(result, -1, -1); - else result = m.clone(); + return result; } -- libgit2 0.21.4