From f2e9bf0e59c10a75dadde89514ab531d841484a4 Mon Sep 17 00:00:00 2001 From: Josh Klontz Date: Wed, 8 Apr 2015 20:55:39 -0400 Subject: [PATCH] simplified lmGallery to make use of newly introduced helper functions --- openbr/plugins/gallery/lm.cpp | 38 ++++---------------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/openbr/plugins/gallery/lm.cpp b/openbr/plugins/gallery/lm.cpp index 5640a58..a0ed972 100644 --- a/openbr/plugins/gallery/lm.cpp +++ b/openbr/plugins/gallery/lm.cpp @@ -23,37 +23,7 @@ class lmGallery : public Gallery { 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); - } - + likely_const_mat m = likelyFromOpenCVMats(mats.toVector().toStdVector()); if (!likely_write(m, qPrintable(file.name))) qFatal("Write failed"); likely_release_mat(m); @@ -64,9 +34,9 @@ class lmGallery : public Gallery *done = true; 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()); + foreach (const cv::Mat &mat, likelyToOpenCVMats(m)) + templates.append(mat); + likely_release_mat(m); return templates; } -- libgit2 0.21.4