Skip to main content

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

Release files for dinkit 1.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for dinkit 1.3.3
File
dinkit-1.3.3-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
dinkit-1.3.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
dinkit-1.3.3-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
dinkit-1.3.3-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
dinkit-1.3.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
dinkit-1.3.3-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
dinkit-1.3.3-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
dinkit-1.3.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details
dinkit-1.3.3-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
dinkit-1.3.3-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
dinkit-1.3.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
dinkit-1.3.3-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details
dinkit-1.3.3-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
dinkit-1.3.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
dinkit-1.3.3-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details

Total release size: 56.6 MB

Release files / dinkit-1.3.3-cp313-cp313-win_amd64.whl

Download URL dinkit-1.3.3-cp313-cp313-win_amd64.whl
Size 3.7 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
2854aa69dd4bbf84030d87be75412496f4637d9eff347485c15c6954b2aaa170
BLAKE2b-256 checksum
How to use checksums
9db3b78c4f748a2acdacaf4dd5b4cda60b2db3d9caea47c164254a10e3596c86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / dinkit-1.3.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl

Download URL dinkit-1.3.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Size 3.8 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
38edb4c338252d49cafb353114960b3d43cdd4d556e289d342efdffa72976a1a
BLAKE2b-256 checksum
How to use checksums
2e3e98eb75081ee5dd4eebbcdf97c2ace878c6210c909942ade9f95b82606e41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / dinkit-1.3.3-cp313-cp313-macosx_11_0_arm64.whl

Download URL dinkit-1.3.3-cp313-cp313-macosx_11_0_arm64.whl
Size 3.8 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ebe884cd5e0cb394500467b9190618a662f055e145b4e08742d59be6dafd06b0
BLAKE2b-256 checksum
How to use checksums
451b070a47e63ee502dcd6c58375e34568acb40da5808f8fcc1c3200126c6668
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / dinkit-1.3.3-cp312-cp312-win_amd64.whl

Download URL dinkit-1.3.3-cp312-cp312-win_amd64.whl
Size 3.7 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
cd02a446030f249cd4027dffd96c425cde2b20fabafb11aa1a084344219e78f3
BLAKE2b-256 checksum
How to use checksums
e2fc7a7cec3f71831579747ab093f5ce7b0c63e2964e9149c593c116c121c8f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / dinkit-1.3.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl

Download URL dinkit-1.3.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Size 3.8 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
9ad4b56722ff297a0c47fc512764644f779e88a1f514f3f62a1706a545658b13
BLAKE2b-256 checksum
How to use checksums
41afe31c020eae2ffd7eead7fc8bbb49433d21ab6cf4571d9a69d4e97b35fbdb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / dinkit-1.3.3-cp312-cp312-macosx_11_0_arm64.whl

Download URL dinkit-1.3.3-cp312-cp312-macosx_11_0_arm64.whl
Size 3.8 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6c4f764b47ee707210f9c02e78727e5c36254c0c986968d1733fe1ff85395bf7
BLAKE2b-256 checksum
How to use checksums
97abc44539859fd9619328cf444166ee24a42d0319cc2e1921f3fe8ac9d55f8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / dinkit-1.3.3-cp311-cp311-win_amd64.whl

Download URL dinkit-1.3.3-cp311-cp311-win_amd64.whl
Size 3.7 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
3a2ab664fc0e4e0534632e6de349b41d132088eb6efca28d1523f311eddee890
BLAKE2b-256 checksum
How to use checksums
259645465e8d71b78ea9d0165f966286c2ac971af4463ed022c120119068b5d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / dinkit-1.3.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl

Download URL dinkit-1.3.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Size 3.8 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
c2691628ece87f46f637e012160e58fa4c0e601cb4105be6c8098a4fb2cc9e4d
BLAKE2b-256 checksum
How to use checksums
bb5ea7d88ab869d2f1060dc528ff69630d9a4aa014e697c1deefa680fb786a9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / dinkit-1.3.3-cp311-cp311-macosx_11_0_arm64.whl

Download URL dinkit-1.3.3-cp311-cp311-macosx_11_0_arm64.whl
Size 3.8 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
34474072bc7a1a32a82eb52b0b6f857408e88e788e6415873120aaa19bd97d0d
BLAKE2b-256 checksum
How to use checksums
6e5dac52706f30ea01ee4bcfe724374d651a49f353f36a7846e28359f58eb39d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / dinkit-1.3.3-cp310-cp310-win_amd64.whl

Download URL dinkit-1.3.3-cp310-cp310-win_amd64.whl
Size 3.7 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
992afe5ed8b7913de8a43b1b54e67da1be706834d7e8cd02e14581a4710f8dc5
BLAKE2b-256 checksum
How to use checksums
80caebed2051882a68b90003d07b5c6884d1b633b8c73b7b5b1f95f05910493c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / dinkit-1.3.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl

Download URL dinkit-1.3.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Size 3.8 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
eb312ba9c9a186aed5e432c63ccac810ea506390533d9f44d478f8148443dd97
BLAKE2b-256 checksum
How to use checksums
8bd40951abcde1707979c7d5ddc0a8555cfdcd085212a9760c28ca93b0c4881a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / dinkit-1.3.3-cp310-cp310-macosx_11_0_arm64.whl

Download URL dinkit-1.3.3-cp310-cp310-macosx_11_0_arm64.whl
Size 3.8 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a499cb8087c2b1c90b294540d9e25596318c1b2828cdd2446eac7682ff8628ab
BLAKE2b-256 checksum
How to use checksums
939b5f7a89e84e6d176b84a3f839e18b15d7836bc09ee2b1733b6df1c3a7ea3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / dinkit-1.3.3-cp39-cp39-win_amd64.whl

Download URL dinkit-1.3.3-cp39-cp39-win_amd64.whl
Size 3.7 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
339a83cc9736db67c3ab4790ed33d5c86e62323c106047cca214fdc55f59d792
BLAKE2b-256 checksum
How to use checksums
90178a7a0a5225b6d1ea5ee2fc3225d5ceecba5a90155138c68c6361ae060c7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / dinkit-1.3.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl

Download URL dinkit-1.3.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Size 3.8 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
a9474e766d9a088a37835ef5360df5d857ba4319ac84376b1bafe637850034a4
BLAKE2b-256 checksum
How to use checksums
95de8afdf8725d91e438f89bb1de920ca021b9dcc4f37103f79dd9060252b15b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / dinkit-1.3.3-cp39-cp39-macosx_11_0_arm64.whl

Download URL dinkit-1.3.3-cp39-cp39-macosx_11_0_arm64.whl
Size 3.8 MB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7abe133c12fbc6c4bf3eabb5bfe6fb3fd6287830d79b9b79b53fea71e96a87cf
BLAKE2b-256 checksum
How to use checksums
1a9ff3f51a84a3395097240cb72866d8c2f074e690f4be1e6c7e3fe7e10ac2b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release history Release notifications | RSS feed

This release

1.3.3 This release

15 release files

1.3.2

15 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page