Commit f25266ec9d79224d9d7298ae6a5ef051f73a0617
1 parent
603f5cc1
Avoid double count
Showing
1 changed file
with
4 additions
and
5 deletions
openbr/plugins/imgproc/cropfrommask.cpp
| @@ -25,12 +25,10 @@ private: | @@ -25,12 +25,10 @@ private: | ||
| 25 | 25 | ||
| 26 | Mat mask = dst.file.get<Mat>("Mask"); | 26 | Mat mask = dst.file.get<Mat>("Mask"); |
| 27 | 27 | ||
| 28 | - const int count = countNonZero(mask); | ||
| 29 | - | ||
| 30 | - if (count > 0) { | ||
| 31 | - Mat indices; | ||
| 32 | - findNonZero(mask,indices); | 28 | + Mat indices; |
| 29 | + findNonZero(mask,indices); | ||
| 33 | 30 | ||
| 31 | + if (indices.total() > 0) { | ||
| 34 | QList<int> x, y; | 32 | QList<int> x, y; |
| 35 | for (size_t i=0; i<indices.total(); i++) { | 33 | for (size_t i=0; i<indices.total(); i++) { |
| 36 | x.append(indices.at<Point>(i).x); | 34 | x.append(indices.at<Point>(i).x); |
| @@ -65,6 +63,7 @@ private: | @@ -65,6 +63,7 @@ private: | ||
| 65 | 63 | ||
| 66 | dst.m() = Mat(src.m(), Rect(l, t, r - l + 1, b - t + 1)); | 64 | dst.m() = Mat(src.m(), Rect(l, t, r - l + 1, b - t + 1)); |
| 67 | } else { | 65 | } else { |
| 66 | + // Avoid serializing mask | ||
| 68 | dst.file.remove("Mask"); | 67 | dst.file.remove("Mask"); |
| 69 | dst.file.fte = true; | 68 | dst.file.fte = true; |
| 70 | } | 69 | } |