Skip to main content

手写汉字识别库 (Digital Ink Kit)

Project description

dinkit

Digital Ink Kit — 轻量级手写汉字识别库,纯 C 实现,毫秒级响应。

PyPI version Python Platform

安装

pip install dinkit

支持 Python 3.9+,覆盖 macOS (Apple Silicon)、Linux (x86_64)、Windows (x86_64)。

快速开始

单次识别

from dinkit import recognize

strokes = [
    [[312, 211], [312, 215], [316, 231], ...],  # 第一笔
    [[382, 363], [401, 358], [420, 349], ...],  # 第二笔
]

result = recognize(strokes)
print(result)
# {'我': 3049, '找': 3784, '戌': 4144, ...}

连续识别

多次调用时用 Recognizer 复用引擎实例,避免重复初始化:

from dinkit import Recognizer

with Recognizer() as reco:
    for strokes in batch:
        result = reco.recognize(strokes)
        print(result)

笔迹格式

strokes: List[List[Tuple[int, int]]]
  • 外层列表:一笔一画
  • 内层列表:该笔包含的 [x, y] 坐标点序列

API 参考

recognize(strokes, top_k=10) -> Dict[str, int]

一次性调用,适合零散识别场景。

参数 类型 说明
strokes List[List[Tuple[int, int]]] 笔迹坐标
top_k int 返回候选数量,默认 10

返回 {汉字: 置信度} 字典,置信度越低越好(本质是匹配距离)。

Recognizer (类)

可复用的识别器,适合批量识别。

  • recognize(strokes, top_k=10) — 识别笔迹,参数同上
  • 支持 with Recognizer() as reco: 上下文管理器,自动释放资源

训练工具

从笔迹数据训练自定义识别模型,详见 tools/train/README.md

cmake .. -DBUILD_TRAIN_TOOL=ON && cmake --build . --target dinkit_train
python tools/train/make_charset.py 守卫汉字战场 -o data/charset
python tools/train/convert_track.py tools/train/examples/sample_我.json -o data/train/sample.trk
./build/tools/train/dinkit_train data/charset data/train data/test build/train_work data/output

许可证

MIT

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

dinkit-1.3.3-cp313-cp313-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.13Windows x86-64

dinkit-1.3.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

dinkit-1.3.3-cp313-cp313-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

dinkit-1.3.3-cp312-cp312-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.12Windows x86-64

dinkit-1.3.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

dinkit-1.3.3-cp312-cp312-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

dinkit-1.3.3-cp311-cp311-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.11Windows x86-64

dinkit-1.3.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

dinkit-1.3.3-cp311-cp311-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

dinkit-1.3.3-cp310-cp310-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.10Windows x86-64

dinkit-1.3.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

dinkit-1.3.3-cp310-cp310-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

dinkit-1.3.3-cp39-cp39-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.9Windows x86-64

dinkit-1.3.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

dinkit-1.3.3-cp39-cp39-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file dinkit-1.3.3-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: dinkit-1.3.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.7 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dinkit-1.3.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2854aa69dd4bbf84030d87be75412496f4637d9eff347485c15c6954b2aaa170
MD5 050b1f48c28271d9bc55e4413277cbcc
BLAKE2b-256 9db3b78c4f748a2acdacaf4dd5b4cda60b2db3d9caea47c164254a10e3596c86

See more details on using hashes here.

File details

Details for the file dinkit-1.3.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for dinkit-1.3.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 38edb4c338252d49cafb353114960b3d43cdd4d556e289d342efdffa72976a1a
MD5 032e943aae9b03a6ec84509916643289
BLAKE2b-256 2e3e98eb75081ee5dd4eebbcdf97c2ace878c6210c909942ade9f95b82606e41

See more details on using hashes here.

File details

Details for the file dinkit-1.3.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dinkit-1.3.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ebe884cd5e0cb394500467b9190618a662f055e145b4e08742d59be6dafd06b0
MD5 bddd468b3872b100f7f81e5743446883
BLAKE2b-256 451b070a47e63ee502dcd6c58375e34568acb40da5808f8fcc1c3200126c6668

See more details on using hashes here.

File details

Details for the file dinkit-1.3.3-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: dinkit-1.3.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.7 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dinkit-1.3.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 cd02a446030f249cd4027dffd96c425cde2b20fabafb11aa1a084344219e78f3
MD5 bd3467a15ad5508008f7906437e9f998
BLAKE2b-256 e2fc7a7cec3f71831579747ab093f5ce7b0c63e2964e9149c593c116c121c8f5

See more details on using hashes here.

File details

