DeepSHPlugins
win11-oneocr 项目预览
GITHUB / COMMUNITY PROJECT

win11-oneocr

视觉与多模态C++

DSH 的本地 Windows 11 OneOCR 工具:`oneocr_recognize` 返回 OCR 文本,以及包含行/词多边形、置信度、旋转角度和手写体样式的结构化结果。

0 Starshawkhai 更新时间 2026-08-19
访问 GitHub 仓库
win11-oneocr 项目预览

项目介绍

中文

DSH 的本地 Windows 11 OneOCR 工具:`oneocr_recognize` 返回 OCR 文本,以及包含行/词多边形、置信度、旋转角度和手写体样式的结构化结果。

English

Local Windows 11 OneOCR tool for DSH: `oneocr_recognize` returns OCR text and structured line/word polygons, confidence, rotation, and handwriting style.

项目信息与收录信号

快照 2026-09-11
作者 / 组织
hawkhai
仓库
hawkhai/win11-oneocr
GitHub Stars
0
Forks
1
开发语言
C++
许可证
未记录
最近推送
2026-08-19
Manifest
数据中检测到声明

公开仓库不自动等于可商用;许可证与当前兼容性以原项目文档为准。Manifest 和数据评分不构成安装安全认证。

数据评分

57/ 100
维护活跃
85
文档与实用信息
75
生态关注度
20
安装便捷信号
100
项目声明信号
80

近 23 天仍在更新;标准命令一键安装。

评分来自已有数据快照的五维模型,仅作浏览参考,不是实际使用评测或安全检测结论。

安装与使用

所有项目资料与许可均以对应 GitHub 仓库为准。

dsh plugin --profile web add github:hawkhai/win11-oneocr

复制命令不会自动执行。请先阅读仓库文档,确认环境要求与许可证。

项目截图

仓库 README

GitHub 原文

已保存的仓库文档快照;文档抓取时间未记录,可能与上方目录介绍处于不同版本。安装前请核对当前仓库说明。

Windows 11 Snipping Tool OCR (OneOCR)

Offline OCR engine extracted from the Windows 11 Snipping Tool, with full-featured C++ CLI, reusable DLL wrapper, and Python visualization.

Based on: https://b1tg.github.io/post/win11-oneocr/

DeepSeek Harness plugin

This repository can be installed as a DeepSeek Harness plugin:

dsh plugin add github:hawkhai/win11-oneocr

It registers oneocr_recognize, a model-facing tool that accepts a local image path and returns recognized text together with OneOCR's structured line/word polygons, confidence values, image angle, and handwriting style. The tool runs locally on Windows 11; image bytes are not sent to an external OCR service.

The bundle defaults to the prebuilt bin/ocr.exe and its adjacent runtime files. Override ocrBin, timeoutMs, or maxOutputBytes in the plugin row if needed.

Features

FeatureDescription
8-point Bounding Box4-corner polygon bbox for lines and words (not just axis-aligned rect)
Word ConfidencePer-word recognition confidence score (0.0–1.0)
Image AngleDetected rotation angle of the text in the image
Line StyleHandwritten vs. printed text classification with confidence
Resize ResolutionConfigurable max internal resize before OCR (performance/accuracy trade-off)
Resource ReleaseProper cleanup via ReleaseOcrResult, ReleaseOcrPipeline, etc.
Unicode PathFull Unicode file path support via _wfopen in the DLL wrapper
Multi-image BatchProcess multiple images in one invocation
Plain Text Output--text mode for pipe-friendly output (no JSON)
Raw Buffer OCRocrImageRaw() for in-memory BGRA pixel buffers (no file I/O)
VisualizationPython script with confidence-colored word boxes and style labels

Prerequisites

  • Windows 11 (tested on 23H2+)
  • Snipping Tool 11.2409.25.0+

Copy these 3 files from the Snipping Tool installation folder into the same directory as ocr.exe:

  • oneocr.dll
  • oneocr.onemodel
  • onnxruntime.dll

Find the Snipping Tool folder:

