小编Pet*_*ela的帖子

从SurfaceView使用ByteBuffer时如何暂停android ML-kit中的条形码扫描

语境

我正在使用Android firebase-ml-vision使用SurfaceView和相框的连续ByteBuffer扫描条形码。我以ML工具包快速入门项目作为起点,并且效果很好。

我项目的目的是识别与条形码关联的产品,并将其添加到扫描项目列表中。

问题

相机对焦后,条形码处理器将多次检测到相同的条形码,因此您将在一秒钟内扫描20条而不是1条条形码。

这是来自CamereSource.FrameProcessingRunnable.run的 javadoc

 * As long as the processing thread is active, this executes detection on frames continuously.
 * The next pending frame is either immediately available or hasn't been received yet. Once it
 * is available, we transfer the frame info to local variables and run detection on that frame.
 * It immediately loops back for the next frame without pausing.
Run Code Online (Sandbox Code Playgroud)

我曾尝试在FrameProcessingRunnable中添加“已暂停”检查,但由于至少一个帧已被送入检测,因此我仍然至少两次被识别相同的条形码:

private class FrameProcessingRunnable implements Runnable {
private volatile …
Run Code Online (Sandbox Code Playgroud)

android barcode-scanner surfaceview firebase firebase-mlkit

5
推荐指数
1
解决办法
877
查看次数