Java | OCR
Setup
for support of other languages
Using custom tessdata
Download trained tessdata for several languages and put them under folder, it could be located under resource folder or any other path outside of the application If folder is located under resource folder, use the next code
or if you know the absolute path, just write it in the setDataPath
Under the folder you will have files with the next names:
deu.traineddata
eng.traineddata
osd.traineddata
the first part of the name is important, we will use for setting languages
Set language
The image that you will OCRing could contain one or multiple languages, in that case you will need to define which language is expected, by default eng
is enabled
Get OCR result
The library tess4j
supports multiple options to work with input content, it could be File
or BufferedImage
or ByteBuffer
, also you could define do you want to extract the text from the whole file, or a concrete Bounding Box
Troubleshooting
Unable to load library 'tesseract'
This one was resolved by providing the path to jna libraries system property
Links
Last updated