diff --git a/src/main/java/org/openpnp/vision/pipeline/stages/MaskHsv.java b/src/main/java/org/openpnp/vision/pipeline/stages/MaskHsv.java index 9c45d4036e7..6bf3419f448 100644 --- a/src/main/java/org/openpnp/vision/pipeline/stages/MaskHsv.java +++ b/src/main/java/org/openpnp/vision/pipeline/stages/MaskHsv.java @@ -391,6 +391,12 @@ public Result process(CvPipeline pipeline) throws Exception { endIdx = -1; startIdx = -1; } + workingMat.release(); + mv.release(); + hist.release(); + ranges.release(); + channels.release(); + histSize.release(); setValueMax( endIdx ); Logger.trace( "valueMax = " + valueMax ); setValueMin( startIdx ); @@ -420,6 +426,7 @@ public Result process(CvPipeline pipeline) throws Exception { Core.inRange(mat, min, max, mask2); Core.bitwise_or(mask, mask2, mask); + mask2.release(); } //The mask is normally inverted because it is used to copy the unmasked portions of the @@ -430,12 +437,12 @@ public Result process(CvPipeline pipeline) throws Exception { double fractionActuallyMasked = 1.0 - Core.countNonZero(mask) / (double) ( mat.rows() * mat.cols() ) ; Logger.trace( "Fraction actually masked = " + fractionActuallyMasked ); - if (binaryMask) { + masked.release(); return new Result(mask); - } - else { + } else { mat.copyTo(masked, mask); + mask.release(); return new Result(masked); } } diff --git a/src/main/java/org/openpnp/vision/pipeline/stages/Normalize.java b/src/main/java/org/openpnp/vision/pipeline/stages/Normalize.java index 4063eb34da5..5fc1b669b17 100644 --- a/src/main/java/org/openpnp/vision/pipeline/stages/Normalize.java +++ b/src/main/java/org/openpnp/vision/pipeline/stages/Normalize.java @@ -26,6 +26,7 @@ private void filter(Mat src){ } } src.put(0, 0, pixel); + dst.release(); } @Override