# OCR_with_format
* simple wrapper that postprocesses pytesseract's hOCR output to maintain format and spacings.
* [Link to an alternative implementation found on stackoverflow](https://stackoverflow.com/questions/59582008/preserving-indentation-with-tesseract-ocr-4-x)
## How to
* install `python -m pip install OCR_with_format`
* see usage `OCR_with_format --help` (executing with `python -m` is not supported)
## Usage
```
NAME
OCR_with_format
SYNOPSIS
OCR_with_format IMG_PATH <flags>
POSITIONAL ARGUMENTS
IMG_PATH
Type: str
path to the image you want to do OCR on
FLAGS
-m, --method=METHOD
Type: str
Default: 'with_format'
if 'with_format', will use the author's code if 'none', will output tesseract's default output if 'stackoverflow', will output using another algorithm found on stackoverflow
--thresholding_method=THRESHOLDING_METHOD
Type: str
Default: 'otsu'
any from "otsu", "otsu_gaussian", "adaptative_gaussian", "all"
If "all", the three methods will be tried and the final output will be the one which maximizes the mean and median confidences over each parsed words.
-l, --language=LANGUAGE
Type: str
Default: 'eng'
language to look for in the image
-o, --output_path=OUTPUT_PATH
Type: Optional[str]
Default: None
if not None, will output to this path and erase its previous content.
--tesseract_args=TESSERACT_ARGS
Type: str
Default: '-...
default arguments for tesseract
-q, --quiet=QUIET
Default: False
if True, will only print the output and no logs
NOTES
You can also use flags syntax for POSITIONAL ARGUMENTS
```
## Example
* Image:
* ![](https://github.com/thiswillbeyourgithub/OCR_with_format/blob/295e724b758045dc952934b6f0d98172fdc9a12e/screenshot.png?raw=true)
* output from `OCR_with_format ./screenshot.png --thresholding_method="all" --quiet`
```
@Unwateh (1) ~ Fork (3) (©
OCR_with_format [ Pir ][ | [ & <) [ s -]
About
&
Wrapper around pytesseract to
¥ Branches © Tags postprocess in a way that preserves
spacing and formattings.
i thiswillbeyourgithub addded license 10 minutes ago O 4
&5 GPL-3.0 license
@ LICENSE addded license 10 minutes ago - Activity
[u] __init__.py minor 11 minutes ago ¢ Ostars
[u] requirements.txt added empty requirements 11 minutes ago <& 1 watching
Y Oforks
Help people interested in this repository understand your project by
adding a README. Releases
Create No releases a new published release
Packages
No packages published
Publish your first package
Languages
———
® Python 100.0%
```
* output from `OCR_with_format ./screenshot.png --quiet --comparison_run`
*
```
OCR_with_format
[ pin | [ @unwateh (@) ~ | [ & Fork (O)
-] [ ¢ s (0
¥ main ~
¥ Branches © Tags
Wrapper around pytesseract to
postprocess in a way that preserves
. . . spacing and formattings.
- thiswillbeyourgithub addded license 10 minutes ago 'O 4
&5 GPL-3.0 license
@ LICENSE addded license 10 minutes ago A Activity
0O _init__py minor 11 minutes ago ¢ Ostars
O requirements.txt added empty requirements 11 minutes ago | @ 1watching
% 0forks
Help people interested in this repository understand your project by
adding a README. Releases
No releases published
Create a new release
Packages
No packages published
Publish your first package
Languages
————
@ Python 100.0%
```
Raw data
{
"_id": null,
"home_page": null,
"name": "OCR-with-format",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "OCR, tesseract, pytesseract, format, formatting, space, spacing, spaces",
"author": "thiswillbeyourgithub",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/60/8c/e716bfad6569a4d2dabb2d790017551de5ba2a9034e850f4c9f640a9fcbc/ocr_with_format-0.12.tar.gz",
"platform": null,
"description": "# OCR_with_format\n* simple wrapper that postprocesses pytesseract's hOCR output to maintain format and spacings.\n* [Link to an alternative implementation found on stackoverflow](https://stackoverflow.com/questions/59582008/preserving-indentation-with-tesseract-ocr-4-x)\n\n## How to\n* install `python -m pip install OCR_with_format`\n* see usage `OCR_with_format --help` (executing with `python -m` is not supported)\n\n## Usage\n```\nNAME\n OCR_with_format\n\nSYNOPSIS\n OCR_with_format IMG_PATH <flags>\n\nPOSITIONAL ARGUMENTS\n IMG_PATH\n Type: str\n path to the image you want to do OCR on\n\nFLAGS\n -m, --method=METHOD\n Type: str\n Default: 'with_format'\n if 'with_format', will use the author's code if 'none', will output tesseract's default output if 'stackoverflow', will output using another algorithm found on stackoverflow\n --thresholding_method=THRESHOLDING_METHOD\n Type: str\n Default: 'otsu'\n any from \"otsu\", \"otsu_gaussian\", \"adaptative_gaussian\", \"all\"\n\n If \"all\", the three methods will be tried and the final output will be the one which maximizes the mean and median confidences over each parsed words.\n -l, --language=LANGUAGE\n Type: str\n Default: 'eng'\n language to look for in the image\n -o, --output_path=OUTPUT_PATH\n Type: Optional[str]\n Default: None\n if not None, will output to this path and erase its previous content.\n --tesseract_args=TESSERACT_ARGS\n Type: str\n Default: '-...\n default arguments for tesseract\n -q, --quiet=QUIET\n Default: False\n if True, will only print the output and no logs\n\nNOTES\n You can also use flags syntax for POSITIONAL ARGUMENTS\n\n```\n\n## Example\n\n* Image:\n * ![](https://github.com/thiswillbeyourgithub/OCR_with_format/blob/295e724b758045dc952934b6f0d98172fdc9a12e/screenshot.png?raw=true)\n* output from `OCR_with_format ./screenshot.png --thresholding_method=\"all\" --quiet`\n```\n @Unwateh (1) ~ Fork (3) (\u00a9\n OCR_with_format [ Pir ][ | [ & <) [ s -]\n About\n &\n Wrapper around pytesseract to\n\u00a5 Branches \u00a9 Tags postprocess in a way that preserves\n spacing and formattings.\n i thiswillbeyourgithub addded license 10 minutes ago O 4\n &5 GPL-3.0 license\n @ LICENSE addded license 10 minutes ago - Activity\n [u] __init__.py minor 11 minutes ago \u00a2 Ostars\n [u] requirements.txt added empty requirements 11 minutes ago <& 1 watching\n Y Oforks\n Help people interested in this repository understand your project by\n adding a README. Releases\n Create No releases a new published release\n Packages\n No packages published\n Publish your first package\n Languages\n \u2014\u2014\u2014\n \u00ae Python 100.0%\n```\n* output from `OCR_with_format ./screenshot.png --quiet --comparison_run`\n *\n```\nOCR_with_format\n\n[ pin | [ @unwateh (@) ~ | [ & Fork (O)\n\n-] [ \u00a2 s (0\n\n\u00a5 main ~\n\n\u00a5 Branches \u00a9 Tags\n\nWrapper around pytesseract to\npostprocess in a way that preserves\n\n. . . spacing and formattings.\n- thiswillbeyourgithub addded license 10 minutes ago 'O 4\n&5 GPL-3.0 license\n@ LICENSE addded license 10 minutes ago A Activity\n0O _init__py minor 11 minutes ago \u00a2 Ostars\nO requirements.txt added empty requirements 11 minutes ago | @ 1watching\n% 0forks\nHelp people interested in this repository understand your project by\nadding a README. Releases\n\nNo releases published\nCreate a new release\n\nPackages\n\nNo packages published\nPublish your first package\n\nLanguages\n\n\u2014\u2014\u2014\u2014\n@ Python 100.0%\n```\n",
"bugtrack_url": null,
"license": "GNU General Public License v3 or later (GPLv3+)",
"summary": "Wrapper to pytesseract to preserve space and formatting",
"version": "0.12",
"project_urls": {
"Homepage": "https://github.com/thiswillbeyourgithub/OCR_with_format"
},
"split_keywords": [
"ocr",
" tesseract",
" pytesseract",
" format",
" formatting",
" space",
" spacing",
" spaces"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "28779f14a4a005993b44e0bab6a67d1658162210ee94fdd934e56245054c31c5",
"md5": "e785f92df98def4cade76f8bd37bb8fb",
"sha256": "b968663df8c4bae8b25c49c773ed8b559d1be29f000ac6af7c5a99700d233df9"
},
"downloads": -1,
"filename": "OCR_with_format-0.12-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e785f92df98def4cade76f8bd37bb8fb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 20678,
"upload_time": "2024-07-06T16:37:21",
"upload_time_iso_8601": "2024-07-06T16:37:21.928890Z",
"url": "https://files.pythonhosted.org/packages/28/77/9f14a4a005993b44e0bab6a67d1658162210ee94fdd934e56245054c31c5/OCR_with_format-0.12-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "608ce716bfad6569a4d2dabb2d790017551de5ba2a9034e850f4c9f640a9fcbc",
"md5": "662eb9fd71a9696632aeb558ad71cf1d",
"sha256": "8fea6a1ae15aa723d2a8630d5ae6c90f40e32f1321cb2510fb53c9f441dc8921"
},
"downloads": -1,
"filename": "ocr_with_format-0.12.tar.gz",
"has_sig": false,
"md5_digest": "662eb9fd71a9696632aeb558ad71cf1d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 19796,
"upload_time": "2024-07-06T16:37:24",
"upload_time_iso_8601": "2024-07-06T16:37:24.102990Z",
"url": "https://files.pythonhosted.org/packages/60/8c/e716bfad6569a4d2dabb2d790017551de5ba2a9034e850f4c9f640a9fcbc/ocr_with_format-0.12.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-06 16:37:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "thiswillbeyourgithub",
"github_project": "OCR_with_format",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "ocr-with-format"
}