public abstract class AbstractTesseract4OcrEngine extends Object implements IOcrEngine, IProductAware
IOcrEngine.
This class provides possibilities to perform OCR, to read data from input
files and to return contained text in the required format.
Also there are possibilities to use features of "tesseract"
(optical character recognition engine for various operating systems).| Constructor and Description |
|---|
AbstractTesseract4OcrEngine(Tesseract4OcrEngineProperties tesseract4OcrEngineProperties)
Creates a new
Tesseract4OcrEngineProperties instance
based on another Tesseract4OcrEngineProperties instance (copy
constructor). |
| Modifier and Type | Method and Description |
|---|---|
void |
createTxtFile(List<File> inputImages,
File txtFile)
Performs OCR using provided
IOcrEngine for the given list of
input images and saves output to a text file using provided path. |
void |
createTxtFile(List<File> inputImages,
File txtFile,
OcrProcessContext ocrProcessContext)
Performs OCR using provided
IOcrEngine for the given list of
input images and saves output to a text file using provided path. |
Map<Integer,List<TextInfo>> |
doImageOcr(File input)
Reads data from the provided input image file and returns retrieved
data in the format described below.
|
Map<Integer,List<TextInfo>> |
doImageOcr(File input,
OcrProcessContext ocrProcessContext)
Reads data from the provided input image file and returns retrieved
data in the format described below.
|
String |
doImageOcr(File input,
OutputFormat outputFormat)
Reads data from the provided input image file and returns retrieved
data as string.
|
String |
doImageOcr(File input,
OutputFormat outputFormat,
OcrProcessContext ocrProcessContext)
Reads data from the provided input image file and returns retrieved
data as string.
|
void |
doTesseractOcr(File inputImage,
File outputFile,
OutputFormat outputFormat)
Performs tesseract OCR for the first (or for the only) image page.
|
void |
doTesseractOcr(File inputImage,
File outputFile,
OutputFormat outputFormat,
OcrProcessContext ocrProcessContext)
Performs tesseract OCR for the first (or for the only) image page.
|
String |
getLanguagesAsString()
Gets list of languages concatenated with "+" symbol to a string
in format required by tesseract.
|
PdfOcrMetaInfoContainer |
getMetaInfoContainer() |
com.itextpdf.commons.actions.data.ProductData |
getProductData() |
Tesseract4OcrEngineProperties |
getTesseract4OcrEngineProperties()
Gets properties for
AbstractTesseract4OcrEngine. |
String |
identifyOsType()
Identifies type of current OS and return it (win, linux).
|
boolean |
isWindows()
Checks current os type.
|
void |
setTesseract4OcrEngineProperties(Tesseract4OcrEngineProperties tesseract4OcrEngineProperties)
Sets properties for
AbstractTesseract4OcrEngine. |
void |
validateLanguages(List<String> languagesList)
Validates list of provided languages and
checks if they all exist in given tess data directory.
|
public AbstractTesseract4OcrEngine(Tesseract4OcrEngineProperties tesseract4OcrEngineProperties)
Tesseract4OcrEngineProperties instance
based on another Tesseract4OcrEngineProperties instance (copy
constructor).tesseract4OcrEngineProperties - the other Tesseract4OcrEngineProperties instancepublic void doTesseractOcr(File inputImage, File outputFile, OutputFormat outputFormat)
inputImage - input image FileoutputFile - output file for the result for the first pageoutputFormat - selected OutputFormat for tesseractpublic void doTesseractOcr(File inputImage, File outputFile, OutputFormat outputFormat, OcrProcessContext ocrProcessContext)
inputImage - input image FileoutputFile - output file for the result for the first pageoutputFormat - selected OutputFormat for tesseractocrProcessContext - ocr process contextpublic void createTxtFile(List<File> inputImages, File txtFile)
IOcrEngine for the given list of
input images and saves output to a text file using provided path.createTxtFile in interface IOcrEngineinputImages - List of images to be OCRedtxtFile - file to be createdpublic void createTxtFile(List<File> inputImages, File txtFile, OcrProcessContext ocrProcessContext)
IOcrEngine for the given list of
input images and saves output to a text file using provided path.createTxtFile in interface IOcrEngineinputImages - List of images to be OCRedtxtFile - file to be createdocrProcessContext - ocr process contextpublic final Tesseract4OcrEngineProperties getTesseract4OcrEngineProperties()
AbstractTesseract4OcrEngine.Tesseract4OcrEnginePropertiespublic final void setTesseract4OcrEngineProperties(Tesseract4OcrEngineProperties tesseract4OcrEngineProperties)
AbstractTesseract4OcrEngine.tesseract4OcrEngineProperties - set of properties
Tesseract4OcrEngineProperties for AbstractTesseract4OcrEnginepublic final String getLanguagesAsString()
String of concatenated languagespublic final Map<Integer,List<TextInfo>> doImageOcr(File input)
doImageOcr in interface IOcrEngineinput - input image FileMap where key is Integer
representing the number of the page and value is
List of TextInfo elements where each
TextInfo element contains a word or a line and its 4
coordinates(bbox)public final Map<Integer,List<TextInfo>> doImageOcr(File input, OcrProcessContext ocrProcessContext)
doImageOcr in interface IOcrEngineinput - input image FileocrProcessContext - ocr process contextMap where key is Integer
representing the number of the page and value is
List of TextInfo elements where each
TextInfo element contains a word or a line and its 4
coordinates(bbox)public final String doImageOcr(File input, OutputFormat outputFormat, OcrProcessContext ocrProcessContext)
input - input image FileoutputFormat - return OutputFormat resultocrProcessContext - ocr process contextString that is
returned after processing the given imagepublic final String doImageOcr(File input, OutputFormat outputFormat)
input - input image FileoutputFormat - return OutputFormat resultString that is
returned after processing the given imagepublic boolean isWindows()
public String identifyOsType()
Stringpublic void validateLanguages(List<String> languagesList) throws PdfOcrTesseract4Exception
languagesList - List of provided languagesPdfOcrTesseract4Exception - if tess data wasn't found for one of the
languages from the provided listpublic PdfOcrMetaInfoContainer getMetaInfoContainer()
getMetaInfoContainer in interface IProductAwarepublic com.itextpdf.commons.actions.data.ProductData getProductData()
getProductData in interface IProductAwareCopyright © 1998–2024 Apryse Group NV. All rights reserved.