npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sudobility/sudojo_ocr

v1.1.46

Published

OCR library for extracting Sudoku puzzles from images (Node.js; recognition via paddle_ocr)

Readme

@sudobility/sudojo_ocr

Node.js library for extracting Sudoku puzzles, and optionally pencilmarks, from images.

Board detection, squaring and cropping happen in-process; digit recognition is a single HTTP call to the paddle_ocr service. Every frontend goes through sudojo_api rather than importing this directly. ESM-only.

The split matters: PaddleOCR emits one text block per digit on a board that fills the frame, but it has no board detector. Cropping first is what makes the geometry mapping exact -- on an uncropped photo the digits land in the wrong rows and any surrounding page text arrives as blocks.

Installation

bun add @sudobility/sudojo_ocr @sudobility/sudojo_types
bun add @napi-rs/canvas   # required by the Node adapter

@sudobility/sudojo_types is a peer dependency. There is no OCR engine to bundle and no language data to download.

Usage

import { extractSudokuFromImage } from '@sudobility/sudojo_ocr';
import { createNodeAdapter } from '@sudobility/sudojo_ocr/node';

const adapter = await createNodeAdapter(); // async
const result = await extractSudokuFromImage(
  adapter,
  imageBuffer, // Buffer or file path
  { url: 'http://ocr.sudobility.com', timeoutMs: 30000 },
  { recognizePencilmarks: true } // optional, default false
);
console.log(result.board.original);            // "004002008100400000..." ('0' = empty)
console.log(result.board.pencilmark.numbers);  // 81 comma-separated entries
console.log(result.confidence);                // 100
console.log(result.digitCount);                // 40

Accuracy

Measured against the three committed fixtures and their ground truth, cropped then recognized: 243/243 cells correct, 0.5-1.6s per board. The recognizePencilmarks flag only decides whether autopencil is set and the legal candidates are computed -- the marks themselves are derived from the givens by constraint propagation, never read off the image.

result.board is a SolverBoard from @sudobility/sudojo_types.

API

  • extractSudokuFromImage() -- Full pipeline: image -> board detection -> crop -> paddle_ocr -> block-to-cell mapping -> board assembly
  • detectAndCropBoard() -- Detect and crop board, returns data URL
  • extractCellImages() -- Extract 81 cell images as data URLs
  • recognizeBoard() / mapBlocksToBoard() -- The paddle client and its geometry mapping, usable on their own
  • Platform adapter: createNodeAdapter()
  • Low-level image-processing and board-detection algorithms are also exported (see src/index.ts)

Development

bun run build        # Build ESM to dist/ (no CJS)
bun run test         # Run Vitest (offline; fakes the paddle response)
PADDLE_OCR_URL=http://ocr.sudobility.com bun run test   # also run the live 81/81 checks
bun run typecheck    # TypeScript check
bun run lint         # ESLint (includes Prettier rules)
bun run verify       # Typecheck + lint + test + build

See CLAUDE.md for the architecture and gotchas, and docs/ for OCR tuning notes.

Related Packages

  • sudojo_api -- Backend /ocr route (Node adapter). Dispatches by image source: camera captures come here, library images prefer sudojo_ocr_ml and fall back here
  • paddle_ocr -- The PaddleOCR service this library calls for recognition
  • sudojo_app, sudojo_app_rn, sudojo_extension, sudojo_bot -- Frontends; they call sudojo_api, not this library
  • sudojo_ocr_ml -- Python ONNX whole-board OCR service; the preferred backend for library images
  • @sudobility/sudojo_types -- Peer dependency; defines SolverBoard, the result's board field

License

BUSL-1.1