Skip to content

Commit

Permalink
Fix/release all mat (openpnp#1007)
Browse files Browse the repository at this point in the history
* Made sure all Mat are released

* removed a bit too much, reverted that change but made sure the Mat is
released if not returned.

* Typo

Co-authored-by: Johannes Formann <johannes@formann.de>
  • Loading branch information
doppelgrau and doppelgrau authored May 15, 2020
1 parent e3a4d7d commit 5e2985c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/java/org/openpnp/vision/pipeline/stages/MaskHsv.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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
Expand All @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ private void filter(Mat src){
}
}
src.put(0, 0, pixel);
dst.release();
}

@Override
Expand Down

0 comments on commit 5e2985c

Please sign in to comment.