Extract your Arcaea play result from screenshot.
Project description
Arcaea Offline OCR
Example
Results from
arcaea_offline_ocr 0.1.0a2
Build an image hash database (ihdb)
import sqlite3
from pathlib import Path
import cv2
from arcaea_offline_ocr.builders.ihdb import (
ImageHashDatabaseBuildTask,
ImageHashesDatabaseBuilder,
)
from arcaea_offline_ocr.providers import ImageCategory, ImageHashDatabaseIdProvider
from arcaea_offline_ocr.scenarios.device import DeviceScenario
def build():
def _read_partner_icon(image_path: str):
return DeviceScenario.preprocess_char_icon(
cv2.cvtColor(cv2.imread(image_path, cv2.IMREAD_COLOR), cv2.COLOR_BGR2GRAY),
)
builder = ImageHashesDatabaseBuilder()
tasks = [
ImageHashDatabaseBuildTask(
image_path=str(file),
image_id=file.stem,
category=ImageCategory.JACKET,
)
for file in Path("/path/to/some/jackets").glob("*.jpg")
]
tasks.extend(
[
ImageHashDatabaseBuildTask(
image_path=str(file),
image_id=file.stem,
category=ImageCategory.PARTNER_ICON,
imread_function=_read_partner_icon,
)
for file in Path("/path/to/some/partner_icons").glob("*.png")
],
)
with sqlite3.connect("/path/to/ihdb-X.Y.Z.db") as conn:
builder.build(conn, tasks)
Device OCR
import json
import sqlite3
from dataclasses import asdict
import cv2
from arcaea_offline_ocr.providers import (
ImageHashDatabaseIdProvider,
OcrKNearestTextProvider,
)
from arcaea_offline_ocr.scenarios.device import (
DeviceRoisAutoT2,
DeviceRoisExtractor,
DeviceRoisMaskerAutoT2,
DeviceScenario,
)
with sqlite3.connect("/path/to/ihdb-X.Y.Z.db") as conn:
img = cv2.imread("/path/to/your/screenshot.jpg")
h, w = img.shape[:2]
r = DeviceRoisAutoT2(w, h)
m = DeviceRoisMaskerAutoT2()
e = DeviceRoisExtractor(img, r)
scenario = DeviceScenario(
extractor=e,
masker=m,
knn_provider=OcrKNearestTextProvider(
cv2.ml.KNearest.load("/path/to/knn_model.dat"),
),
image_id_provider=ImageHashDatabaseIdProvider(conn),
)
result = scenario.result()
with open("result.jsonc", "w", encoding="utf-8") as jf:
json.dump(asdict(result), jf, indent=2, ensure_ascii=False)
// result.json
{
"song_id": "vector",
"rating_class": 1,
"score": 9990996,
"song_id_results": [
{
"image_id": "vector",
"category": 0,
"confidence": 1.0,
"image_hash_type": 0
},
{
"image_id": "clotho",
"category": 0,
"confidence": 0.71875,
"image_hash_type": 0
}
// 28 more results omitted…
],
"partner_id_results": [
{
"image_id": "23",
"category": 1,
"confidence": 0.90625,
"image_hash_type": 0
},
{
"image_id": "45",
"category": 1,
"confidence": 0.8828125,
"image_hash_type": 0
}
// 28 more results omitted…
],
"pure": 1000,
"pure_inaccurate": null,
"pure_early": null,
"pure_late": null,
"far": 2,
"far_inaccurate": null,
"far_early": null,
"far_late": null,
"lost": 0,
"played_at": null,
"max_recall": 1002,
"clear_status": 2,
"clear_type": null,
"modifier": null
}
License
This file is part of arcaea-offline-ocr, as called "This program" below.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
Credits
- JohannesBuchner/imagehash:
arcaea_offline_ocr.core.hashersimplementations reference
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file arcaea_offline_ocr-0.1.0a2.tar.gz.
File metadata
- Download URL: arcaea_offline_ocr-0.1.0a2.tar.gz
- Upload date:
- Size: 58.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6135aaddf7696dda3ab5714580231e50a8d527d7864969f1d9ca6617e4d8bf3
|
|
| MD5 |
ea9ff2d9efa8bcec3161cc281412ccba
|
|
| BLAKE2b-256 |
9f5e5c5b4343401e09e59236e63b11ac07e5456395110d683fa222bbdbeef772
|
Provenance
The following attestation bundles were made for arcaea_offline_ocr-0.1.0a2.tar.gz:
Publisher:
build-and-publish.yml on ArcaeaOffline/core-ocr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
arcaea_offline_ocr-0.1.0a2.tar.gz -
Subject digest:
f6135aaddf7696dda3ab5714580231e50a8d527d7864969f1d9ca6617e4d8bf3 - Sigstore transparency entry: 251988118
- Sigstore integration time:
-
Permalink:
ArcaeaOffline/core-ocr@8cc407b2bcd7b7b1028a259e1bce07567307989d -
Branch / Tag:
refs/tags/0.1.0a2 - Owner: https://github.com/ArcaeaOffline
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-and-publish.yml@8cc407b2bcd7b7b1028a259e1bce07567307989d -
Trigger Event:
push
-
Statement type:
File details
Details for the file arcaea_offline_ocr-0.1.0a2-py3-none-any.whl.
File metadata
- Download URL: arcaea_offline_ocr-0.1.0a2-py3-none-any.whl
- Upload date:
- Size: 38.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3bce05c4addeed0bceb62d598c7ab105fa6b56ecbec88d9f7dff0eb797da53f
|
|
| MD5 |
4a6714f9c179c66d2479899fb2cc7fde
|
|
| BLAKE2b-256 |
b13c3f34bd7205255bd5eb51a7bd5bd85eabd9957bcc9230de7503aff552343c
|
Provenance
The following attestation bundles were made for arcaea_offline_ocr-0.1.0a2-py3-none-any.whl:
Publisher:
build-and-publish.yml on ArcaeaOffline/core-ocr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
arcaea_offline_ocr-0.1.0a2-py3-none-any.whl -
Subject digest:
d3bce05c4addeed0bceb62d598c7ab105fa6b56ecbec88d9f7dff0eb797da53f - Sigstore transparency entry: 251988120
- Sigstore integration time:
-
Permalink:
ArcaeaOffline/core-ocr@8cc407b2bcd7b7b1028a259e1bce07567307989d -
Branch / Tag:
refs/tags/0.1.0a2 - Owner: https://github.com/ArcaeaOffline
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-and-publish.yml@8cc407b2bcd7b7b1028a259e1bce07567307989d -
Trigger Event:
push
-
Statement type: