mediapipe
mediapipe copied to clipboard
Android. Process ARGB and Grayscale input packets
Issue https://github.com/google/mediapipe/issues/5017
points to the issue of incorrect bitmap conversion in
Android when RGBA or Grayscale images are used.
As far as the library allows the creation of ALPHA8 bitmaps,
it is not enough to use only getBitmapFromRgb and getBitmapFromRgba,
so the new getBitmapFromAlpha method is needed.
Otherwise, existing users relying on the 8-bit input but not using the
input packet would catch errors despite their code operating as
intended.
Add correct processing of images with 1, 3, and 4 channels
to FaceDetector, FaceLandmarker, FaceStylizer,
GestureRecognizer, HandLandmarker, HolisticLandmarker,
ImageClassifier, ImageEmbedder, ImageSegmenter,
InteractiveSegmenter, ObjectDetector, and PoseLandmarker.
If the number of channels is not 1, 3, or 4,
throw MediaPipeException with INVALID_ARGUMENT status code.
Implement methods and functions needed to convert single-channel images
to RGBA bitmaps.
The native function AlphaToRGBA uses memset
to set all bytes of the resulting buffer to zeros
and then copies the alpha values of the input image to the alpha values
of the corresponding output pixels.
Perform a slight refactoring:
use operator[i] instead of *(array + i) for clarity.
@schmidt-sebastian, is there a chance somebody will look at this PR?
Please let me know how to run the unit tests for Android MediaPipe. I wanted to add tests for this PR but failed to launch them, so I had to test the code manually on my device.
@schmidt-sebastian @kuaashish, please tell me whether there are estimates for this bugfix's review. Also, please let me know how to build an APK and run automated tests.
@schmidt-sebastian,
Could you please review this PR? If not, please tell me where I should send these changes to be reviewed and applied.
It's been over a year, and this issue (https://github.com/google-ai-edge/mediapipe/issues/5017) is annoying: it makes fetching the currently processed image tricky.
@definability is there any workaround other than pulling your fix and recompiling the library? @schmidt-sebastian can we please have this looked at?
@HarrisonUnifyAI, I asked a similar question two years ago and still do not know the answer: https://github.com/google-ai-edge/mediapipe/issues/5017#issuecomment-1849013855
Hopefully made obsolete by https://github.com/google-ai-edge/mediapipe/commit/167fe9a7b78bf2b9362c3cc1fa2e634cc50da062