Android,如何反转谷歌ml Kit ImageProxy的颜色?



我正在开发一个Android应用程序。我是交易与谷歌ML工具包。但是当使用Imageproxy渲染时,我需要反转颜色。我能够用OpenCV反转图像。但我无法将其转换为Imageproxy。如何反转图像颜色?

我需要你的帮助

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();
}

如果您只需要使用ML Kit运行倒立图像。你不需要将它转换回ImageProxy,只需要创建另一个InputImage并将其提供给ML Kit

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

最新更新