public interface IRecognizedText
This interface is for work with recognized text. The result may be in multiple formats (plain text, array parts with details on each, in the hOCR format).
OcrEngine ocr = new OcrEngine(); ocr.getLanguageContainer().addLanguage(LanguageFactory.load("Portuguese-RSC-HS-PB-ResourcesAllCharsNet.zip")); // Resource file name ocr.setImage(ImageStream.fromFile("image.tiff")); if (ocr.process()) { } for(IRecognizedPartInfo recognizedPartInfo : ocr.getText().getPartsInfo()) { if (recognizedPartInfo instanceof IRecognizedTextPartInfo) { IRecognizedTextPartInfo recognizedBlockInfo = (IRecognizedTextPartInfo)recognizedPartInfo; String text = recognizedBlockInfo.getText(); if (recognizedBlockInfo.Bold) text = text; if (recognizedBlockInfo.Italic) text = text; System.out.println(text); } }
Modifier and Type | Method and Description |
---|---|
IRecognizedPartInfo[] |
getPartsInfo()
Gets an array of recognized text by parts.
|
String |
toString()
Gets whole recognized text without formatting.
|
IRecognizedPartInfo[] getPartsInfo()
Copyright © 2017. All Rights Reserved.