2017-09-14 49 views

回答

1

如果你看一下參考(https://developers.google.com/android/reference/com/google/android/gms/vision/text/TextBlock),你將在已識別的塊中看到您將擁有包含元素列表的行列表。

那麼你應該得到這個詞在你的處理器類是這樣的:

@Override 
public void receiveDetections(Detector.Detections<TextBlock> detections) { 
    SparseArray<TextBlock> items = detections.getDetectedItems(); 
    for (int i = 0; i < items.size(); ++i) { 
     TextBlock item = items.valueAt(i); 
     List<Line> lines = (List<Line>) item.getComponents(); 
     for (Line line : lines) { 
      List<Element> elements = (List<Element>) line.getComponents(); 
      for (Element element : elements) { 
       String word = element.getValue(); 
      } 
     } 
    } 
} 
+0

不getComponent()方法的工作如上面給出的參考 –