{ "info": { "author": "Linxi (Jim) Fan", "author_email": "jimfan@cs.stanford.edu", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Programming Language :: Python :: 3", "Topic :: Scientific/Engineering :: Image Recognition", "Topic :: Utilities" ], "description": "OCR engine\n==========\n\nThis library provides a clean interface to segment and recognize text in\nan image. It's optimized for printed text, e.g. scanned documents and\nwebsite screenshots.\n\n|Python version| |Github release| |PyPI version| |PyPI status|\n\nInstallation\n------------\n\n``pip install liteocr``\n\nThe installation includes both the ``liteocr`` Python3 library and a\ncommand line executable.\n\nUsage\n-----\n\n``>> liteocr``\n~~~~~~~~~~~~~~\n\nPerforms OCR on an image file and writes the recognition results to\nJSON.\n\n::\n\n usage: LiteOCR [-h] [-d] [--extra-whitelist str] [--all-unicode] [--lang str]\n [--min-text-size int] [--max-text-size int]\n [--uniformity-thresh :0.0<=float<1.0]\n [--thin-line-thresh :odd int] [--conf-thresh :0<=int<100]\n [--box-expand-factor :0.0<=float<1.0]\n [--horizontal-pooling int]\n str str\n\n positional arguments:\n str image file\n str output JSON file\n\n optional arguments:\n -h, --help show this help message and exit\n -d, --display display recognized bounding boxes and text on top of the image\n\n engine:\n parameters to liteocr.OCREngine constructor\n\n --extra-whitelist str\n string of extra chars for Tesseract to consider only\n takes effect when all_unicode is False\n --all-unicode if True, Tesseract will consider all possible unicode\n characters\n --lang str language in the text. Defaults to English.\n\n recognition:\n parameters to OCREngine.recognize() method\n\n --min-text-size int min text height/width in pixels, below which will be\n ignored\n --max-text-size int max text height/width in pixels, above which will be\n ignored\n --uniformity-thresh :0.0<=float<1.0\n ignore a region if the number of pixels neither black\n nor white < [thresh]\n --thin-line-thresh :odd int\n remove all lines thinner than [thresh] pixels.can be\n used to remove the thin borders of web page textboxes.\n --conf-thresh :0<=int<100\n ignore regions with OCR confidence < thresh.\n --box-expand-factor :0.0<=float<1.0\n expand the bounding box outwards in case certain chars\n are cutoff.\n --horizontal-pooling int\n result bounding boxes will be more connected with more\n pooling, but large pooling might lower accuracy.\n\nPython3 library\n~~~~~~~~~~~~~~~\n\n.. code:: python\n\n from liteocr import OCREngine, load_img, draw_rect, draw_text, disp\n\n image_file = 'my_img.png'\n img = load_img(image_file)\n\n # you can either use context manager or call engine.close() manually at the end.\n with OCREngine() as engine:\n # engine.recognize() can accept a file name, a numpy image, or a PIL image.\n for text, box, conf in engine.recognize(image_file):\n print(box, '\\tconfidence =', conf, '\\ttext =', text)\n draw_rect(img, box)\n draw_text(img, text, box, color='bw')\n\n # display the image with recognized text boxes overlaid\n disp(img, pause=False)\n\nNotes\n-----\n\nI deprecated and moved the old code into a `separate\nfolder `__. The old\nAPI calls Tesseract directly on the entire image. The low recall wasn't\ntrivial to fix at all, as I realized later:\n\n- The command-line Tesseract makes really weird global page\n segmentation decisions. It ignores certain text regions with no\n apparent patterns. I have tried many different combinations of a\n handful of tuneable parameters, but none of them helps. My hands are\n tied because Tesseract is poorly documented and very few people asks\n such questions on Stackoverflow.\n- `Tesserocr `__\n is a python package that builds a ``.pyx`` wrapper around Tesseract's\n C++ API. There are a few native API methods that can iterate through\n text regions, but they randomly fail with SegFault (ughh!!!). I spent\n a lot of time trying to fix it, but gave up in despair ...\n- Tesseract is the best open-source OCR engine, which means I don\u2019t\n have other choices. I thought about using Google\u2019s online OCR API,\n but we shouldn\u2019t be bothered by internet connection and API call\n limits.\n\nSo I ended up using a new workflow:\n\n1. Apply OpenCV magic to produce better text segmentation.\n2. Run Tesseract on each of the segmented text box. It\u2019s much more\n transparent than running on the whole image.\n3. Collect text result and mean confidence level (``yield`` as a\n generator).\n\n.. |Python version| image:: https://img.shields.io/pypi/pyversions/liteocr.svg\n.. |Github release| image:: https://img.shields.io/github/release/LinxiFan/liteocr.svg\n.. |PyPI version| image:: https://img.shields.io/pypi/v/liteocr.svg\n.. |PyPI status| image:: https://img.shields.io/pypi/status/liteocr.svg\n\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/LinxiFan/LiteOCR", "keywords": "OCR image recognition Tesseract", "license": "GPLv3", "maintainer": "", "maintainer_email": "", "name": "liteocr", "package_url": "https://pypi.org/project/liteocr/", "platform": "", "project_url": "https://pypi.org/project/liteocr/", "project_urls": { "Homepage": "http://github.com/LinxiFan/LiteOCR" }, "release_url": "https://pypi.org/project/liteocr/0.2.1/", "requires_dist": [ "numpy", "pillow", "tesserocr" ], "requires_python": "", "summary": "Light-weight OCR engine.", "version": "0.2.1" }, "last_serial": 2543542, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "7452551b8ace9fe427aeafee3897553f", "sha256": "b74097cd0d1812148b44f50de83f568667665413319eebc8356a9fcc270df511" }, "downloads": -1, "filename": "liteocr-0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "7452551b8ace9fe427aeafee3897553f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6857, "upload_time": "2016-12-27T12:46:38", "url": "https://files.pythonhosted.org/packages/7c/73/2e1fe4e4beb7137d5ecfd774d9721ba579a70a9a2a5fad68e930ebc0cb0c/liteocr-0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f8767054162c1489e9bdae120372e8af", "sha256": "fa7ee197c1511b3d4034dc6a012647e9ead4c02b632f982f7de4ff83e7fb8678" }, "downloads": -1, "filename": "liteocr-0.1.tar.gz", "has_sig": false, "md5_digest": "f8767054162c1489e9bdae120372e8af", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5234, "upload_time": "2016-12-27T12:46:39", "url": "https://files.pythonhosted.org/packages/eb/83/04acb2ad4cbf2a9a159187187a06822ca53556e7789a1e4599f55dca0520/liteocr-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "f7484e0ffc29ee685ca8b989d76328b7", "sha256": "f39cd55f6f19f4ced7dbd775d614fbfaacc7e1402df48de10ef3c4768d99342c" }, "downloads": -1, "filename": "liteocr-0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "f7484e0ffc29ee685ca8b989d76328b7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8942, "upload_time": "2016-12-27T15:31:12", "url": "https://files.pythonhosted.org/packages/d7/c0/d54dba39461d3471020cef096aa5d6becaca361615d1a65b496029379be2/liteocr-0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "67e84554bd50c7a3f2597ec4e79bfbae", "sha256": "b1cbdf155b9cafeb6bb4a2b7dede8c3425f6b7c40676a45c5ae1865420d36f44" }, "downloads": -1, "filename": "liteocr-0.2.tar.gz", "has_sig": false, "md5_digest": "67e84554bd50c7a3f2597ec4e79bfbae", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6418, "upload_time": "2016-12-27T15:31:15", "url": "https://files.pythonhosted.org/packages/54/13/89187996251d31c17d5ca1aa52c84ef0f297ae9da2b2cfcc01070ecd3e84/liteocr-0.2.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "c3de3788d63ec917c82f983028bbe572", "sha256": "f61f37ac8b3c802d28b6148424f3106b3de5a31dddbeb07d5b0a660c5c14ddc1" }, "downloads": -1, "filename": "liteocr-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "c3de3788d63ec917c82f983028bbe572", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13051, "upload_time": "2016-12-29T03:27:24", "url": "https://files.pythonhosted.org/packages/c1/1b/92c7ef25b8d424ae07b4d7530e81e5542f68c625df15d05121d4f34cfce0/liteocr-0.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "637335ed9c26e29f6fb34bad751f3075", "sha256": "5007798261954bcbee9b620c8551d7eaee5d85431c0c9f6044b548b7c30d3871" }, "downloads": -1, "filename": "liteocr-0.2.1.tar.gz", "has_sig": false, "md5_digest": "637335ed9c26e29f6fb34bad751f3075", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8505, "upload_time": "2016-12-29T03:27:25", "url": "https://files.pythonhosted.org/packages/44/63/4dc0a0ed33ac159c3b133773b7f35fdac532107090106a28ed554674c40c/liteocr-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c3de3788d63ec917c82f983028bbe572", "sha256": "f61f37ac8b3c802d28b6148424f3106b3de5a31dddbeb07d5b0a660c5c14ddc1" }, "downloads": -1, "filename": "liteocr-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "c3de3788d63ec917c82f983028bbe572", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13051, "upload_time": "2016-12-29T03:27:24", "url": "https://files.pythonhosted.org/packages/c1/1b/92c7ef25b8d424ae07b4d7530e81e5542f68c625df15d05121d4f34cfce0/liteocr-0.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "637335ed9c26e29f6fb34bad751f3075", "sha256": "5007798261954bcbee9b620c8551d7eaee5d85431c0c9f6044b548b7c30d3871" }, "downloads": -1, "filename": "liteocr-0.2.1.tar.gz", "has_sig": false, "md5_digest": "637335ed9c26e29f6fb34bad751f3075", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8505, "upload_time": "2016-12-29T03:27:25", "url": "https://files.pythonhosted.org/packages/44/63/4dc0a0ed33ac159c3b133773b7f35fdac532107090106a28ed554674c40c/liteocr-0.2.1.tar.gz" } ] }