Details for the file dinkit-1.3.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for dinkit-1.3.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9ad4b56722ff297a0c47fc512764644f779e88a1f514f3f62a1706a545658b13
MD5 38e44ddab415f1dda678901e28faf5cc
BLAKE2b-256 41afe31c020eae2ffd7eead7fc8bbb49433d21ab6cf4571d9a69d4e97b35fbdb

See more details on using hashes here.

File details

Details for the file dinkit-1.3.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dinkit-1.3.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6c4f764b47ee707210f9c02e78727e5c36254c0c986968d1733fe1ff85395bf7
MD5 d30012ff0bcf2a60002c9ec21de55c8e
BLAKE2b-256 97abc44539859fd9619328cf444166ee24a42d0319cc2e1921f3fe8ac9d55f8d

See more details on using hashes here.

File details

Details for the file dinkit-1.3.3-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: dinkit-1.3.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.7 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dinkit-1.3.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3a2ab664fc0e4e0534632e6de349b41d132088eb6efca28d1523f311eddee890
MD5 b552bdaa4c4f617564698811bf55729b
BLAKE2b-256 259645465e8d71b78ea9d0165f966286c2ac971af4463ed022c120119068b5d0

See more details on using hashes here.

File details

Details for the file dinkit-1.3.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for dinkit-1.3.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c2691628ece87f46f637e012160e58fa4c0e601cb4105be6c8098a4fb2cc9e4d
MD5 603fcb7b1f4df5e52eac1d13fb9b87a4
BLAKE2b-256 bb5ea7d88ab869d2f1060dc528ff69630d9a4aa014e697c1deefa680fb786a9d

See more details on using hashes here.

File details

Details for the file dinkit-1.3.3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dinkit-1.3.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 34474072bc7a1a32a82eb52b0b6f857408e88e788e6415873120aaa19bd97d0d
MD5 e109c34353631bece3095e80e8f6957c
BLAKE2b-256 6e5dac52706f30ea01ee4bcfe724374d651a49f353f36a7846e28359f58eb39d

See more details on using hashes here.

File details

Details for the file dinkit-1.3.3-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: dinkit-1.3.3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.7 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dinkit-1.3.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 992afe5ed8b7913de8a43b1b54e67da1be706834d7e8cd02e14581a4710f8dc5
MD5 7b45aa2feea30668b5649cf0fc3ecafd
BLAKE2b-256 80caebed2051882a68b90003d07b5c6884d1b633b8c73b7b5b1f95f05910493c

See more details on using hashes here.

File details

Details for the file dinkit-1.3.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for dinkit-1.3.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 eb312ba9c9a186aed5e432c63ccac810ea506390533d9f44d478f8148443dd97
MD5 46f0a571f9d55780241c6b47fb24ae13
BLAKE2b-256 8bd40951abcde1707979c7d5ddc0a8555cfdcd085212a9760c28ca93b0c4881a

See more details on using hashes here.

File details

Details for the file dinkit-1.3.3-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dinkit-1.3.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a499cb8087c2b1c90b294540d9e25596318c1b2828cdd2446eac7682ff8628ab
MD5 e4e7df7a8cafbd2ae882b3ea82107893
BLAKE2b-256 939b5f7a89e84e6d176b84a3f839e18b15d7836bc09ee2b1733b6df1c3a7ea3b

See more details on using hashes here.

File details

Details for the file dinkit-1.3.3-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: dinkit-1.3.3-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 3.7 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dinkit-1.3.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 339a83cc9736db67c3ab4790ed33d5c86e62323c106047cca214fdc55f59d792
MD5 3e7a6bb059fd67f9dbbc815fff9105fd
BLAKE2b-256 90178a7a0a5225b6d1ea5ee2fc3225d5ceecba5a90155138c68c6361ae060c7b

See more details on using hashes here.

File details

Details for the file dinkit-1.3.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for dinkit-1.3.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a9474e766d9a088a37835ef5360df5d857ba4319ac84376b1bafe637850034a4
MD5 7969d0f173970929c0679c4f55220f50
BLAKE2b-256 95de8afdf8725d91e438f89bb1de920ca021b9dcc4f37103f79dd9060252b15b

See more details on using hashes here.

File details

Details for the file dinkit-1.3.3-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dinkit-1.3.3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7abe133c12fbc6c4bf3eabb5bfe6fb3fd6287830d79b9b79b53fea71e96a87cf
MD5 18340afbf76462642aa2206368e4dd4e
BLAKE2b-256 1a9ff3f51a84a3395097240cb72866d8c2f074e690f4be1e6c7e3fe7e10ac2b1

See more details on using hashes here.

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