Package org.apache.tika.parser.ocr
Class TesseractOCRParser
java.lang.Object
org.apache.tika.parser.AbstractExternalProcessParser
org.apache.tika.parser.ocr.TesseractOCRParser
- All Implemented Interfaces:
Serializable,Initializable,SelfConfiguring,Parser
TesseractOCRParser powered by tesseract-ocr engine. To enable this parser,
create a
TesseractOCRConfig object and pass it through a
ParseContext. Tesseract-ocr must be installed and on system path or the path
to its root folder must be provided:
TesseractOCRConfig config = new TesseractOCRConfig();
//Needed if tesseract is not on system path
config.setTesseractPath(tesseractFolder);
parseContext.set(TesseractOCRConfig.class, config);
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTesseractOCRParser(JsonConfig jsonConfig) Constructor for JSON configuration.TesseractOCRParser(TesseractOCRConfig tesseractOCRConfig) -
Method Summary
Modifier and TypeMethodDescriptionvoidstatic StringgetLangs()getSupportedTypes(ParseContext context) Returns the set of media types supported by this parser when used with the given parse context.static Stringbooleanprotected booleanvoidCalled after all properties have been set to allow for validation and initialization that depends on multiple properties.voidparse(Image image, ContentHandler handler, Metadata metadata, ParseContext context) voidparse(TikaInputStream tis, ContentHandler handler, Metadata metadata, ParseContext parseContext) Parses a document stream into a sequence of XHTML SAX events.voidsetOtherTesseractSettings(List<String> settings) protected voidwarn()Methods inherited from class org.apache.tika.parser.AbstractExternalProcessParser
register, release
-
Field Details
-
TESS_META
- See Also:
-
IMAGE_ROTATION
-
IMAGE_MAGICK
-
PSM0_PAGE_NUMBER
-
PSM0_ORIENTATION
-
PSM0_ROTATE
-
PSM0_ORIENTATION_CONFIDENCE
-
PSM0_SCRIPT
-
PSM0_SCRIPT_CONFIDENCE
-
-
Constructor Details
-
TesseractOCRParser
- Throws:
TikaConfigException
-
TesseractOCRParser
- Throws:
TikaConfigException
-
TesseractOCRParser
Constructor for JSON configuration. Requires Jackson on the classpath.- Parameters:
jsonConfig- JSON configuration- Throws:
TikaConfigException
-
-
Method Details
-
getImageMagickProg
-
getTesseractProg
-
getSupportedTypes
Description copied from interface:ParserReturns the set of media types supported by this parser when used with the given parse context.- Specified by:
getSupportedTypesin interfaceParser- Parameters:
context- parse context- Returns:
- immutable set of media types
-
hasTesseract
- Throws:
TikaConfigException
-
parse
public void parse(Image image, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException - Throws:
IOExceptionSAXExceptionTikaException
-
parse
public void parse(TikaInputStream tis, ContentHandler handler, Metadata metadata, ParseContext parseContext) throws IOException, SAXException, TikaException Description copied from interface:ParserParses a document stream into a sequence of XHTML SAX events. Fills in related document metadata in the given metadata object.The given document stream is consumed but not closed by this method. The responsibility to close the stream remains on the caller.
Information about the parsing context can be passed in the context parameter. See the parser implementations for the kinds of context information they expect.
- Specified by:
parsein interfaceParserhandler- handler for the XHTML SAX events (output)metadata- document metadata (input and output)parseContext- parse context- Throws:
IOException- if the document stream could not be readSAXException- if the SAX events could not be processedTikaException- if the document could not be parsed
-
initialize
Description copied from interface:InitializableCalled after all properties have been set to allow for validation and initialization that depends on multiple properties.- Specified by:
initializein interfaceInitializable- Throws:
TikaConfigException- if there is a problem with the configuration
-
checkInitialization
- Throws:
TikaConfigException
-
getLangs
-
hasWarned
protected boolean hasWarned() -
warn
protected void warn() -
setOtherTesseractSettings
- Throws:
TikaConfigException
-
getOtherTesseractSettings
-
getDefaultConfig
-