From 0f880500cd0ff0b6dcec0b68213f87e9d84c1aab Mon Sep 17 00:00:00 2001 From: Scott Klum Date: Sun, 12 Apr 2015 15:36:43 -0400 Subject: [PATCH] Fixed logic error in samplefrommask --- openbr/plugins/imgproc/samplefrommask.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/openbr/plugins/imgproc/samplefrommask.cpp b/openbr/plugins/imgproc/samplefrommask.cpp index 5314637..80d49ce 100644 --- a/openbr/plugins/imgproc/samplefrommask.cpp +++ b/openbr/plugins/imgproc/samplefrommask.cpp @@ -17,17 +17,15 @@ class SampleFromMaskTransform : public UntrainableTransform void project(const Template &src, Template &dst) const { Mat mask = src.file.get("Mask"); - const int count = countNonZero(mask); + Mat indices; + findNonZero(mask,indices); - if (count > 0) { - dst.m() = Mat(1,count,src.m().type()); + if (indices.total() > 0) { + dst.m() = Mat(1,indices.total(),src.m().type()); Mat masked; src.m().copyTo(masked, mask); - Mat indices; - findNonZero(masked,indices); - for (size_t j=0; j(0,j) = masked.at(indices.at(j).y,indices.at(j).x); } else { -- libgit2 0.21.4