{"id":14977690,"url":"https://github.com/lucs1590/nkocr","last_synced_at":"2025-04-07T13:05:55.087Z","repository":{"id":37965585,"uuid":"277910581","full_name":"Lucs1590/Nkocr","owner":"Lucs1590","description":"🔎📝   This is a module to make specifics OCRs at food products and nutritional tables.","archived":false,"fork":false,"pushed_at":"2024-10-04T14:26:34.000Z","size":83745,"stargazers_count":34,"open_issues_count":1,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-12T16:23:28.261Z","etag":null,"topics":["computer-vision","east","food-products","hacktoberfest","image-processing","language","ocr","opencv","opencv-python","pytesseract","python","python3","specifics-ocrs","spelling-correction","symspell","tesseract","tesseract-ocr","tesseract-ocr-engine","tesseract-python"],"latest_commit_sha":null,"homepage":"https://medium.com/analytics-vidhya/how-did-the-machine-read-nutritional-facts-271a53893194","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/Lucs1590.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-07T20:00:56.000Z","updated_at":"2024-10-04T14:26:31.000Z","dependencies_parsed_at":"2023-02-16T12:45:32.672Z","dependency_job_id":"24ab307a-3692-44d5-95cd-12156585354f","html_url":"https://github.com/Lucs1590/Nkocr","commit_stats":{"total_commits":541,"total_committers":8,"mean_commits":67.625,"dds":0.3678373382624769,"last_synced_commit":"26ce4721a2a18552ed9d3d424bb3865718428b23"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lucs1590%2FNkocr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lucs1590%2FNkocr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lucs1590%2FNkocr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lucs1590%2FNkocr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lucs1590","download_url":"https://codeload.github.com/Lucs1590/Nkocr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247657276,"owners_count":20974344,"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","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":["computer-vision","east","food-products","hacktoberfest","image-processing","language","ocr","opencv","opencv-python","pytesseract","python","python3","specifics-ocrs","spelling-correction","symspell","tesseract","tesseract-ocr","tesseract-ocr-engine","tesseract-python"],"created_at":"2024-09-24T13:56:08.971Z","updated_at":"2025-04-07T13:05:55.067Z","avatar_url":"https://github.com/Lucs1590.png","language":"Python","funding_links":["https://www.buymeacoffee.com/Lucs1590"],"categories":[],"sub_categories":[],"readme":"# Nkocr: The OCR tool for nutritional tables\n\n![Nkocr_logo](https://raw.githubusercontent.com/Lucs1590/Nkocr/master/logo.jpg)\n\n[![PyPI version](https://badge.fury.io/py/nkocr.svg)](https://badge.fury.io/py/nkocr)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/Lucs1590/Nkocr/blob/master/LICENSE)\n![Python Test](https://github.com/Lucs1590/Nkocr/workflows/Python%20Test/badge.svg)\n![CodeQL](https://github.com/Lucs1590/Nkocr/workflows/CodeQL/badge.svg)\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[![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[![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\u0026url=https://github.com/Lucs1590/Nkocr\u0026hashtags=ocr,github,opensource,developer,dev)\n\nThis is a module to make specifics OCRs at food products and nutritional tables.\n\n# Contents\n\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# 📝 Prerequisites \u003ca id=\"prerequisites\"\u003e\u003c/a\u003e\n\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ßsites.\n\n## Tesseract OCR \u003ca id=\"tesseract\"\u003e\u003c/a\u003e\n\nThe installation of tesseract on the **Linux** system can be done in a few commands:\n\n```bash\nsudo 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```bash\nbrew 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 \u003ca id=\"opencv\"\u003e\u003c/a\u003e\n\nThe installation of opencv on the **Linux** system can be done in a command:\n\n```bash\nsudo apt install python3-opencv\n```\n\nAnd to **macOS** running the following command:\n\n```bash\nbrew install opencv\n```\n\n# ⚙️ Installation \u003ca id=\"install\"\u003e\u003c/a\u003e\n\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\n## Pip \u003ca id=\"pip\"\u003e\u003c/a\u003e\n\nYou can install the project requirements in a Python environment by running:\n\n```bash\npip install -r requirements.txt --user\n```\n\n## Conda \u003ca id=\"conda\"\u003e\u003c/a\u003e\n\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\n```bash\nconda env create -f environment.yml\n```\n\n# 👨‍💻 Usage \u003ca id=\"usage\"\u003e\u003c/a\u003e\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 \u003ca id=\"example\"\u003e\u003c/a\u003e\n\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# ℹ️ Under the Hood \u003ca id=\"uth\"\u003e\u003c/a\u003e\n\nFrom now on we will be talking about a little more technical details of the library.\n\n## Changing Language \u003ca id=\"lang\"\u003e\u003c/a\u003e\n\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 ```\u003clang\u003e``` 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\nsudo apt install tesseract-ocr-\u003clang\u003e\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\nbrew 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 \u003ca id=\"pipeline\"\u003e\u003c/a\u003e\n\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\n![Pipeline_Nkocr](https://raw.githubusercontent.com/Lucs1590/Nkocr/master/pipeline.png)\n\n# 🤝 Supporting \u003ca id=\"sup\"\u003e\u003c/a\u003e\n\nMany hours of hard work have gone into this project. Your support will be very appreciated!\n\n\u003ca href=\"https://www.buymeacoffee.com/Lucs1590\" target=\"_blank\"\u003e\u003cimg src=\"https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png\" alt=\"Buy Me A Coffee\" style=\"height: auto !important;width: auto !important;\" \u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucs1590%2Fnkocr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucs1590%2Fnkocr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucs1590%2Fnkocr/lists"}