Building a Lightweight OCR-Powered Receipt Parser

When working with scanned receipts, extracting structured data like dates, items, and prices can be tricky due to varying fonts, layouts, and image quality. ReceiptLogger is a lightweight, local-first application that utilizes PaddleOCR to process scanned receipts efficiently. By integrating PaddleOCR with a Tkinter GUI, the app extracts text from images, parses relevant details, and logs the data into a structured format like a Google Sheet. The goal is to make receipt digitization efficient, even on low-resource machines, ensuring quick and accurate text recognition. Requirements ReceiptLogger runs on macOS (tested on an M1 Mac) with Python 3.12.9. It uses PaddleOCR version 2.9.1 for text extraction and Tcl/Tk version 8 for the GUI. Make sure these dependencies are installed before running the app. App Structure The app has two main components, the main script containing the Tkinter class for the GUI (main.py) and the helper script that extracts the data from the OCR response (process_data.py). main.py main.py handles the core workflow of the app, from receiving images to extracting and storing data. It initializes a folder in Desktop to store uploaded receipt images, processes each image with PaddleOCR to extract text and relevant details, and finally uploads the structured data to Google Sheets for storage. Below are the two main parts of the class, the initialization of key variables and the creation of the UI components. class ReceiptLogger: def __init__(self, root): self.initialize_variables(root) self.create_ui() def initialize_variables(self, root): self.ocr = PaddleOCR(use_angle_cls=True, lang='en') self.root = root self.root.title('ReceiptLogger') self.receipts_folder = os.path.join(os.path.expanduser('~'), 'Desktop', '

Feb 27, 2025 - 20:22
 0
Building a Lightweight OCR-Powered Receipt Parser

When working with scanned receipts, extracting structured data like dates, items, and prices can be tricky due to varying fonts, layouts, and image quality. ReceiptLogger is a lightweight, local-first application that utilizes PaddleOCR to process scanned receipts efficiently. By integrating PaddleOCR with a Tkinter GUI, the app extracts text from images, parses relevant details, and logs the data into a structured format like a Google Sheet. The goal is to make receipt digitization efficient, even on low-resource machines, ensuring quick and accurate text recognition.

Requirements

ReceiptLogger runs on macOS (tested on an M1 Mac) with Python 3.12.9. It uses PaddleOCR version 2.9.1 for text extraction and Tcl/Tk version 8 for the GUI. Make sure these dependencies are installed before running the app.

App Structure

The app has two main components, the main script containing the Tkinter class for the GUI (main.py) and the helper script that extracts the data from the OCR response (process_data.py).

main.py

main.py handles the core workflow of the app, from receiving images to extracting and storing data. It initializes a folder in Desktop to store uploaded receipt images, processes each image with PaddleOCR to extract text and relevant details, and finally uploads the structured data to Google Sheets for storage. Below are the two main parts of the class, the initialization of key variables and the creation of the UI components.

class ReceiptLogger:
    def __init__(self, root):
        self.initialize_variables(root)
        self.create_ui()

    def initialize_variables(self, root):
        self.ocr = PaddleOCR(use_angle_cls=True, lang='en')
        self.root = root
        self.root.title('ReceiptLogger')
        self.receipts_folder = os.path.join(os.path.expanduser('~'), 'Desktop', '