A dynamic, interactive computer-vision tool to extract precise word-level and line-level bounding boxes from PDFs and images. Fine-tuned for Arabic script by default, but fully adjustable for any alphabet.
Arabic (Default):
Latin Alphabet:
- Clone the repository.
- Create and activate a conda environment:
conda create -n qiraah python=3.10 conda activate qiraah
- Install dependencies:
pip install -r requirements.txt
Run with or without a file path:
python main.py
# Or with a specific file
python main.py path/to/document.pdfControls: d (Next), a (Previous), g (Go to page), ESC (Exit).
- Use Otsu: Set to
1to let the tool automatically find the best black & white balance. Set to0to adjust it manually. - Thresh Val: If Otsu is
0, adjust this to manually change the black & white balance. Increase to make text thicker/darker. - Kernel X: Controls horizontal grouping. Increase this to connect disconnected letters into single words.
- Kernel Y: Controls vertical grouping. Keep this low to prevent different text lines from bleeding into each other.
- Min Width / Height: Filters out small specks of dirt or noise. Boxes smaller than these values are ignored.
- Max Height: If a box gets too tall, the tool assumes multiple lines merged by mistake and splits them.
- Max Width: If a box gets too wide, the tool assumes words merged into a paragraph and splits them.
- Merge Dist: The maximum pixel distance between two boxes to combine them into one word.
- Refine On: Set to
1to enable an extra cleanup pass that fixes overly large boxes. - Max Merge W / H: During cleanup, any box larger than these limits gets broken down again.
- Close Merge D: During cleanup, uses a smaller, stricter distance to safely reconnect broken words.
- Margin L/R/U/D: Adds a clean border (Left, Right, Up, Down) around your final bounding boxes.



