Name | readyocr JSON |
Version |
0.0.43
JSON |
| download |
home_page | |
Summary | A nice package OCR for Amazon Textract and Google Document AI |
upload_time | 2023-10-18 07:50:21 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.8 |
license | Copyright 2023 Sy An Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
ocr
textract
documentai
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
[![License: MIT](https://img.shields.io/github/license/syanng/readyocr)](https://opensource.org/licenses/MIT) [![PyPI Version](https://img.shields.io/pypi/v/readyocr)](https://pypi.org/project/readyocr/) [![Downloads](https://img.shields.io/pypi/dm/readyocr)](https://pypi.org/project/readyocr/)
# ReadyOCR
ReadyOCR is a Python library that allows you to quickly and easily parse data from various OCR API services, including AWS Textract and Google Document AI. The package also comes with nice features for searching and visualizing.
![Textract Output Visualize](https://raw.githubusercontent.com/syanng/readyocr/main/images/visualize.png)
## Installation
You can install ReadyOCR using pip. Depending on the OCR API service you want to use, you can install the corresponding version of ReadyOCR:
* For minimal usage, if you only want to create ReadyOCR document object format:
```
pip install readyocr
```
* Or you can choose a specific version to support a specific API response:
```
# support AWS Textract response
pip install "readyocr[textract]"
# support Google Document AI response
pip install "readyocr[documentai]"
# support all available
pip install "readyocr[all]"
```
## Basic Usage
* ReadyOCR allows you to create a Document object, which represents the OCR results. A Document can contain one or many pages, and each page can have multiple page entity objects, such as line, word, or table.
```
from readyocr.entities import Document, Page, Block, Paragraph, Line, Word, Table, Cell, Key, Value
document = Document(...)
page = Page(...)
word = Word(...)
# linking all object
page.add(word)
document.pages.append(page)
```
* You can define any document structure you want by using the `.children` property for page entities. For example, a line object can have many word objects as children.
```
page = Page(...)
line = Line(...)
word1 = Word(...)
word2 = Word(...)
line.children = [word1, word2]
# add line object to page children
page.add(line)
# you can get descendant of a object
all_page_entity = page.descendant
# you can also filter all object by class, tag or attribute
all_word = page.descendant.filter_by_class(Word)
```
* ReadyOCR allows you to read PDF file with page object Line, Character, Figure, and Image. You can read from both path and byte stream
```
from readyocr.parsers.pdf_parser import load
document = load(pdf_path, load_image=True, remove_text=False)
...
with open(pdf_path, 'rb') as fp:
byte_obj = fp.read()
document = load(byte_obj, load_image=True, remove_text=False)
```
* You can also use tags attribute to identify some specific attribute:
```
table = Table(...)
cell = Cell(...)
cell.tags.add('COLUMN_HEADER')
table.add(cell)
# Get all table cell which is column header
table.children.filter_by_tags('COLUMN_HEADER')
```
* ReadyOCR support export json object and also load from same json object
```
from readyocr.parsers.readyocr_parser import load
...
# python object -> python dict
dict_resp = document.export_json()
# python dict -> python object
same_document = load(dict_resp)
```
* ReadyOCR support visualize for bounding box and textbox
```
from readyocr.utils.visualize import draw_bbox, draw_textbox
bbox_image = page.image.copy()
text_image = page.image.copy()
for item in page.descendants.filter_by_class(Line):
bbox_image = draw_bbox(
image=bbox_image,
bbox=item,
fill_color=(0, 255, 0),
outline_color=(0, 255, 0),
opacity=0.2
)
text_image = draw_textbox(
image=text_image,
textbox=item,
padding=1,
true_font_path="../fonts/arial.ttf",
)
```
![Textract Textbox Output Visualize](https://raw.githubusercontent.com/syanng/readyocr/main/images/visualize_textbox.png)
### Examples
Please find all the available [examples](examples/) for better understanding ReadyOCR.
### License
ReadyOCR is released under the MIT license. See the [LICENSE](LICENSE) file for more details.
Raw data
{
"_id": null,
"home_page": "",
"name": "readyocr",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "ocr,textract,documentai",
"author": "",
"author_email": "Sy An <syan.vn@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/cd/3e/2ec2eb8160a6298361bb77d6e779b907c1c1fff3fdc32043ebfae6c0fe6b/readyocr-0.0.43.tar.gz",
"platform": null,
"description": "[![License: MIT](https://img.shields.io/github/license/syanng/readyocr)](https://opensource.org/licenses/MIT) [![PyPI Version](https://img.shields.io/pypi/v/readyocr)](https://pypi.org/project/readyocr/) [![Downloads](https://img.shields.io/pypi/dm/readyocr)](https://pypi.org/project/readyocr/)\n\n\n# ReadyOCR\n\nReadyOCR is a Python library that allows you to quickly and easily parse data from various OCR API services, including AWS Textract and Google Document AI. The package also comes with nice features for searching and visualizing.\n\n![Textract Output Visualize](https://raw.githubusercontent.com/syanng/readyocr/main/images/visualize.png)\n\n## Installation\n\nYou can install ReadyOCR using pip. Depending on the OCR API service you want to use, you can install the corresponding version of ReadyOCR:\n\n* For minimal usage, if you only want to create ReadyOCR document object format:\n\n ```\n pip install readyocr\n ```\n\n* Or you can choose a specific version to support a specific API response:\n\n ```\n # support AWS Textract response\n pip install \"readyocr[textract]\"\n\n # support Google Document AI response\n pip install \"readyocr[documentai]\"\n\n # support all available\n pip install \"readyocr[all]\"\n ```\n\n## Basic Usage\n\n* ReadyOCR allows you to create a Document object, which represents the OCR results. A Document can contain one or many pages, and each page can have multiple page entity objects, such as line, word, or table.\n\n ```\n from readyocr.entities import Document, Page, Block, Paragraph, Line, Word, Table, Cell, Key, Value\n\n document = Document(...)\n page = Page(...)\n word = Word(...)\n\n # linking all object\n page.add(word)\n document.pages.append(page)\n ```\n\n* You can define any document structure you want by using the `.children` property for page entities. For example, a line object can have many word objects as children.\n\n ```\n page = Page(...)\n line = Line(...)\n word1 = Word(...)\n word2 = Word(...)\n\n line.children = [word1, word2]\n\n # add line object to page children\n page.add(line)\n\n # you can get descendant of a object\n all_page_entity = page.descendant\n\n # you can also filter all object by class, tag or attribute\n all_word = page.descendant.filter_by_class(Word)\n ```\n\n* ReadyOCR allows you to read PDF file with page object Line, Character, Figure, and Image. You can read from both path and byte stream\n ```\n from readyocr.parsers.pdf_parser import load\n \n document = load(pdf_path, load_image=True, remove_text=False)\n ...\n with open(pdf_path, 'rb') as fp:\n byte_obj = fp.read()\n document = load(byte_obj, load_image=True, remove_text=False)\n ```\n\n* You can also use tags attribute to identify some specific attribute:\n\n ```\n table = Table(...)\n cell = Cell(...)\n cell.tags.add('COLUMN_HEADER')\n table.add(cell)\n\n # Get all table cell which is column header\n table.children.filter_by_tags('COLUMN_HEADER') \n ```\n\n* ReadyOCR support export json object and also load from same json object\n\n ```\n from readyocr.parsers.readyocr_parser import load\n\n ...\n # python object -> python dict\n dict_resp = document.export_json()\n\n # python dict -> python object\n same_document = load(dict_resp)\n ```\n\n* ReadyOCR support visualize for bounding box and textbox\n\n ```\n from readyocr.utils.visualize import draw_bbox, draw_textbox\n \n bbox_image = page.image.copy()\n text_image = page.image.copy()\n\n for item in page.descendants.filter_by_class(Line):\n bbox_image = draw_bbox(\n image=bbox_image,\n bbox=item,\n fill_color=(0, 255, 0),\n outline_color=(0, 255, 0), \n opacity=0.2\n )\n text_image = draw_textbox(\n image=text_image, \n textbox=item,\n padding=1,\n true_font_path=\"../fonts/arial.ttf\",\n )\n ```\n\n ![Textract Textbox Output Visualize](https://raw.githubusercontent.com/syanng/readyocr/main/images/visualize_textbox.png)\n\n### Examples\n\nPlease find all the available [examples](examples/) for better understanding ReadyOCR.\n\n### License\n\nReadyOCR is released under the MIT license. See the [LICENSE](LICENSE) file for more details.\n",
"bugtrack_url": null,
"license": "Copyright 2023 Sy An Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \u201cSoftware\u201d), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \u201cAS IS\u201d, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "A nice package OCR for Amazon Textract and Google Document AI",
"version": "0.0.43",
"project_urls": {
"Bug Tracker": "https://github.com/syanng/readyocr/issues",
"Homepage": "https://github.com/syanng/readyocr"
},
"split_keywords": [
"ocr",
"textract",
"documentai"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ba9a23e2588e6077ddfc3bcdeee4aca07b15c59315914193f04bf05155849c03",
"md5": "949e37bcdacb2e954193029788703888",
"sha256": "8c17da599590e919d306b5446550bf7c1a60d7874564657bc8d1a6d351d1c0d0"
},
"downloads": -1,
"filename": "readyocr-0.0.43-py3-none-any.whl",
"has_sig": false,
"md5_digest": "949e37bcdacb2e954193029788703888",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 41244,
"upload_time": "2023-10-18T07:50:20",
"upload_time_iso_8601": "2023-10-18T07:50:20.040078Z",
"url": "https://files.pythonhosted.org/packages/ba/9a/23e2588e6077ddfc3bcdeee4aca07b15c59315914193f04bf05155849c03/readyocr-0.0.43-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cd3e2ec2eb8160a6298361bb77d6e779b907c1c1fff3fdc32043ebfae6c0fe6b",
"md5": "c7b974a340a2644f2cd070979915199e",
"sha256": "9256799f3718988600768453185ce0a97ac3da2bb7d67c45ac6e3266948431fa"
},
"downloads": -1,
"filename": "readyocr-0.0.43.tar.gz",
"has_sig": false,
"md5_digest": "c7b974a340a2644f2cd070979915199e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 30414,
"upload_time": "2023-10-18T07:50:21",
"upload_time_iso_8601": "2023-10-18T07:50:21.902121Z",
"url": "https://files.pythonhosted.org/packages/cd/3e/2ec2eb8160a6298361bb77d6e779b907c1c1fff3fdc32043ebfae6c0fe6b/readyocr-0.0.43.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-18 07:50:21",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "syanng",
"github_project": "readyocr",
"github_not_found": true,
"lcname": "readyocr"
}