Skip to content

Extracts text from images using manual selection of regions of interest. GUI for easy image loading and text extraction (OCR).

Notifications You must be signed in to change notification settings

banatibalazs/image_text_extractor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Image text extractor

Python Tkinter OpenCV Pillow Pytesseract Numpy PDF2Image

Overview

image_text_extractor is a Python-based application designed to extract text from images.

  • GUI for image loading and text extraction
  • Manual selection of regions of interest
  • Text extraction from selected regions

Note: This project was only tested on Windows.

Demo Video

Watch the video

Demo Images

Main Menu Mask Drawing Mode Rect Mask Drawing Mode Free Mask Drawing Mode csv

Features

  • Image Loading: Load images from a folder or individual files.
  • Mask Drawing Modes: Supports freehand and rectangle drawing modes for selecting regions of interest.
  • Text Extraction: Extract text from selected regions using Tesseract OCR.
  • Text Copying: Copy extracted text to a text field with options to preserve text structure.
  • File Dialogs: Open text files to display their content in the GUI.

Requirements

  • Python 3.x
  • Tesseract OCR
  • Python packages: opencv-python, pillow, pytesseract, numpy, matplotlib

Installation

Python Packages

To install the required packages, run the following command:

pip install -r requirements.txt

Tesseract OCR

  1. Windows:

    • Download the Tesseract installer from Tesseract at UB Mannheim.
    • Run the installer and follow the instructions.
    • Add the Tesseract installation path (e.g., C:\Program Files\Tesseract-OCR) to your system's PATH environment variable.
  2. macOS (not tested):

    • Install Tesseract using Homebrew:
      brew install tesseract
  3. Linux (not tested):

    • Install Tesseract using your package manager. For example, on Ubuntu:
      sudo apt-get install tesseract-ocr

Language Packs

To install additional language packs for Tesseract:

  1. Windows:

    • Download the desired language pack (e.g., fra.traineddata for French) from the Tesseract GitHub repository.
    • Copy the downloaded .traineddata file to the tessdata directory of your Tesseract installation (e.g., C:\Program Files\Tesseract-OCR\tessdata).
  2. macOS (not tested):

    • Use Homebrew to install the language pack:
      brew install tesseract-lang
  3. Linux (Ubuntu) (not tested):

    • Use your package manager to install the language pack. For example, to install the French language pack:
      sudo apt-get install tesseract-ocr-fra

Usage

  1. Run the Application: Execute the extractor.py script to start the application.
  2. Load Images: Use the file dialog to load images from a folder.
  3. Select Drawing Mode: Choose between freehand and rectangle drawing modes.
  4. Draw on Image: Draw on the image to select the region of interest.
  5. Extract Text: Extract text from the selected region and copy it to the text field.
  6. Save or Copy Text: Save the extracted text or copy it to the clipboard.

Note: Ensure to update the tesseract_cmd path in the code to match your Tesseract installation path

pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'

About

Extracts text from images using manual selection of regions of interest. GUI for easy image loading and text extraction (OCR).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages