{"id":33125726,"url":"https://github.com/guitarmind/tesseract-web-service","last_synced_at":"2025-11-20T00:02:03.701Z","repository":{"id":12050445,"uuid":"14636455","full_name":"guitarmind/tesseract-web-service","owner":"guitarmind","description":"An implementation of RESTful web service for tesseract-OCR using tornado","archived":false,"fork":false,"pushed_at":"2023-05-20T20:31:42.000Z","size":54,"stargazers_count":135,"open_issues_count":4,"forks_count":34,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-04-22T01:24:00.026Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/guitarmind.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2013-11-23T04:46:13.000Z","updated_at":"2023-09-01T11:16:55.000Z","dependencies_parsed_at":"2024-01-07T21:14:01.217Z","dependency_job_id":"814f86be-34ee-4f72-ade7-c62d733fd605","html_url":"https://github.com/guitarmind/tesseract-web-service","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/guitarmind/tesseract-web-service","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guitarmind%2Ftesseract-web-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guitarmind%2Ftesseract-web-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guitarmind%2Ftesseract-web-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guitarmind%2Ftesseract-web-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guitarmind","download_url":"https://codeload.github.com/guitarmind/tesseract-web-service/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guitarmind%2Ftesseract-web-service/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285348528,"owners_count":27156475,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-19T02:00:05.673Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-11-15T06:00:52.703Z","updated_at":"2025-11-20T00:02:03.695Z","avatar_url":"https://github.com/guitarmind.png","language":"Python","funding_links":[],"categories":["Software"],"sub_categories":["OCR as a Service"],"readme":"tesseract-web-service\n=====================\n\nAn implementation of RESTful web service for tesseract-OCR. The HTTP server is implemented using tornado. A [**Docker Container**](https://registry.hub.docker.com/u/guitarmind/tesseract-web-service/) has been created to let you run this service without any installation efforts!\n\nAs of tesseract-ocr version 3.02.02, it provides a [C-API](https://code.google.com/p/tesseract-ocr/wiki/APIExample).\nNow while calling the \"Fetch Image From URL\" API, operations are done in memory for better performance. No file I/O is required. The python implementation of C API wrapper using ctypes can be found in [**tesseractcapi.py**](https://github.com/guitarmind/tesseract-web-service/blob/master/tesseractcapi.py). Bulk processing is planned to appear in the future version.\n\nA full list of C APIs supported in tesseract-ocr version 3.02.02 is at [here](https://code.google.com/p/tesseract-ocr/source/browse/api/capi.h) with detailed signatures and comments.\n\n\n#### Support two APIs with GET and POST\n\n    Upload Image File: /upload\n    Fetch Image From URL: /fetchurl\n\n\n#### Tesseract Installation on Ubuntu 12.04 LTS\n\nPython Requirement\n\n    version \u003e= 2.7\n\nInstall tornado, PIL image library and other required packages by apt-get.\n\n    sudo apt-get update \u0026\u0026 sudo apt-get install -y \\\n        autoconf \\\n        automake \\\n        autotools-dev \\\n        build-essential \\\n        checkinstall \\\n        libjpeg-dev \\\n        libpng-dev \\\n        libtiff-dev \\\n        libtool \\\n        python \\\n        python-imaging \\\n        python-tornado \\\n        wget \\\n        zlib1g-dev\n\nYou need to compile and install leptonica and the latest version (3.02.02) of tesseract-ocr manually to support C API. More details can be found at [this wiki](https://code.google.com/p/tesseract-ocr/wiki/Compiling). Here is an example on Ubuntu 12.04 LTS:\n\n    mkdir ~/temp \\\n        \u0026\u0026 cd ~/temp/ \\\n        wget http://www.leptonica.org/source/leptonica-1.69.tar.gz \\\n        \u0026\u0026 tar -zxvf leptonica-1.69.tar.gz \\\n        \u0026\u0026 cd leptonica-1.69 \\\n        \u0026\u0026 ./configure \\\n        \u0026\u0026 make \\\n        \u0026\u0026 checkinstall \\\n        \u0026\u0026 ldconfig\n\n\n    cd ~/temp/ \\\n        \u0026\u0026 wget https://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.02.tar.gz \\\n        \u0026\u0026 tar xvf tesseract-ocr-3.02.02.tar.gz \\\n        \u0026\u0026 cd tesseract-ocr \\\n        \u0026\u0026 ./autogen.sh \\\n        \u0026\u0026 mkdir ~/local \\\n        \u0026\u0026 ./configure --prefix=$HOME/local/ \\\n        \u0026\u0026 make \\\n        \u0026\u0026 make install\n\nOnly English letters and digits are supported by default.\nYou can download more language packs, such as Simplified/Traditional Chinese pack from http://code.google.com/p/tesseract-ocr/downloads/list.\nDecompress and put the packs under '**~/local/share/**' or other locations you like.\n\n    mkdir ~/local/share -p\n    cd ~/local/share \\\n        \u0026\u0026 wget https://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.eng.tar.gz \\\n        \u0026\u0026 tar xvf tesseract-ocr-3.02.eng.tar.gz\n\n    ls ~/local/share/tesseract-ocr/tessdata\n\n    configs           eng.cube.params        eng.traineddata.__tmp__\n    eng.cube.bigrams  eng.cube.size          equ.traineddata\n    eng.cube.fold     eng.cube.word-freq     osd.traineddata\n    eng.cube.lm       eng.tesseract_cube.nn  tessconfigs\n    eng.cube.nn       eng.traineddata\n\nBe sure to set the parent folder path of language packs in environment variables, for instance:\n\n    export TESSDATA_PREFIX=/home/markpeng/local/share/tesseract-ocr/\n\n\n\n#### How to start tesseract-web-service\nCreate a folder named '**static**' under current folder (for instance, '**/opt/ocr**') to keep temp files\n\n    sudo mkdir /opt/ocr/static -p\n\nThen put all .py files to /opt/ocr and make them executable.\n\n    sudo cp ~/Share/tesseract-web-service/* /opt/ocr\n    sudo chmod 755 /opt/ocr/*.py\n\nNote: you should go to the folder path containing the **static** folder to make the service work.\n\n    cd /opt/ocr\n\nNow, start tesseract-web-service by:\n\n    python tesseractserver.py -b \"/home/markpeng/local/lib\" -d \"/home/markpeng/local/share/tesseract-ocr\"\n\nType the following command to check the options.\n\n    python tesseractserver.py -h\n\n    Usage: tesseractserver.py [options]\n\n    Options:\n      -h, --help            show this help message and exit\n      -p PORT, --port=PORT  the listening port of RESTful tesseract web service.\n                            (default: 1688)\n      -l LANG, --lang=LANG  the targe language. (default: eng)\n      -b LIBPATH, --lib-path=LIBPATH\n                            the absolute path of tesseract library.\n      -d TESSDATA, --tessdata-folder=TESSDATA\n                            the absolute path of tessdata folder containing\n                            language packs.\n\n\nThe default listening port is **1688**. Change it to yours on startup.\nPlease make sure that the firewall is opened for listening port.\n\nFor example, you can change the port to 8080 by:\n\n    python /opt/ocr/tesseractserver.py -p 8080 -b \"/home/markpeng/local/lib\" -d \"/home/markpeng/local/share/tesseract-ocr\"\n\nTo start it as a persistent service even after terminal logout:\n\n    sudo nohup python /opt/ocr/tesseractserver.py -p 8080 -b \"/home/markpeng/local/lib\" -d \"/home/markpeng/local/share/tesseract-ocr\" \u0026\n\n#### Tesseract Installation on Ubuntu 14.04 LTS\n\nPython Requirement\n\n    version \u003e= 2.7\n\nInstall tornado, PIL image library and other required packages by apt-get.\n\n    sudo apt-get update \u0026\u0026 sudo apt-get install -y \\\n        autoconf \\\n        automake \\\n        autotools-dev \\\n        build-essential \\\n        checkinstall \\\n        libjpeg-dev \\\n        libpng-dev \\\n        libtiff-dev \\\n        libtool \\\n        python \\\n        python-imaging \\\n        python-tornado \\\n        wget \\\n        zlib1g-dev\n\nInstall the tesseract library:\n\n    sudo apt-get install tesseract-ocr-dev\n\nCorrect the Filename( or use this Repository):\n\n    class TesseactWrapper:\n        def __init__(self, lang, libpath, tessdata):\n            libname = libpath + \"/libtesseract.so.3.0.3\"\n\n\nCheck for English training data (Filename: eng.traineddata in /usr/share/tesseract-ocr/tessdata/).\nIf not exist do:\n\n    wget https://tesseract-ocr.googlecode.com/files/eng.traineddata.gz\n    gunzip eng.traineddata.gz\n    sudo mv -v eng.traineddata /usr/local/share/tessdata/\n\nCreate a static folder in repo main directory:\n\n    mkdir static\n\nNow, start tesseract-web-service by:\n\n    python tesseractserver.py -p 1688 -b /usr/lib -d /usr/share/tesseract-ocr/tessdata/\n\n\n\n#### How to call RESTful API by GET/POST request\nThe web service provides two HTTP GET pages for testing the API:\n\n    Upload Image File: http://localhost:1688/upload\n    Fetch Image From URL: http://localhost:1688/fetchurl\n\nThe results are returned in JSON format with OCR result strings.\n\n\nIf you would like to call \"Fetch Image From URL\" API with POST, please send a HTTP request header similar to the following:\n\n    POST /fetchurl HTTP/1.1\n    Host: localhost:1688\n    Connection: keep-alive\n    Content-Length: 214\n    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\n    Origin: http://localhost:1688\n    User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.114 Safari/537.36\n    Content-Type: multipart/form-data; boundary=----WebKitFormBoundarylFMK6PAyVCzNCDAr\n    Referer: http://localhost:1688/fetchurl\n    Accept-Encoding: gzip,deflate,sdch\n    Accept-Language: zh-TW,zh;q=0.8,en-US;q=0.6,en;q=0.4d license\n\n    .....\n    POST data payload: imageUrl = 'http://xxxxxxx'\n\n\nIf you send POST data by JSON, you need to provide a '**url**' key, which contains target image url.\n\nExample POST data in JSON:\n\n    data: {\n        'url': 'http://price1.suning.cn/webapp/wcs/stores/prdprice/89218_9173_10000_9-1.png'\n    }\n\nThen you shall get a JSON response similar to the following:\n\n    data: {\n        'url': 'http://price1.suning.cn/webapp/wcs/stores/prdprice/89218_9173_10000_9-1.png',\n        'result': '2158.00'\n    }\n\nNote that for /upload API, since there is no url provided, only result string will be returned in JSON.\n\n#### How to call RESTful API by tesseract client\ntesseractclient.py is a client for calling the \"Fetch Image From URL\" API.\n\nType the following command to check the options.\n\n    python /opt/ocr/tesseractclient.py --help\n\n    Usage: tesseractclient.py [options]\n\n    Options:\n      -h, --help            show this help message and exit\n      -a APIURL, --api-url=APIURL\n                            the URL of RESTful tesseract web service\n      -i IMAGEURL, --image-url=IMAGEURL\n                            the URL of image to do OCR\n\n\nFor instance:\n\n    python /opt/ocr/tesseractclient.py -a \"http://localhost:1688/fetchurl\" -i \"http://www.greatdreams.com/666-magicsquare.gif\"\n\nYou should provide the API url and image source url to make it work.\n\n\n#### How to pull and run Docker Container\nInstall Docker to your host by following the [official installation guide](https://docs.docker.com/installation/#installation).\n\nAfter that, execute the following command to download Docker Image (packaged in Ubuntu 12.04 LTS):\n\n    docker pull guitarmind/tesseract-web-service\n\nTo run the web service using container, just type:\n\n    docker run --rm -d -p 1688:1688 guitarmind/tesseract-web-service\n\nNote that the -p flag is used to bind local port with Container's virtual port. By default it is set to 1688. You can change it by modifying the [Dockerfile](https://github.com/guitarmind/tesseract-web-service/blob/master/Dockerfile). The -d flag means to run it in daemon mode.\n\nThe container has been created as an Automated Build:\n\nhttps://registry.hub.docker.com/u/guitarmind/tesseract-web-service/\n\n## Changelog\n\n#### 0.0.1 - 2013-11-23\n\nFeatures:\n\n  - Support basic GET/POST APIs for \"upload\" and \"fetchUrl\" APIs\n  - File-based processing\n\n\n#### 0.0.2 - 2013-12-08\n\nFeatures:\n\n  - Add a Python wrapper for calling tesseract-ocr C API directly\n  - Memory-based processing for \"fetchUrl\" API\n\n\n#### 0.0.3 - 2015-01-03\n\nFeatures:\n\n  - Add a Docker Container for easy installation and deployment\n\n\n#### 0.0.4 - 2015-09-18\n\nFeatures:\n\n  - Fixed issue [#3](https://github.com/guitarmind/tesseract-web-service/issues/3)\n  - Merged pull request [#1](https://github.com/guitarmind/tesseract-web-service/pull/1), [#2](https://github.com/guitarmind/tesseract-web-service/pull/2), [#4](https://github.com/guitarmind/tesseract-web-service/pull/4) and [#6](https://github.com/guitarmind/tesseract-web-service/pull/6) accordingly.\n\n\n#### 0.0.5 - 2016-02-11\n\nFeatures:\n\n  - Fixed issue [#7](https://github.com/guitarmind/tesseract-web-service/issues/7)\n\n\n## Copyright and License\n\nAuthor: Mark Peng (markpeng.ntu at gmail)\n\nAll codes are under the [Apache 2.0 license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguitarmind%2Ftesseract-web-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguitarmind%2Ftesseract-web-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguitarmind%2Ftesseract-web-service/lists"}