Skip to main content

What is Tesseract?

Google’s open-source OCR engine with 100+ language support. Best for traditional OCR with extensive language coverage.

Usage

from upsonic.ocr import OCR
from upsonic.ocr.tesseract import TesseractOCR

# Create OCR with Tesseract
ocr = OCR(TesseractOCR, languages=['eng', 'fra'], enhance_contrast=True)

# Extract text
text = ocr.get_text('receipt.jpg')
print(text)

# Custom Tesseract configuration
result = ocr.process_file('document.pdf', psm=3, oem=3)
print(f"Text: {result.text}")

Parameters

ParameterTypeDefaultDescription
languagesList[str]['eng']List of Tesseract language codes
tesseract_cmdstrNonePath to tesseract executable
confidence_thresholdfloat0.0Minimum confidence for text blocks
rotation_fixboolFalseAuto-detect and fix image rotation
enhance_contrastboolFalseEnhance image contrast
remove_noiseboolFalseApply noise reduction
preserve_formattingboolTruePreserve text layout and formatting
psmint3Page segmentation mode (0-13)
oemint3OCR Engine Mode (0-3)
custom_configstr''Additional Tesseract configuration string

Supported Languages

100+ languages including all major languages. Requires language packs to be installed separately.

Installation Note

Tesseract must be installed on the system:
  • Ubuntu/Debian: sudo apt-get install tesseract-ocr
  • macOS: brew install tesseract
  • Windows: Download installer from GitHub