From d7c2fb941f2db2bfe9ae8cb969413fe4e94718d1 Mon Sep 17 00:00:00 2001 From: Josh Klontz Date: Wed, 8 Apr 2015 16:47:56 -0400 Subject: [PATCH] rewrote lmGallery implementation --- openbr/plugins/gallery/lm.cpp | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/openbr/plugins/gallery/lm.cpp b/openbr/plugins/gallery/lm.cpp index 606927e..5640a58 100644 --- a/openbr/plugins/gallery/lm.cpp +++ b/openbr/plugins/gallery/lm.cpp @@ -21,15 +21,53 @@ class lmGallery : public Gallery ~lmGallery() { - const likely_const_mat m = likelyFromOpenCVMat(OpenCVUtils::toMatByRow(mats)); - likely_write(m, qPrintable(file.name)); + if (mats.empty()) + return; + if (!mats.first().data) + qFatal("Null first matrix"); + + const int depth = mats.first().depth(); + const int channels = mats.first().channels(); + const int columns = mats.first().cols; + const int rows = mats.first().rows; + const int frames = mats.size(); + likely_type type = likelyFromOpenCVDepth(depth); + if (channels > 1) type |= likely_multi_channel; + if (columns > 1) type |= likely_multi_column; + if (rows > 1) type |= likely_multi_row; + if (frames > 1) type |= likely_multi_frame; + + const likely_mat m = likely_new(type, channels, columns, rows, frames, NULL); + const size_t step = (type & likely_depth) * channels * columns * rows / 8; + for (size_t i=0; idata + i * step, mat.data, step); + } + + if (!likely_write(m, qPrintable(file.name))) + qFatal("Write failed"); likely_release_mat(m); } TemplateList readBlock(bool *done) { *done = true; - qFatal("Not supported."); + TemplateList templates; + const likely_const_mat m = likely_read(qPrintable(file.name), likely_file_matrix, likely_void); + const size_t step = (m->type & likely_depth) * m->channels * m->columns * m->rows / 8; + for (size_t i=0; iframes; i++) + templates.append(cv::Mat(m->rows, m->columns, CV_MAKETYPE(likelyToOpenCVDepth(m->type), m->channels), (void*)(m->data + i * step)).clone()); + return templates; } void write(const Template &t) -- libgit2 0.21.4