Skip to content Skip to sidebar Skip to footer

How To Detect Words With Textrecognizer? It Can Only Detect Textblocks

I am able to detect TextBlock like Cyan color block in below image but I want to detect Word with TextRecogniger

Solution 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:

@Overridepublic 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();
            }
        }
    }
}

Post a Comment for "How To Detect Words With Textrecognizer? It Can Only Detect Textblocks"