DdddOcr.NetCore
1.0.0
dotnet add package DdddOcr.NetCore --version 1.0.0
NuGet\Install-Package DdddOcr.NetCore -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DdddOcr.NetCore" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DdddOcr.NetCore" Version="1.0.0" />
<PackageReference Include="DdddOcr.NetCore" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DdddOcr.NetCore --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DdddOcr.NetCore, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DdddOcr.NetCore@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DdddOcr.NetCore&version=1.0.0
#tool nuget:?package=DdddOcr.NetCore&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
DdddOcr.NET
DdddOcr的.NET Core 10.0完整重构版本 - 开箱即用的通用验证码识别SDK
✨ 本包已包含完整模型文件(85MB),安装即可使用,无需额外下载!
🚀 快速开始
1. 安装包
dotnet add package DdddOcr.NET
2. 使用
using DdddOcr.Core;
// 创建实例(模型已内置,开箱即用)
using var ocr = new DdddOcr();
// 识别验证码
byte[] imageBytes = File.ReadAllBytes("captcha.png");
string result = ocr.Classification(imageBytes);
Console.WriteLine($"识别结果: {result}");
📦 包含的模型
| 模型文件 | 大小 | 用途 |
|---|---|---|
| common_old.onnx | 13 MB | 默认OCR模型(快速) |
| common.onnx | 52 MB | Beta版OCR模型(高准确率) |
| common_det.onnx | 19 MB | 目标检测模型(YOLOX) |
💡 使用示例
基础OCR识别
using var ocr = new DdddOcr();
string code = ocr.Classification(imageBytes);
使用Beta模型(更高准确率)
var config = new OcrConfig { Beta = true };
using var ocr = new DdddOcr(config);
string code = ocr.Classification(imageBytes);
目标检测
using var ocr = new DdddOcr();
var boxes = ocr.Detection(imageBytes);
foreach (var box in boxes)
{
Console.WriteLine($"位置: ({box.X}, {box.Y}), 置信度: {box.Confidence}");
}
滑块匹配
using var ocr = new DdddOcr();
float offset = ocr.SlideMatch(targetBytes, backgroundBytes);
Console.WriteLine($"滑块偏移: {offset}");
限制字符集
using var ocr = new DdddOcr();
ocr.SetRanges("0123456789"); // 仅数字
string code = ocr.Classification(imageBytes);
⚙️ 配置选项
var config = new OcrConfig
{
// 模型配置
ModelsPath = "E:/models", // 自定义模型路径(可选)
Old = false, // 使用旧版模型
Beta = true, // 使用Beta版模型
ImportOnnxPath = "", // 自定义ONNX模型
CharsetsPath = "", // 自定义字符集
// 性能配置
UseGpu = false, // 启用GPU
DeviceId = 0 // GPU设备ID
};
using var ocr = new DdddOcr(config);
📊 性能指标
- 识别速度: < 100ms/张(CPU)
- 内存占用: < 200MB
- 支持格式: PNG, JPG, BMP, GIF
- 目标框架: .NET 10.0+
🎯 核心特性
- ✅ 开箱即用 - 内置完整模型文件,无需额外下载
- ✅ 高准确率 - 基于深度学习的OCR识别
- ✅ 多场景支持 - 验证码识别、目标检测、滑块匹配
- ✅ 简单易用 - 简洁的API设计
- ✅ 跨平台 - 支持Windows、Linux、macOS
- ✅ 高性能 - 基于ONNX Runtime推理引擎
📝 完整文档
🤝 贡献
欢迎提交Issue和Pull Request!
📄 许可证
Apache-2.0 License
🙏 致谢
- ddddocr - Python原版项目
- ONNX Runtime
- ImageSharp
- OpenCvSharp
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Microsoft.ML.OnnxRuntime (>= 1.26.0)
- OpenCvSharp4 (>= 4.13.0.20260427)
- OpenCvSharp4.runtime.win (>= 4.13.0.20260302)
- SixLabors.ImageSharp (>= 3.1.12)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 164 | 5/10/2026 |