如何停止扫描和存储来自Google Vision API的数据? [英] How to stop scanning and store data from Google's Vision API?

查看:65
本文介绍了如何停止扫描和存储来自Google Vision API的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目上使用Google的Vision API BarcodeScanner.我想在扫描完代码后中断扫描,并将内容存储在另一个活动中.我怎样才能做到这一点 ?有太多的类和互连":x

I'm using Google's Vision API BarcodeScanner on my project. I would like to interrupt scanning once a code has been scanned and store the content in another activity. How can i do that ? There are so many classes and 'interconnections' :x

谢谢!

推荐答案

因此,就停止扫描而言,我可以通过在BarcodeDetector实例上调用.release()使它正常工作.我遵循了此示例Detector.Processor<Barcode>.处理器具有receiveDetections()方法,所以我所做的只是调用了barcodeDetector.release(),其中barcodeDetector是检测到条形码的实例.它对我来说很好用,我还测试了扫描并在检测到之后启动了另一个活动,并且仅添加了一个活动,因此它实际上只是检测到一个条形码然后停止.

So, as far as stopping the scanning goes, I got it working by calling .release() on my BarcodeDetector instance. I followed this example and as you can see they set a Detector.Processor<Barcode> for the BarcodeDetector. The processor has a receiveDetections() method, so what I did was just calling barcodeDetector.release() with barcodeDetector being the instance that detected the barcode. It works fine for me, I also tested the scanning and starting another activity after detection, and only one activity is added, so it really just detects one barcode and then stops.

要将内容保存到另一个活动中,可以使用Intent在相同的receiveDetections()方法中启动另一个活动,然后使用putExtra()方法获取另一个活动所需的数据,尽管我真的不知道您要保存什么,因此putExtra()可能不足以满足您的需求.

To save the content in another activity, you can start another activity in the same receiveDetections() method using an Intent, and then use the putExtra() method to get the data you need to the other activity, although I don't really know what you want to save and thus putExtra() might not suffice for you.

关于示例,向下滚动到"4.使用相机读取QR码",您将发现我在说什么.

concerning the example scroll down to "4. Reading a QR Code Using the Camera" there you will find what I am talking about.

这篇关于如何停止扫描和存储来自Google Vision API的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