Receipt OCR Engine
An efficient OCR engine for receipt image processing.
This repository provides a comprehensive solution for Optical Character Recognition (OCR) on receipt images, featuring both a dedicated Tesseract OCR module and a general receipt processing package using LLMs.
Star History
Table of Contents
Quick Start
Extract structured data from a receipt in 3 steps:
Install the package:
pip install receipt-ocrSet up your API key:
export OPENAI_API_KEY="your_openai_api_key_here"Process a receipt:
receipt-ocr images/receipt.jpg
For Docker or advanced usage, see How to Use Receipt OCR below.
Project Structure
The project is organized into two main modules:
src/receipt_ocr/: A new package for abstracting general receipt processing logic, including CLI, programmatic API, and a production FastAPI web service for LLM-powered structured data extraction from receipts.src/tesseract_ocr/: Contains the Tesseract OCR FastAPI application, CLI, utility functions, and Docker setup for performing raw OCR text extraction from images.
Prerequisites
- Python 3.x
- Docker & Docker-compose(for running as a service)
- Tesseract OCR (for local Tesseract CLI usage) - Installation Guide
How to Use Receipt OCR
Receipt OCR Module (Structured Data Extraction)
This module provides a higher-level abstraction for processing receipts, leveraging LLMs for parsing and extraction.
To use the receipt-ocr CLI, first install it:
pip install receipt-ocr
Configure Environment Variables: Create a
.envfile in the project root or set environment variables directly. This module supports multiple LLM providers.Supported Providers:
OpenAI:
Get API key from: https://platform.openai.com/api-keys
OPENAI_API_KEY="your_openai_api_key_here" OPENAI_MODEL="gpt-4o"Gemini (Google):
Get API key from: https://aistudio.google.com/app/apikey
OPENAI_API_KEY="your_gemini_api_key_here" OPENAI_BASE_URL="https://generativelanguage.googleapis.com/v1beta/openai/" OPE