Skip to main content

An ocr designed to read in game texts

Project description

hash-ocr

An ocr designed to read in game texts

Installation

You can install the package via pip:

pip install hash-ocr

Usage

import cv2

from hash_ocr import compute_distances
from hash_ocr import get_word

img = cv2.imread("test_data/382.png", cv2.IMREAD_GRAYSCALE)
img = cv2.threshold(img, 128, 255, cv2.THRESH_BINARY)[1]

print(get_word(img))
# 382

print(compute_distances(img))
# [(8.0, '3', (5, 6, 18, 25)), (7.0, '8', (24, 5, 18, 26)), (10.0, '2', (42, 6, 20, 24))]

Custom Models

A model in hash-ocr contains an image and a json file.

Example image:

Model Image

Example label:

["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]

Example:

from hash_ocr.models import AverageHash

model = AverageHash(
    model_path="hash_ocr/models/digits.png",
    label_path="hash_ocr/models/letters.json",
)

License

This project is licensed under the terms of the MIT license.

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

hash_ocr-2.0.0.tar.gz (20.4 kB view hashes)

Uploaded Source

Built Distribution

hash_ocr-2.0.0-py3-none-any.whl (20.3 kB view hashes)

Uploaded Python 3

Supported by

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