nkocr


Namenkocr JSON
Version 2.3.0 PyPI version JSON
download
home_pagehttps://github.com/Lucs1590/Nkocr
SummaryThis is a module to make specifics OCRs at food products and nutricional tables.
upload_time2022-12-26 01:32:46
maintainer
docs_urlNone
authorLucas de Brito Silva
requires_python>=3.6
licenseApache License 2.0
keywords ocr tesseract-ocr nk python3 python-3 food-products
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![Nkocr_logo](https://raw.githubusercontent.com/Lucs1590/Nkocr/master/logo.jpg)
[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=try%20to%20apply%20OCR%20techniques%20on%20a%20nutritional%20table%20with%20Nkocr&url=https://github.com/Lucs1590/Nkocr&hashtags=ocr,github,opensource,developer,dev)

--------------------------------------

[![CodeFactor](https://www.codefactor.io/repository/github/lucs1590/nkocr/badge)](https://www.codefactor.io/repository/github/lucs1590/nkocr)
[![codecov](https://codecov.io/gh/Lucs1590/Nkocr/branch/master/graph/badge.svg?token=DRGVRJMNBP)](https://codecov.io/gh/Lucs1590/Nkocr)
![Python Test](https://github.com/Lucs1590/Nkocr/workflows/Python%20Test/badge.svg)
![Upload Python Package](https://github.com/Lucs1590/Nkocr/workflows/Upload%20Python%20Package/badge.svg?branch=v0.2.2)
![CodeQL](https://github.com/Lucs1590/Nkocr/workflows/CodeQL/badge.svg)
[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Lucs1590/Nkocr/blob/master/ocr_table.ipynb)


This is a module to make specifics OCRs at food products and nutritional tables.

# Contents
- [Prerequisites](#prerequisites)
    - [Tesseract OCR](#tesseract)
    - [OpenCV](#opencv)
- [Installation](#install)
    - [Pip](#pip)
    - [Conda](#conda)
- [Usage](#usage)
    - [Example](#example)
- [Under the Hood](#uth)
    - [Choosing the Language](#lang)
    - [Pipeline](#pipeline)
- [Supporting](#sup)

# 📝 Prerequisites <a id="prerequisites"></a>
As a prerequisite of this project, we have the [tesseract library](https://github.com/tesseract-ocr/tesseract) and [OpenCV](https://docs.opencv.org/master/da/df6/tutorial_py_table_of_contents_setup.html), so next we will install this preßsites.
## Tesseract OCR <a id="tesseract"></a>

The installation of tesseract on the **Linux** system can be done in a few commands:

```bash
$ sudo apt install tesseract-ocr libtesseract-dev
```

And the same goes for **macOS**. There is a variation between MacPorts and Homebrew, but in this post I will only quote the version of Homebrew:

```
$ brew install tesseract
```

After performing the tesseract installation, it is possible to perform OCR in just one command, thus already extracting some words from the image.

## OpenCV <a id="opencv"></a>
The installation of opencv on the **Linux** system can be done in a command:

```bash
$ sudo apt install python3-opencv
```

And to **macOS** running the following command:

```bash
$ brew install opencv
```

# ⚙️ Installation <a id="install"></a>
Now, assuming the prerequisites have already been installed, you're ready to install the Nkocr environment to modify, contribute and work!

**But, if you just want to use the project, go to the [usage](#usage) part.**
## Pip <a id="pip"></a>
You can install the project requirements in a Python environment by running:

```bash
$ pip install -r requirements.txt --user
```

## Conda <a id="conda"></a>
But if you are used to using a conda environment to keep everything organized, or if you want to test using it this time, feel free to run the following command and have a unique environment for Nkocr.
```bash
$ conda env create -f environment.yml
```

# 👨‍💻 Usage <a id="usage"></a>

To use this package, it's very easy, first you need to install it by running:

```bash
pip install nkocr --user
```

And after installing, you can import the packages in a Python script like the example below.

```python
from nkocr import OcrTable, OcrProduct
```

## Example <a id="example"></a>
To make it even easier, below is an example of code snippet.

```python
from nkocr import OcrTable

text = OcrTable("paste_image_url_here")
print(text) # or print(text.text)
```

# ℹ️ Under the Hood <a id="uth"></a>
From now on we will be talking about a little more technical details of the library.

## Changing Language <a id="lang"></a>
The default language is English, so depending on the text, it will not be possible to capture the desired words / phrases.
Therefore, if you want to work with another language, you will need to make some changes inherent to the language that the algorithm executes.

The first thing is to download the desired language with tesseract support, and on Linux this can be done by running the following command:
Don't forget to change ```<lang>``` with the desired language. If you would like more details, please feel free to access the [tesseract documentation](https://github.com/tesseract-ocr/tessdoc/blob/master/Data-Files-in-different-versions.md).

```bash
$ sudo apt install tesseract-ocr-<lang>
```

If you are a macOS user, your command will be a little different. You will need to run the following command, and don't worry about the language, after running this command you will have access to all languages.

```bash
$ brew install tesseract-lang
```

After downloading the support languages, to perform the translations in the desired language you will have to change the code in the [ocr_product.py](https://github.com/Lucs1590/Nkocr/blob/cdf0024850617bf24261ad1b028b5b924ae96720/src/ocr_product.py#L13), [ocr_table.py](https://github.com/Lucs1590/Nkocr/blob/cdf0024850617bf24261ad1b028b5b924ae96720/src/ocr_table.py#L15) and [auxiliary.py](https://github.com/Lucs1590/Nkocr/blob/a6c2cd045edfb12f664a8832b1349b1e1dc4b00f/src/auxiliary.py#L349).

## Operating Pipeline <a id="pipeline"></a>
The main algorithm was built working, mainly, with structures and methods of computer vision and digital image processing. The image below clearly depicts the line followed for the operational pipeline combinations.
![Pipeline_Nkocr](https://raw.githubusercontent.com/Lucs1590/Nkocr/master/pipeline.png)
# 🤝 Supporting <a id="sup"></a>

Many hours of hard work have gone into this project. Your support will be very appreciated!

<a href="https://www.buymeacoffee.com/Lucs1590" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;" ></a>

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Lucs1590/Nkocr",
    "name": "nkocr",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "ocr,tesseract-ocr,nk,python3,python-3,food-products",
    "author": "Lucas de Brito Silva",
    "author_email": "lucasbsilva29@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/56/3f/3a4199bf0fb42dc211dd7bab6006457714760e637b76fe1cf284e444f43a/nkocr-2.3.0.tar.gz",
    "platform": null,
    "description": "![Nkocr_logo](https://raw.githubusercontent.com/Lucs1590/Nkocr/master/logo.jpg)\n[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=try%20to%20apply%20OCR%20techniques%20on%20a%20nutritional%20table%20with%20Nkocr&url=https://github.com/Lucs1590/Nkocr&hashtags=ocr,github,opensource,developer,dev)\n\n--------------------------------------\n\n[![CodeFactor](https://www.codefactor.io/repository/github/lucs1590/nkocr/badge)](https://www.codefactor.io/repository/github/lucs1590/nkocr)\n[![codecov](https://codecov.io/gh/Lucs1590/Nkocr/branch/master/graph/badge.svg?token=DRGVRJMNBP)](https://codecov.io/gh/Lucs1590/Nkocr)\n![Python Test](https://github.com/Lucs1590/Nkocr/workflows/Python%20Test/badge.svg)\n![Upload Python Package](https://github.com/Lucs1590/Nkocr/workflows/Upload%20Python%20Package/badge.svg?branch=v0.2.2)\n![CodeQL](https://github.com/Lucs1590/Nkocr/workflows/CodeQL/badge.svg)\n[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Lucs1590/Nkocr/blob/master/ocr_table.ipynb)\n\n\nThis is a module to make specifics OCRs at food products and nutritional tables.\n\n# Contents\n- [Prerequisites](#prerequisites)\n    - [Tesseract OCR](#tesseract)\n    - [OpenCV](#opencv)\n- [Installation](#install)\n    - [Pip](#pip)\n    - [Conda](#conda)\n- [Usage](#usage)\n    - [Example](#example)\n- [Under the Hood](#uth)\n    - [Choosing the Language](#lang)\n    - [Pipeline](#pipeline)\n- [Supporting](#sup)\n\n# \ud83d\udcdd Prerequisites <a id=\"prerequisites\"></a>\nAs a prerequisite of this project, we have the [tesseract library](https://github.com/tesseract-ocr/tesseract) and [OpenCV](https://docs.opencv.org/master/da/df6/tutorial_py_table_of_contents_setup.html), so next we will install this pre\u00dfsites.\n## Tesseract OCR <a id=\"tesseract\"></a>\n\nThe installation of tesseract on the **Linux** system can be done in a few commands:\n\n```bash\n$ sudo apt install tesseract-ocr libtesseract-dev\n```\n\nAnd the same goes for **macOS**. There is a variation between MacPorts and Homebrew, but in this post I will only quote the version of Homebrew:\n\n```\n$ brew install tesseract\n```\n\nAfter performing the tesseract installation, it is possible to perform OCR in just one command, thus already extracting some words from the image.\n\n## OpenCV <a id=\"opencv\"></a>\nThe installation of opencv on the **Linux** system can be done in a command:\n\n```bash\n$ sudo apt install python3-opencv\n```\n\nAnd to **macOS** running the following command:\n\n```bash\n$ brew install opencv\n```\n\n# \u2699\ufe0f Installation <a id=\"install\"></a>\nNow, assuming the prerequisites have already been installed, you're ready to install the Nkocr environment to modify, contribute and work!\n\n**But, if you just want to use the project, go to the [usage](#usage) part.**\n## Pip <a id=\"pip\"></a>\nYou can install the project requirements in a Python environment by running:\n\n```bash\n$ pip install -r requirements.txt --user\n```\n\n## Conda <a id=\"conda\"></a>\nBut if you are used to using a conda environment to keep everything organized, or if you want to test using it this time, feel free to run the following command and have a unique environment for Nkocr.\n```bash\n$ conda env create -f environment.yml\n```\n\n# \ud83d\udc68\u200d\ud83d\udcbb Usage <a id=\"usage\"></a>\n\nTo use this package, it's very easy, first you need to install it by running:\n\n```bash\npip install nkocr --user\n```\n\nAnd after installing, you can import the packages in a Python script like the example below.\n\n```python\nfrom nkocr import OcrTable, OcrProduct\n```\n\n## Example <a id=\"example\"></a>\nTo make it even easier, below is an example of code snippet.\n\n```python\nfrom nkocr import OcrTable\n\ntext = OcrTable(\"paste_image_url_here\")\nprint(text) # or print(text.text)\n```\n\n# \u2139\ufe0f Under the Hood <a id=\"uth\"></a>\nFrom now on we will be talking about a little more technical details of the library.\n\n## Changing Language <a id=\"lang\"></a>\nThe default language is English, so depending on the text, it will not be possible to capture the desired words / phrases.\nTherefore, if you want to work with another language, you will need to make some changes inherent to the language that the algorithm executes.\n\nThe first thing is to download the desired language with tesseract support, and on Linux this can be done by running the following command:\nDon't forget to change ```<lang>``` with the desired language. If you would like more details, please feel free to access the [tesseract documentation](https://github.com/tesseract-ocr/tessdoc/blob/master/Data-Files-in-different-versions.md).\n\n```bash\n$ sudo apt install tesseract-ocr-<lang>\n```\n\nIf you are a macOS user, your command will be a little different. You will need to run the following command, and don't worry about the language, after running this command you will have access to all languages.\n\n```bash\n$ brew install tesseract-lang\n```\n\nAfter downloading the support languages, to perform the translations in the desired language you will have to change the code in the [ocr_product.py](https://github.com/Lucs1590/Nkocr/blob/cdf0024850617bf24261ad1b028b5b924ae96720/src/ocr_product.py#L13), [ocr_table.py](https://github.com/Lucs1590/Nkocr/blob/cdf0024850617bf24261ad1b028b5b924ae96720/src/ocr_table.py#L15) and [auxiliary.py](https://github.com/Lucs1590/Nkocr/blob/a6c2cd045edfb12f664a8832b1349b1e1dc4b00f/src/auxiliary.py#L349).\n\n## Operating Pipeline <a id=\"pipeline\"></a>\nThe main algorithm was built working, mainly, with structures and methods of computer vision and digital image processing. The image below clearly depicts the line followed for the operational pipeline combinations.\n![Pipeline_Nkocr](https://raw.githubusercontent.com/Lucs1590/Nkocr/master/pipeline.png)\n# \ud83e\udd1d Supporting <a id=\"sup\"></a>\n\nMany hours of hard work have gone into this project. Your support will be very appreciated!\n\n<a href=\"https://www.buymeacoffee.com/Lucs1590\" target=\"_blank\"><img src=\"https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png\" alt=\"Buy Me A Coffee\" style=\"height: auto !important;width: auto !important;\" ></a>\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "This is a module to make specifics OCRs          at food products and nutricional tables.",
    "version": "2.3.0",
    "split_keywords": [
        "ocr",
        "tesseract-ocr",
        "nk",
        "python3",
        "python-3",
        "food-products"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "3ec2828130a64867188f46dd5eb424cb",
                "sha256": "baca61a9f53438289c355993e00c8ced4d9d62e78d2dedbef30e16526b178e98"
            },
            "downloads": -1,
            "filename": "nkocr-2.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3ec2828130a64867188f46dd5eb424cb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 17281,
            "upload_time": "2022-12-26T01:32:43",
            "upload_time_iso_8601": "2022-12-26T01:32:43.539045Z",
            "url": "https://files.pythonhosted.org/packages/28/d2/8a0f0a1662e648330d8dfe7d3785d8b4fd14b38e941ef4c7be127c39fc52/nkocr-2.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "a992a1d19f2c54c881dbaceab147bb18",
                "sha256": "f3fdd8095f1f8eea8fb1275e4f24d5df3286075d199ef177596f542e6736439f"
            },
            "downloads": -1,
            "filename": "nkocr-2.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a992a1d19f2c54c881dbaceab147bb18",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 293875,
            "upload_time": "2022-12-26T01:32:46",
            "upload_time_iso_8601": "2022-12-26T01:32:46.087333Z",
            "url": "https://files.pythonhosted.org/packages/56/3f/3a4199bf0fb42dc211dd7bab6006457714760e637b76fe1cf284e444f43a/nkocr-2.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-26 01:32:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "Lucs1590",
    "github_project": "Nkocr",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "nkocr"
}
        
Elapsed time: 0.02107s