【问题标题】:Android, How to invert Google ml Kit ImageProxy colors?Android,如何反转 Google ml Kit ImageProxy 颜色?
【发布时间】:2022-11-16 05:49:58
【问题描述】:

我正在开发一个 Android 应用程序。 我正在使用 Google ML Kit 进行交易。但是我需要在使用 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();
                }

【问题讨论】:

    标签: android google-mlkit


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2021-10-18
      • 2021-08-05
      • 1970-01-01
      • 2021-12-06
      • 2021-03-10
      • 2021-01-02
      • 1970-01-01
      • 2020-12-26
      • 2018-05-07
      相关资源
      最近更新 更多