Skip to main content

EasyOCR Basic Example

from upsonic.ocr import OCR
from upsonic.ocr.layer_1.engines import EasyOCREngine
import urllib.request

# Download a sample image for testing
url = "https://raw.githubusercontent.com/JaidedAI/EasyOCR/master/examples/english.png"
urllib.request.urlretrieve(url, "sample_image.png")

# Configure engine with preprocessing for best results
engine = EasyOCREngine(
    languages=['en'],
    confidence_threshold=0.6,
    rotation_fix=True,
    enhance_contrast=True,
    remove_noise=True,
    pdf_dpi=250,
    gpu=True
)

# Create OCR orchestrator
ocr = OCR(layer_1_ocr_engine=engine)

# Run OCR on the sample image
result = ocr.get_text("sample_image.png")
print(result)

Multi-Language Support

EasyOCR supports 80+ languages. You can find the full list of supported languages in the EasyOCR repository.