简体   繁体   中英

Android, How to invert Google ml Kit ImageProxy colors?

I'm developing an Android Application. I am trading with Google ML Kit. But I need to invert the colors when rendering with Imageproxy. I am able to invert the image with OpenCV. But I can't convert it to Imageproxy. How can I invert image colors?

i need your help

InputImage image = InputImage.fromMediaImage(mediaImage, imageProxy.getImageInfo().getRotationDegrees());
                try {
                    Bitmap bitmap = ImageConvertUtils.getInstance().getUpRightBitmap(image);
                    Mat tmp = new Mat (bitmap.getWidth(), bitmap.getHeight(), CvType.CV_8UC1);
                    Utils.bitmapToMat(bitmap, tmp);
                    Core.bitwise_not(tmp, tmp);
                    Utils.matToBitmap(tmp, bitmap);
}  catch (MlKitException e) {
                    e.printStackTrace();
                }

If you just need to run inverted image with ML Kit. You don't need to convert it back to ImageProxy, just create another InputImage and feed it to ML Kit

InputImage invertedImage = InputImage.fromBitmap(yourBitmap, 0);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM