From f25266ec9d79224d9d7298ae6a5ef051f73a0617 Mon Sep 17 00:00:00 2001 From: Scott Klum Date: Fri, 10 Apr 2015 14:32:28 -0400 Subject: [PATCH] Avoid double count --- openbr/plugins/imgproc/cropfrommask.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/openbr/plugins/imgproc/cropfrommask.cpp b/openbr/plugins/imgproc/cropfrommask.cpp index e222197..14327e9 100644 --- a/openbr/plugins/imgproc/cropfrommask.cpp +++ b/openbr/plugins/imgproc/cropfrommask.cpp @@ -25,12 +25,10 @@ private: Mat mask = dst.file.get("Mask"); - const int count = countNonZero(mask); - - if (count > 0) { - Mat indices; - findNonZero(mask,indices); + Mat indices; + findNonZero(mask,indices); + if (indices.total() > 0) { QList x, y; for (size_t i=0; i(i).x); @@ -65,6 +63,7 @@ private: dst.m() = Mat(src.m(), Rect(l, t, r - l + 1, b - t + 1)); } else { + // Avoid serializing mask dst.file.remove("Mask"); dst.file.fte = true; } -- libgit2 0.21.4