I've been working with Android Mobile Vision OCR API for a while. Everything is work perfectly until i found that i need to extract just single words from the whole SparseArray (Mobile Vision API default return is a TextBlocks which defined in a SparseArray)
SparseArray<TextBlock> textBlocks = textRecognizer.detect(imageFrame);
for (int i = 0; i < textBlocks.size(); i++) {
TextBlock textBlock = textBlocks.get(textBlocks.keyAt(i));
List<Line> lines = (List<Line>) textBlock.getComponents();
for (Line line : lines) {
List<Element> elements = (List<Element>)
line.getComponents();
for (Element element : elements) {
word = element.getValue();
Log.d(TAG, "word Read : " + word);
}
}
}
When i check
Log.d(TAG, "word Read : " + word);
it print out repeatedly all element in the SparseArray
It seems that i'm asking a not-so-obvious question. But can i extract just a single or couple word from those "words" printed above ? For example, i want to extract the word which has character above 12 and has number in it.
Any help or hints will much Appreciated.