What's your feature request? Please describe.
Can we set Manually ByteBuffer and Bitmap in mlkit selfie segmentation
Mobile environment
both
Additional context
We are currently using this code
private Segmenter segmenter;
private ByteBuffer maskBuffer = ByteBuffer.allocate(0);
private int maskWidth = 0;
private int maskHeight = 0;
BitmapUtils bitmapUtils = new BitmapUtils();
Bitmap maskBitmap;
ProcessedListener listener;
public SegmentHelper(ProcessedListener mlistener) {
this.listener = mlistener;
}
public void init() {
SelfieSegmenterOptions options =
new SelfieSegmenterOptions.Builder()
.setDetectorMode(SelfieSegmenterOptions.SINGLE_IMAGE_MODE)
.build();
segmenter = Segmentation.getClient(options);
}
/**
* Processes a bitmap and informs the listener on success
*/
public void processImage(Context mContext, Bitmap image) {
InputImage input = InputImage.fromBitmap(image, 0);
segmenter.process(input).addOnSuccessListener(SegmentationMask -> {
maskBuffer = SegmentationMask.getBuffer();
maskWidth = SegmentationMask.getWidth();
maskHeight = SegmentationMask.getHeight();
listener.imageProcessed();
})
.addOnFailureListener(e -> {
});
}
/**
* Highlights the detected background of the segmentation mask as a green overlay
*/
public Bitmap generateMaskImage(Bitmap image) {
maskBitmap = Bitmap.createBitmap(image.getWidth(), image.getHeight(), image.getConfig());
for (int y = 0; y < maskHeight; y++) {
for (int x = 0; x < maskWidth; x++) {
int bgConfidence = (int) ((1.0 - maskBuffer.getFloat()) * 255);
maskBitmap.setPixel(x, y, Color.argb(bgConfidence, 0, 0, 0));
}
}
maskBuffer.rewind();
return bitmapUtils.mergeBitmaps(image, maskBitmap);
}
every thing is done by MLKIT, can we set the bytbuffer and Create a bitmap out of it Manually , since some times MLKIT misses some parts of the image we want to capture.
What's your feature request? Please describe.
Can we set Manually ByteBuffer and Bitmap in mlkit selfie segmentation
Mobile environment
both
Additional context
We are currently using this code
every thing is done by MLKIT, can we set the bytbuffer and Create a bitmap out of it Manually , since some times MLKIT misses some parts of the image we want to capture.