ML Kit条形码扫描 - 与FirebaseVisionImageMetadata一起使用的图像格式?

问题描述 投票:0回答:1

documentation for ML Kit's barcode scanning functionality说你应该在下面的代码片段中配置一个FirebaseVisionImageMetadata

FirebaseVisionImageMetadata metadata = new FirebaseVisionImageMetadata.Builder()
        .setWidth(1280)
        .setHeight(720)
        .setFormat(FirebaseVisionImageMetadata.IMAGE_FORMAT_NV21)
        .setRotation(rotation)
        .build();

文档是关于使用什么格式完全不存在的。而the API doc for the ImageFormat interface并没有真正的帮助。

我怎么知道在这里选择什么?选择其中一个会产生什么后果?设备的不同支持哪种格式?

android firebase-mlkit
1个回答
0
投票

支持的文件格式位于文档的FirebaseVisionImageMetadata.ImageFormat部分。

特别是它的YV21NV21(链接转到Android文档)

正如您在Android文档中看到的那样,它主要是关于您使用哪个相机库建议使用哪种格式。

格式决定了您传递的ByteBuffer中图像数据的表示方式,因此如果使用与源不匹配的图像数据,图像将被错误地解释。如果您没有使用ByteBuffer,则无需创建元数据对象!

© www.soinside.com 2019 - 2024. All rights reserved.