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; }