Metadata-Version: 2.2
Name: pmsh-ocr
Version: 0.0.1
Summary: Primary Math Screen Handwriting OCR (pmsh-ocr) is a Python package for recognizing primary mathematical expressions handwritten on screen.
Author-email: Martin HM MaDing <mading5@xdf.cn>
License: MIT
Project-URL: Homepage, https://github.com/yourusername/pmsh-ocr
Keywords: Primary Math,Screen Handwriting,OCR
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: opencv-python
Requires-Dist: numpy
Requires-Dist: onnxruntime

# pmsh-ocr

Primary Math Screen Handwriting OCR (pmsh-ocr) is a Python package for recognizing primary school mathematical expressions handwritten on screen.

## Features

- Recognize primary mathematical expressions handwritten on screen
- Vocabulary: `['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '-', '<', '=', '>', '\frac', '{', '}']`
- Support recognizing expression with input reference text, e.g. answer
- Model trained with max token length 40

## Installation

```bash
pip install pmsh-ocr
```

## Usage

```python
import cv2

from pmsh import PMSHOCR

ocr = PMSHOCR()

image = cv2.imread('path_to_image')
ref_text = 'some reference txt'
result = ocr.inference(image, ref_text)
print(result)
```

example of result:

```json
{
    "box": [0, 0, 384, 288], # [x1, y1, x2, y2]
    "ctc_text": "-15",       # text not referring the input ref_text
    "ctc_prob": 0.999,
    # if the input ref_text is None, the following keys will not output
    "ar_text": "-15",        # text referring the input ref_text
    "ar_prob": 0.92
}
```

## License

This project is licensed under the MIT License.
