bhimrazy / receipt-ocr

Efficient OCR engine for receipt image processing using Python, FastAPI, and Tesseract
MIT License
20 stars 7 forks source link
ocr pytesseract tesseract-ocr

Receipt OCR Engine

This repository hosts a script and a Docker-compose setup for performing Optical Character Recognition (OCR) on receipt images.

image

Prerequisites

Installation

Clone the repository

git clone https://github.com/bhimrazy/receipt-ocr.git
cd receipt-ocr

Set up Python environment (if not using Docker)

# Create and activate a virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate  # For Windows, use venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

Usage

Running the script locally

main.py

The main.py script performs OCR on an input image of a receipt.

python main.py -i images/receipt.jpg

Replace images/receipt.jpg with the path to your receipt image.

Please ensure that the image is well-lit and that the edges of the receipt are clearly visible and detectable within the image.

Receipt Image

Using Docker-compose

The repository includes a Docker-compose setup for running the OCR engine as a service.

docker-compose up

Once the service is up and running, you can perform OCR on receipt images by sending a POST request to http://localhost:8000/ocr/ with the image file.

API Endpoint

The OCR functionality can be accessed via a FastAPI endpoint:

Example usage with cURL:

curl -X 'POST' \
  'http://localhost:8000/ocr/' \
  -H 'accept: application/json' \
  -H 'Content-Type: multipart/form-data' \
  -F 'file=@images/paper-cash-sell-receipt-vector-23876532.jpg;type=image/jpeg'

Using Gemini

image

License

This project is licensed under the terms of the MIT license.

References