是否可以同时使用Firebase ML Kit文本识别和条形码扫描仪?

时间:2019-07-09 14:50:40

标签: android firebase google-vision firebase-mlkit

我已经分别制作了用于文本识别和条形码扫描仪的应用程序。但是是否可以在实时流中同时使用文本识别和条形码扫描仪?

阅读此代码后我感到困惑

mCameraSource.setMachineLearningFrameProcessor(barcodeScanningProcessor);

是否表示每一项MachineLearning仅提供一个摄像头资源?

1 个答案:

答案 0 :(得分:0)

是的,但是您正在使用的示例代码是针对一次使用一个帧处理器而定制的。

一种实现所需内容的方法是分别处理每个帧,这将使您可以将其传递给多个API。

CameraView是一个允许进行帧处理的程序包。您可能希望节流,每X帧只取一帧,因为处理一帧需要大量计算。

cameraView.addFrameProcessor(new FrameProcessor() {
   @Override
   @WorkerThread
   public void process(Frame frame) {
       byte[] data = frame.getData();
       int rotation = frame.getRotation();
       long time = frame.getTime();
       Size size = frame.getSize();
       int format = frame.getFormat();

       // Process frame
       // This is where you'd pass the image to the Text recognition API
       // and then to the Barcode scanning API.

   }
}

您将按照text recognitionbarcode scanning的文档中所述处理每一帧。

相关问题