问题
I am able to detect TextBlock like Cyan color block in below image but I want to detect Word with TextRecogniger
回答1:
If you have a look at the reference (https://developers.google.com/android/reference/com/google/android/gms/vision/text/TextBlock), you will see that in the recognized block you will have a list of lines which has a list of elements.
Then you should get the word in your Processor class with something like this:
@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();
}
}
}
}
来源:https://stackoverflow.com/questions/46220141/how-to-detect-words-with-textrecognizer-it-can-only-detect-textblocks