Get-AppxPackage Microsoft.ScreenSketch | Select-Object -ExpandProperty InstallLocation

Example: C:\Program Files\WindowsApps\Microsoft.ScreenSketch_11.2409.25.0_x64__8wekyb3d8bbwe\SnippingTool

CLI Usage (ocr.exe)

ocr.exe <image1.png> [image2.jpg ...] [options]

Options

OptionDescription
--text, -tOutput plain text only (no JSON)
--output, -o <file>Write JSON to specified file (default: <image>.json)
--max-lines <n>Max recognition lines, 1–1000 (default 1000)
--resize <WxH>Max internal resize resolution (e.g. 1152x768)
--quiet, -qSuppress progress messages
--help, -hShow help

Examples

# Single image → JSON
ocr.exe screenshot.png

# Plain text output (pipe to file)
ocr.exe screenshot.png --text > result.txt

# Batch process
ocr.exe img1.png img2.jpg img3.bmp

# Custom options
ocr.exe photo.jpg --max-lines 50 --resize 800x600 -o result.json

JSON Output Format

{
  "file": "test.png",
  "image": { "width": 771, "height": 479, "step": 3084 },
  "image_angle": 0.0643,
  "line_count": 2,
  "lines": [
    {
      "index": 0,
      "text": "Hello World",
      "bounding_box": [
        13.0, 38.0, 458.0, 38.0,
        458.0, 77.0, 13.0, 76.0
      ],
      "style": { "type": "printed", "confidence": 0.035 },
      "word_count": 2,
      "words": [
        {
          "index": 0,
          "text": "Hello",
          "bounding_box": [
            14.35, 39.70, 140.35, 41.31,
            139.93, 73.42, 13.78, 74.09
          ],
          "confidence": 0.987
        }
      ]
    }
  ]
}

DLL Wrapper (oneocr_wrapper.dll)

A reusable C DLL wrapper with 3 main APIs:

FunctionDescription
initModel(model_dir)Load DLL + model, initialize pipeline
ocrImage(image_path, json, alloc)OCR an image file → JSON string
ocrImageEx(image_path, json, alloc, max_lines, resize_w, resize_h)OCR with configurable options
ocrImageRaw(pixel_data, w, h, step, json, alloc)OCR on raw BGRA pixel buffer
releaseModel()Clean up all resources

C++ Header-Only Usage (oneocr.h)

#include "oneocr.h"

OneOcr ocr;                               // loads oneocr_wrapper.dll
ocr.initModel(L".");                      // directory with oneocr.dll + .onemodel

std::string json;
ocr.ocrImage(L"test.png", json);          // basic OCR
ocr.ocrImageEx(L"test.png", json, 50);    // max 50 lines
ocr.ocrImageRaw(bgra_ptr, w, h, json);    // raw buffer OCR

Visualization (visualize.py)

python visualize.py <image_path> <json_path> [output_path]

Features:

  • 8-point polygon bounding boxes (lines in red, words colored by confidence)
  • Confidence score labels below each word
  • Handwritten lines highlighted in orange, printed in red
  • Image angle and line count overlay

Build

Requires: MSVC (Visual Studio), json.hpp (nlohmann/json), stb_image.h.

# Build CLI
cl /EHsc /O2 ocr.cpp /Fe:ocr.exe

# Build wrapper DLL
cl /EHsc /O2 /LD oneocr_wrapper.cpp /Fe:oneocr_wrapper.dll

# Build test
cl /EHsc /O2 oneocr_test.cpp /Fe:oneocr_test.exe

Other Implementations

DirectoryLanguageDescription
oneocr/PythonPyPI package with PIL/cv2 input, FastAPI web server
oneocr-rs/Rustcrates.io library with image crate, serde JSON
oneocr-cli/RustMinimal CLI, plain text output
win11_oneocr_py/PythonBasic ctypes script (original Python port)

Credits

License

MIT

使用前核对

安装步骤、兼容版本与授权范围以原项目当前文档为准。Stars 和评分是快照中的导航信号。

安装与排错 · 项目问题反馈

同类项目