How do I update a segmentation mask manually to fix errors or mask additional content?

Occasionally the segmentation result may not provide a completely accurate mask or you may want to allow a user to update the mask manually. You can achieve this by modifying the alpha mask directly.

  1. From the SegmentationResult , export the alpha mask to a bitmap: segmentResult.buildSingleClassMask
  2. Add or erase the desired pixels to the alpha mask by set the alpha to 0 if you want to remove it, 1 if you want to add the pixel. You’ll have to implement this yourself.
  3. Use the alpha mask to cut out from the original image: Bitmap finalResult = visionImage.mask(yourModifiedBitmap);