Skip to content

Commit

Permalink
Avoid extra copy
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm001 committed Oct 15, 2023
1 parent f02b230 commit e0628af
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,11 @@ protected CVPipelineResult process(Frame frame, ArucoPipelineSettings settings)

// If we want to debug the thresholding steps, draw the first step to the color image
if (settings.debugThreshold) {
var thresh =
drawThresholdFrame(
drawThresholdFrame(
frame.processedImage.getMat(),
frame.colorImage.getMat(),
settings.threshWinSizes.getFirst(),
settings.threshConstant);
thresh.copyTo(frame.colorImage.getMat());
thresh.release();
}

targetList = new ArrayList<>();
Expand Down Expand Up @@ -165,17 +163,15 @@ protected CVPipelineResult process(Frame frame, ArucoPipelineSettings settings)
return new CVPipelineResult(sumPipeNanosElapsed, fps, targetList, frame);
}

private Mat drawThresholdFrame(Mat greyMat, int windowSize, double constant) {
Mat thresh = new Mat();
private void drawThresholdFrame(Mat greyMat, Mat outputMat, int windowSize, double constant) {
if (windowSize % 2 == 0) windowSize++;
Imgproc.adaptiveThreshold(
greyMat,
thresh,
outputMat,
255,
Imgproc.ADAPTIVE_THRESH_MEAN_C,
Imgproc.THRESH_BINARY_INV,
windowSize,
constant);
return thresh;
}
}

0 comments on commit e0628af

Please sign in to comment.