Last active
July 26, 2019 14:21
-
-
Save hsiaoer/a28eedeb33cdb8ce3c1518de2b2e2df5 to your computer and use it in GitHub Desktop.
ImageSegmentationTutorial-showPredictionResult
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
snapshotOverlay.setCallback(new OverlayView.DrawCallback() { | |
@Override | |
public void drawCallback(final Canvas canvas) { | |
// If the prediction has not run | |
if(segmentResult == null) { | |
return; | |
} | |
// STEP 6: Show the people segmentation result when the background hasn't been chosen. | |
if (backgroundBitmap == null) { | |
// Create the person mask | |
Bitmap personMask = segmentResult.buildSingleClassMask(MaskType.PERSON, 180, clippingThreshold, zeroCutoff); | |
// Overlay the mask on the original image | |
Bitmap result = visionImage.overlay(personMask); | |
// Scale the bitmap to the viewport | |
Bitmap scaledBitmap = BitmapUtils.resize(result, cameraSize.getWidth(), cameraSize.getHeight()); | |
// Draw it on the canvas to render | |
canvas.drawBitmap(scaledBitmap, new Matrix(), new Paint()); | |
return; | |
} | |
// ... | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment