AghoraGuru/Gabor-Bounding-Box

Kalyana Sundaram

ML Engineer
AI Model Developer
AI Developer
OpenCV

📷 Image Text Line Detection and Bounding Box Creation

This script processes an input image, applies Gabor filters to detect text lines, and creates bounding boxes around the detected text lines. The resulting modified image is saved with the bounding boxes, and bounding box coordinates are stored in a JSON file.

🛠️ Installation

Make sure you have Python installed on your system.
Install the required packages by running:
pip install opencv-python

🚀 Usage

Replace img_path with the path to the image you want to process.
Adjust the Gabor filter parameters in the cv2.getGaborKernel function to fine-tune the text line detection.
Tweak the parameters in the cv2.HoughLinesP function for line detection.
Run the script:
python bounding_box.py

🔍 Script Explanation

The script follows these steps:
Load the image using OpenCV.
Create a Gabor filter bank using cv2.getGaborKernel.
Apply Gabor filters to the image and store the filtered images.
Detect edges using the Canny edge detector.
Use Hough Transform to detect lines.
Group lines based on y-coordinates to form text lines.
Create a new folder to save the modified image and boxed text lines.
Iterate through grouped lines, draw bounding boxes, and save boxed images.
Store bounding box coordinates in a dictionary and save as JSON.
Save the modified image with bounding boxes.

🤝 Help me out with Filter Parameters

Do let me know if you found a better parameter for any filter being used; it would mean a lot!
Partner With Kalyana
View Services

More Projects by Kalyana