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
allprojects { | |
repositories { | |
maven { | |
url "https://raw.github.com/fritzlabs/fritz-repository/master" | |
} | |
} | |
} |
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
// Run the image through the model to identify pixels representing hair. | |
FritzVisionSegmentResult segmentResult = predictor.predict(visionImage); |
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
// Get the original image. | |
FritzVisionImage visionImage = segmentResult.getOriginalImage(); | |
// Blend the original image with the mask and the blend mode. | |
Bitmap blendedBitmap = visionImage.blend(maskBitmap, blendMode); |
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
Bitmap maskBitmap = segmentResult.createMaskOverlayBitmap(blendMode.getAlpha()); |
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
// Initialize the model included with the app | |
SegmentOnDeviceModel onDeviceModel = new HairSegmentationOnDeviceModelFast(); | |
// Create the predictor with the Hair Segmentation model. | |
FritzVisionSegmentPredictor predictor = FritzVision.ImageSegmentation.getPredictor(onDeviceModel); |
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
// Soft Light Blend | |
BlendMode blendMode = BlendMode.SOFT_LIGHT; | |
// Color Blend | |
BlendMode blendMode = BlendMode.COLOR; | |
// Hue Blend | |
BlendMode blendMode = BlendMode.HUE; |
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
// Determine how to rotate the image from the camera used. | |
ImageRotation rotation = FritzVisionOrientation.getImageRotationFromCamera(this, cameraId); | |
// Create a FritzVisionImage object from android.media.Image | |
FritzVisionImage visionImage = FritzVisionImage.fromMediaImage(image, rotation); |
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
// --------------------------------- | |
// Handle Bitmap (ARG_8888) | |
// --------------------------------- | |
// Standard FritzVisionImage creation | |
FritzVisionImage visionImage = FritzVisionImage.fromBitmap(bitmap); | |
// Applying a rotation to the bitmap (how to get the rotation value) | |
// https://stackoverflow.com/questions/7286714/android-get-orientation-of-a-camera-bitmap-and-rotate-back-90-degrees | |
FritzVisionImage visionImage = FritzVisionImage.fromBitmap(bitmap, rotation); |
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
@Override | |
protected void onCreate(final Bundle savedInstanceState) { | |
// ... | |
// PeopleSegmentOnDeviceModel is a subclass of FritzOnDeviceModel | |
PeopleSegmentOnDeviceModel onDeviceModel = new PeopleSegmentOnDeviceModelFast(); | |
// Get the predictor with the People Segmentation Model | |
// FritzVisionSegmentPredictor is a subclass of FritzVisionPredictor | |
FritzVisionSegmentPredictor predictor = FritzVision.ImageSegmentation.getPredictor(onDeviceModel); | |
} |
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); |