Skip to content

Efficient OCR engine for receipt image processing using Python, FastAPI, and Tesseract

License

Notifications You must be signed in to change notification settings

bhimrazy/receipt-ocr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Receipt OCR Engine

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

image

Star History

Star History Chart

Prerequisites

  • Python 3.x
  • Docker
  • Docker-compose

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:

  • POST /ocr/: Upload a receipt image file to perform OCR. The response will contain the extracted text from the receipt.

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