Skip to main content

Python wrapper for OCR by Windows Runtime API

Project description

WinRT OCR: Take advantage of powerful existing Windows tool

GitHub License GitHub last commit Stars

If you find this repo helpful, please leave me a star, thanks!!!

Overview

WinRT OCR is a Python wrapper for using OCR API from Windows Runtime (WinRT) on Windows operating system.

1. What is Windows Runtime (WinRT) API?

Windows Runtime is an integrated software module deeply in Windows system, first introduced after Windows 8 released. It can be simply understood as set of APIs and rules to build functions in Windows apps.

Through APIs it provides, the developers can interact with modern functions of Windows such as location detection, camera, Bluetooth, and so on.

See more APIs

2. Which version of Windows supports WinRT API ?

It's highly recommended to use Windows 10, version 1803 or later.

The older version may lead to unwanted behaviors or no longer supported syntax.

3. Which language does it support to OCR?

Up to this point, WinRT has supported for several languages:

Code Language
ar-SA Arabic (Saudi Arabia)
bg-BG Bulgarian (Bulgaria)
bs-LATN-BA Bosnian (Latin, Bosnia and Herzegovina)
cs-CZ Czech (Czech Republic)
da-DK Danish (Denmark)
de-DE German (Germany)
el-GR Greek (Greece)
en-GB English (United Kingdom)
en-US English (US)
es-ES Spanish (Spain)
es-MX Spanish (Mexico)
fi-FI Finnish (Finland)
fr-CA French (Canada)
fr-FR French (France)
hr-HR Croatian (Croatia)
hu-HU Hungarian (Hungary)
it-IT Italian (Italy)
ja-JP Japanese (Japan)
ko-KR Korean (South Korea)
nb-NO Norwegian Bokmål (Norway)
nl-NL Dutch (Netherlands)
pl-PL Polish (Poland)
pt-BR Portuguese (Brazil)
pt-PT Portuguese (Portugal)
ro-RO Romanian (Romania)
ru-RU Russian (Russia)
sk-SK Slovak (Slovakia)
sl-SI Slovenian (Slovenia)
sr-CYRL-RS Serbian (Cyrillic, Serbia)
sr-LATN-RS Serbian (Latin, Serbia)
sv-SE Swedish (Sweden)
tr-TR Turkish (Turkey)
zh-CN Chinese (Simplified, China)
zh-HK Chinese (Traditional, Hong Kong SAR)
zh-TW Chinese (Traditional, Taiwan)

Recent Update

  • 🚀 2025/04/12: Release the first version.

Quick Start

Dependencies:

  • Python >= 3.8
  • Windows 10, version 1803 or higher
pip install winrt-ocr-python

NOTICE:

Before you continue, check your computer to ensure that your expected language has been installed for OCR.

Open Powershell as Administrator then run this cell:

# This line will list all of language it supports for OCR (or you can see in table above)
Get-WindowsCapability -Online | Where-Object { $_.Name -Like 'Language.OCR*' }

# Download your target language (such as fr-FR)
Get-WindowsCapability -Online | Where-Object { $_.Name -Like 'Language.OCR*fr-FR*' } | Add-WindowsCapability -Online

This will look for the OCR language package in Window Update (WU) host then download it. It may take a few time to finish.

Check C:/Windows/OCR to see that your language has been installed or not yet. If an OCR pack is supported and installed but different location, for example, X:/Windows/OCR, then just copy X:/Windows/OCR folder to C:/Windows/OCR folder.

Usage:

import asyncio
from winrtocr import WinRTOCR

engine = WinRTOCR()
img_path = "/path/to/img_file"
output_lines = asyncio.run(engine.ocr(img_path, lang="en-US", detail_level='line'))

# (Optional) Show languages support
engine.available_languages

# Visualize the result
# NOTE: image MUST BE str, BGR or BGRA
test_img = engine.draw_ocr_result(img_path, output_lines, detail_level='line')

Acknowledgement

This library is built based on PyWinSDK. Thank for their great jobs!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

winrt_ocr_python-0.1.1.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

winrt_ocr_python-0.1.1-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file winrt_ocr_python-0.1.1.tar.gz.

File metadata

  • Download URL: winrt_ocr_python-0.1.1.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for winrt_ocr_python-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0bb9b3c9a143f12fc42e823693485ea71c2084063a5ed270537f18b177c7268f
MD5 e922e86aa3e5b64acb185db0a652d475
BLAKE2b-256 229129a39ff3087b94100369632b3c5fdbddaa1856ed9a2ef22d4414bcfbe586

See more details on using hashes here.

Provenance

The following attestation bundles were made for winrt_ocr_python-0.1.1.tar.gz:

Publisher: python-publish.yml on hieulhaiwork/winrt-ocr-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file winrt_ocr_python-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for winrt_ocr_python-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c51f8e0856f043b0c6ad2f1187f5492d519558444edde54b3ec650a7e003e26e
MD5 54dc594142db5f1fbd6dc21539acda1e
BLAKE2b-256 1f5c4802986c03c555891b50ebe2565a559e46759f2ceda2ec2a5c24686a8f52

See more details on using hashes here.

Provenance

The following attestation bundles were made for winrt_ocr_python-0.1.1-py3-none-any.whl:

Publisher: python-publish.yml on hieulhaiwork/winrt-ocr-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page