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.2-cp313-cp313-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.13Windows x86-64

dinkit-1.3.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (3.7 MB view details)

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

dinkit-1.3.2-cp313-cp313-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

dinkit-1.3.2-cp312-cp312-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.12Windows x86-64

dinkit-1.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (3.7 MB view details)

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

dinkit-1.3.2-cp312-cp312-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

dinkit-1.3.2-cp311-cp311-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.11Windows x86-64

dinkit-1.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (3.7 MB view details)

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

dinkit-1.3.2-cp311-cp311-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

dinkit-1.3.2-cp310-cp310-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.10Windows x86-64

dinkit-1.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (3.7 MB view details)

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

dinkit-1.3.2-cp310-cp310-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

dinkit-1.3.2-cp39-cp39-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.9Windows x86-64

dinkit-1.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (3.7 MB view details)

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

dinkit-1.3.2-cp39-cp39-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: dinkit-1.3.2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.6 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.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 fba22c01204703278fb6304e8c1ac01d5e74de19e3341ab264f690bf2d9b7275
MD5 31fa057fe565ef687ff01fa7b6316be6
BLAKE2b-256 b66eac7723af37955adc35eaa041f60567be58427803832f88c127bc9f3c5e69

See more details on using hashes here.

File details

Details for the file dinkit-1.3.2-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.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ee5a7ebdf5e61c4b544cebb552b64c03af4e0d3b60f46c0e6e30e06ad267201f
MD5 bcff747e1414545035a7dd5466277a29
BLAKE2b-256 f16d018086af06d7d2d7d223623d2630e81fed48e5d2b3edce3034446bc524b3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dinkit-1.3.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 22bf3966e6a8bb100bc73a3030963c6775e0d05bcc1effe57e12920bee50ecd0
MD5 c4ddfc96ef046600f808edae416de5e2
BLAKE2b-256 fdaec46a051bcb69e46bf323487de3b4465bb3581b6888804b5032497edf17d8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dinkit-1.3.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.6 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.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 67cd49db6b8c80ee2c3f1b51d6d77ee181f64af8edf492fe0d7b0febfdc91ec8
MD5 83395a0f7424f4f415c40868ec14049a
BLAKE2b-256 6d03fb539cb1edaf2d8806d245679cea8c37e16ee7bddc207997b5472e0f9865

See more details on using hashes here.

File details

Details for the file dinkit-1.3.2-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.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 71a3a49d90e7ba31be663f68a69871ce0e346d2981521837813df5522fd599f8
MD5 643b467b7e462c09b7bfa68b71d1baa8
BLAKE2b-256 c3c648f13beda63bc023b8a2829dd37873e485ba991e9b50814a3cb45da825de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dinkit-1.3.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ee75917146372e7558028fb0315ee26123fb9a9db769fcf1b4b2c129e53a02c2
MD5 01f8bef61a3e0e5082a4b3f492cd72a7
BLAKE2b-256 519cdd26de73d52da1fa6216b598065894a1652036eab5c9fe2b0332f3c5769c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dinkit-1.3.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.6 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.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0062768c02c420338e42408cad17bddba2f97ab719f01d966999cd397a1654ce
MD5 49564272e00064fc7c1948c982e2e276
BLAKE2b-256 5516f9ae708488df67c603ced98ff1238849835f4f94509ccb254bb989cb5bbc

See more details on using hashes here.

File details

Details for the file dinkit-1.3.2-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.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 05d7ec40cb70c9df26be15e9e55dea05b9d00dd2fa211ce4ea6a32005307ba5b
MD5 1bc35ea58ea30b167905e139a51079b0
BLAKE2b-256 8185c4536acc1f2b3ebc777fe8566a3702965d990ed06b036453850be4a75c0a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dinkit-1.3.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9a2449f7d4f42ae8e5a31e55521a96ceca727c5acbda9ff4e55c28c59fecf6c3
MD5 560f5a5336ca5d94a08f91aa88d93ff6
BLAKE2b-256 951eaa8aac0d79a792e94ae8564a6260b884717cf0328092c9afd96b3c82db9d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dinkit-1.3.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.6 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.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 131f293a233c4a81a8aa3dcef19a7ae5a8689a4bdfcec058860fb5d7c54aef9e
MD5 84b07d169951476c1f1ba6a75c17c9e1
BLAKE2b-256 d6196b57f4a0934725ff420be6f7f6c46e83db023c6b07ee3eba0dd435f1e105

See more details on using hashes here.

File details

Details for the file dinkit-1.3.2-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.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c2c925990301dd65ada5d42edbb22222572bad05a9101f0015b036817cf51693
MD5 e35bfdf92581045fdcf42c5a3f18c829
BLAKE2b-256 c5754023e56a70a1bb2e24be4332fdda99ddfcb4b699637b85777482709d3b8c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dinkit-1.3.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a41e1b145bdd3e3f94ea0e7279422079c1198c44b060eb99818d678e3ff62646
MD5 48dca480fb84a0a4cb6cd856bc15923b
BLAKE2b-256 7d91690c23d127f230043993231631189c90e32091b99edfbcbc03d0bce9bf5b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dinkit-1.3.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 3.6 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.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e793fdad11598061f6457499b18bd3313a14379eb308cae68ac3fd1a3bc57dd6
MD5 9f23d006117ae46e05f86c27a4ee661c
BLAKE2b-256 f7f0951f0db95914cb147c490be02ac2f7859f2b0e86c91a66a740d6552c1536

See more details on using hashes here.

File details

Details for the file dinkit-1.3.2-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.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0657bc9c24dad08af09409f5c27a41e106ee04c04a49f8a50c147ecc8cb1f8bd
MD5 7394f3fdf049cbd8a3889ba3293662f9
BLAKE2b-256 1d0e9ef2705740c9633d68ee91ff7d138a1a881463dd066a9a6c66e82e9bc840

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dinkit-1.3.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8266fbf1cd93b1c515bf46723d0cb6e85ca778417c1d98cf1bf9f321c50391ad
MD5 6d670faceb5ef270aabe356594993e85
BLAKE2b-256 e66ec452db738acf0d7beb8864d0f7ac315de56a4eedb7b44f7ee1001b1a59d6

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