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并没有真正的帮助。
我怎么知道在这里选择什么?选择其中一个会产生什么后果?设备的不同支持哪种格式?
支持的文件格式位于文档的FirebaseVisionImageMetadata.ImageFormat部分。
正如您在Android文档中看到的那样,它主要是关于您使用哪个相机库建议使用哪种格式。
格式决定了您传递的ByteBuffer
中图像数据的表示方式,因此如果使用与源不匹配的图像数据,图像将被错误地解释。如果您没有使用ByteBuffer
,则无需创建元数据对象!