使用Android Mobile Vision API搜索文本中的特定模式
我已经制作了一个应用程序的工作实现,该应用程序使用android mobile vision API来阅读文本。但是有没有一种方法可以让我搜索特定的文本模式,比如搜索一行中有10位数字的地方或者类似的地方。是否有可能实现这一点使用Android Mobile Vision API搜索文本中的特定模式,android,android-vision,Android,Android Vision,我已经制作了一个应用程序的工作实现,该应用程序使用android mobile vision API来阅读文本。但是有没有一种方法可以让我搜索特定的文本模式,比如搜索一行中有10位数字的地方或者类似的地方。是否有可能实现这一点 感谢您的帮助。在android mobile vision api中,OcrDetectorProcessor类中有一个名为receiveDetections的方法 此方法接收通过摄像头检测到的所有字符,其默认行为是显示每个字符 在屏幕上检测到字符 @Override
感谢您的帮助。在android mobile vision api中,OcrDetectorProcessor类中有一个名为receiveDetections的方法 此方法接收通过摄像头检测到的所有字符,其默认行为是显示每个字符 在屏幕上检测到字符
@Override
public void receiveDetections(Detector.Detections<TextBlock> detections) {
mGraphicOverlay.clear();
SparseArray<TextBlock> items = detections.getDetectedItems();
for (int i = 0; i < items.size(); ++i) {
TextBlock item = items.valueAt(i);
OcrGraphic graphic = new OcrGraphic(mGraphicOverlay, item);
mGraphicOverlay.add(graphic);
}
}
@覆盖
公共空隙接收检测(检测器。检测){
mGraphicOverlay.clear();
SparseArray items=detections.getDetectedItems();
对于(int i=0;i
您可以编辑此方法以过滤检测到的字符,并仅向用户显示您要显示的内容。因此,如果说,根据您的问题,您希望显示任何包含10个字符的字符串,您可以通过将该方法编辑为
@Override
public void receiveDetections(Detector.Detections<TextBlock> detections) {
if(stopScan){
SparseArray<TextBlock> items = detections.getDetectedItems();
for (int i = 0; i < items.size(); ++i) {
TextBlock item = items.valueAt(i);
//verify string here
if (item.getValue().length() == 10) {
OcrGraphic graphic = new OcrGraphic(mGraphicOverlay, item);
mGraphicOverlay.add(graphic);
}
}
}
}
@覆盖
公共空隙接收检测(检测器。检测){
如果(停止扫描){
SparseArray items=detections.getDetectedItems();
对于(int i=0;i
Mobile vision为您提供了大量字符串及其位置。连接它们,并应用正则表达式。就这样。