@vali98/uma-reader
v0.0.1
Published
Browser-focused OCR/matcher reader for Uma Musume screenshots (stats page, deck, podium).
Readme
uma-reader
Browser OCR for Uma Musume statsheets, support decks and podium screenshots.
Install
npm install @vali98/uma-reader
npx uma-reader-assets --out public/uma-readerServe public/uma-reader/ at /uma-reader/. Run the asset-copy command before
builds to refresh descriptors and the packaged OCR runtime/model.
Read an image
import { readStats, readDeck, readPodium } from "@vali/98uma-reader";
const { data, warnings } = await readStats(file);Readers accept a File, Blob, image URL, canvas, ImageBitmap, ImageData,
or RGBA PixelImage. Results contain data, warnings and optional debug boxes.
Unreadable fields are null. In Next.js, call readers from a client component's
event handler or effect.
For podiums, optionally validate the event header:
const result = await readPodium(file, { checkHeader: "Sagittarius" });
// result.header: { text, cup, isFinals, matches }Use checkHeader: true to accept any zodiac Cup Finals header. Failed checks
add a warning and preserve the detected rows.
Preload assets
Assets load on the first read and are reused across calls. To preload:
import { loadStatsAssets, readStats } from "@vali/98uma-reader";
await loadStatsAssets();
const result = await readStats(file, { loadAssets: false });Also available: loadDeckAssets(), loadPodiumAssets(), loadAllAssets() and
loadOnnx(). loadOnnx() downloads ONNX runtime files; the first OCR session
initializes WASM. Read options are optional; loadAssets defaults to true.
The OCR model and runtime are served from the copied assets and load on demand. Model and WASM bytes are cached in browser storage when available.
Configure
Call configure() before loading to customize URLs or receive progress:
import { configure } from "@vali/98uma-reader";
configure({
baseUrl: "/uma-reader/",
onProgress: ({ stage, loaded, total }) => console.log(stage, loaded, total),
});Other options: modelUrl, cacheModel, cacheWasm, fetch and signal.
Inference uses one thread. Cross-origin asset hosts need CORS headers. Custom
models must use ORT format and match the runtime operators and packaged charset.
