OCR toolkits
Introduction
Collection of functions to work with ocr and synthetic data generater
Features
- Generate synthetic images containing Khmer text
- Customize text content from a file
- Choose from multiple font styles
- Option to apply random blur effect to images
- Generate corresponding labels for each image
Installation
You can install the Khmer Text Image Generator using pip:
pip install ocr_toolkits
Usage
-
create text file to words list eg. dict.txt and put all khmer words you want to gnerate or download sample data here
-
create a folder call font and download all font from this link : font
-
create python script to generate data eg. test.py
from khmerocr_tools import synthetic_data
# Set parameters
image_height = 128
output_folder = 'output'
output_labels_file = 'output/labels.txt'
text_file_path = "dict.txt"
font_option = [1, 2]
# Generate images and labels
synthetic_data(
text_file_path,
image_height,
output_folder,
output_labels_file,
font_option=font_option,
random_blur=True
)
Parameters
image_height: Height of the generated images in pixels.output_folder: Path to the folder where generated images will be saved.output_labels_file: Path to the file where labels will be saved.text_file_path: Path to the text file containing Khmer text for generation.font_option: List of integers representing font options.- 1 for AKbalthom KhmerLer Regular.
- 2 for Khmer MEF1 Regular.
- 3 for Khmer OS Battambang Regular.
- 4 for Khmer OS Muol Light Regular.
- 5 for Khmer OS Siemreap Regular.
- Use an empty list [] to select all available fonts.
random_blur: Boolean flag indicating whether to apply random blur effect to images.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for ocr-toolkits 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ocr-toolkits-0.0.2.tar.gz | 8.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ocr_toolkits-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.8 kB
Release files / ocr-toolkits-0.0.2.tar.gz
| Download URL | ocr-toolkits-0.0.2.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
86cd7932588e77b83103e7630709cb065bbec8b00015db423290271d7cdda980
|
|
BLAKE2b-256 checksum How to use checksums |
0339cf46333ec43b148a5fb07a8530066f0e1ec8666cecfd74fd77edaf6c0de9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.4
|
Release files / ocr_toolkits-0.0.2-py3-none-any.whl
| Download URL | ocr_toolkits-0.0.2-py3-none-any.whl |
|---|---|
| Size | 8.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ac96e2c6d98e949eb9b88077a08d7fe45584ffe1e6d736b59238fe968514c4c1
|
|
BLAKE2b-256 checksum How to use checksums |
8f57f045a68966a948768879900a940c563cf2adcdcb932ca39c60b0c0e8d1df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.4
|