Last active
April 8, 2022 16:01
-
-
Save hsiaoer/c497c08a97e4e7bdae838282f3eb852f to your computer and use it in GitHub Desktop.
ImageSegmentationTutorial-completePrediction
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
// Create the on device model for People Segmentation | |
// PeopleSegmentationOnDeviceModel is a subclass of FritzOnDeviceModel | |
PeopleSegmentOnDeviceModelFast onDeviceModel = new PeopleSegmentOnDeviceModelFast(); | |
// Get the predictor with the People Segmentation Model | |
// FritzVisionSegmentPredictor is a subclass of FritzVisionPredictor | |
FritzVisionSegmentPredictor predictor = FritzVision.ImageSegmentation.getPredictor(onDeviceModel); | |
// Create a a visionImage | |
FritzVisionImage visionImage = FritzVisionImage.fromBitmap(inputBitmap); | |
// Run predict on an image | |
// FritzVisionSegmentResult is a subclass of FritzVisionResult | |
FritzVisionSegmentResult segmentResult = predictor.predict(visionImage); | |
// Get a masked bitmap of People detected in the image. | |
// Set the max alpha to 255 and .5f for clippingScoresAbove and .5f for zeroingScoresBelow | |
// For more details on this option, take a look at the documentation: | |
// https://docs.fritz.ai/develop/vision/image-segmentation/android.html#run-prediction-on-fritzvisionimage | |
Bitmap peopleMask = segmentResult.buildSingleClassMask(MaskType.PERSON, 255, .5f, .5f); | |
// Return a cut out option of the person | |
// Set option to trim any transparent pixels. | |
Bitmap peopleInPhoto = visionImage.mask(peopleMask, true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PeopleSegmentOnDeviceModelFast is not importing in my android studio and MaskType.PERSON is also showing error how to import that package. This is the error I am getting. How to solve them.