PaddleOCRSharp 3.0.0
See the version list below for details.
dotnet add package PaddleOCRSharp --version 3.0.0
NuGet\Install-Package PaddleOCRSharp -Version 3.0.0
<PackageReference Include="PaddleOCRSharp" Version="3.0.0" />
paket add PaddleOCRSharp --version 3.0.0
#r "nuget: PaddleOCRSharp, 3.0.0"
// Install PaddleOCRSharp as a Cake Addin #addin nuget:?package=PaddleOCRSharp&version=3.0.0 // Install PaddleOCRSharp as a Cake Tool #tool nuget:?package=PaddleOCRSharp&version=3.0.0
简体中文 | English |更新记录
如果对你有用或者喜欢,那就给颗星赞,点个赞。谢谢!
介绍
本项目是一个基于百度飞桨PaddleOCR的C++代码修改并封装的.NET的OCR工具类库。包含文本识别、文本检测、表格识别功能。本项目针对小图识别不准的情况下做了优化,比飞桨原代码识别准确率有所提高。包含总模型仅8.6M的超轻量级中文OCR,单模型支持中英文数字组合识别、竖排文本识别、长文本识别。同时支持多种文本检测。 项目封装极其简化,实际调用仅几行代码,极大的方便了中下游开发者的使用和降低了PaddleOCR的使用入门级别,同时提供不同的.NET框架使用,方便各个行业应用开发与部署。Nuget包即装即用,可以离线部署,不需要网络就可以识别的高精度中英文OCR。
本项目核心组件PaddleOCR.dll,由C++编写,根据百度飞桨PaddleOCR的C++代码修改而成。目前已经支持C++、.NET、Python、Golang、Rust等开发语言的直接API接口调用。因PaddleOCR.dll导出标准C函数接口,理论上支持更多的开发语言调用。
本项目已经适配PaddleOCR2.6以上开发版C++代码,并支持PP-OCRv3模型。 超轻量OCR系统PP-OCRv3:中英文、纯英文以及多语言场景精度再提升5% - 11%!
如果使用v2模型,请设置OCR识别参数OCRParameter对象的属性rec_img_h=32,本项目默认使用V3模型,默认rec_img_h=48:
本项目只能在X64的CPU上编译和使用,只能在avx指令集上的CPU上使用。其中PaddleOCR已经支持Linux平台下编译和使用。
本项目目前支持以下.NET框架:
net35;net40;net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;net481;
netstandard2.0;netcoreapp3.1;
net5.0;net6.0;net7.0;
本项目提供了两个SDK,一个是C++版本,一个是.net版本,.net版本是桥接C++的封装,核心还是C++代码。
源码编译
本项目编译使用opencv4.1.1版本,如需使用其他版本,请自行更换opencv版本编译。
1.文件夹结构
PaddleOCR //该文件夹包含PaddleOCR.dll文件的源代码
PaddleOCRSharp //该文件夹包含.NET对PaddleOCR封装类库项目
PaddleOCRDemo //该文件夹包含OCR示例Demo文件夹
|--PaddleOCRCppDemo //C++调用示例项目
|--PaddleOCRSharpDemo //.NET调用示例项目
2. C++版编译
3. .NET版编译
使用与部署
1. 在C++中使用PaddleOCR
2. 在.NET中使用PaddleOCRSharp
模型
OCR识别模型库支持官方所有的模型,也支持自己训练的模型。完全按照飞桨OCR接口搭桥。 本项目部署自带的一种轻量版8.6M模型库、服务器版模型库(更准确,需要自行下载),可以自行更改模型库适用实际需求。
模型名称 | 模型大小 | 下载地址 | 备注 |
---|---|---|---|
ch_PP-OCRv2 | 10M | 中英文轻量v2 | |
en_PP-OCRv2 | 4M | 英文数字v2 | |
ch_PP-OCRv3 | 12M | 中英文轻量v3 | |
en_PP-OCRv3 | 10M | 英文数字v3 |
如果需要修改成服务器版模型库,参考代码如下:(假设服务器版模型库在运行目录的文件夹inferenceserver下)
//自带轻量版中英文模型PP-OCRv3
// OCRModelConfig config = null;
//服务器中英文模型
//OCRModelConfig config = new OCRModelConfig();
//string root = System.IO.Path.GetDirectoryName(typeof(OCRModelConfig).Assembly.Location);
//string modelPathroot = root + @"\inferenceserver";
//config.det_infer = modelPathroot + @"\ch_ppocr_server_v2.0_det_infer";
//config.cls_infer = modelPathroot + @"\ch_ppocr_mobile_v2.0_cls_infer";
//config.rec_infer = modelPathroot + @"\ch_ppocr_server_v2.0_rec_infer";
//config.keys = modelPathroot + @"\ppocr_keys.txt";
//英文和数字模型
OCRModelConfig config = new OCRModelConfig();
string root = System.IO.Path.GetDirectoryName(typeof(OCRModelConfig).Assembly.Location);
string modelPathroot = root + @"\en";
config.det_infer = modelPathroot + @"\ch_PP-OCRv2_det_infer";
config.cls_infer = modelPathroot + @"\ch_ppocr_mobile_v2.0_cls_infer";
config.rec_infer = modelPathroot + @"\en_number_mobile_v2.0_rec_infer";
config.keys = modelPathroot + @"\en_dict.txt";
常见问题与解决方案
技术交流方式
QQ技术交流群:818391797,318860399
微信公众号:明月心技术学堂。
个人博客地址: https://www.cnblogs.com/raoyutian/
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net35 is compatible. net40 is compatible. net403 was computed. net45 is compatible. net451 is compatible. net452 is compatible. net46 is compatible. net461 is compatible. net462 is compatible. net463 was computed. net47 is compatible. net471 is compatible. net472 is compatible. net48 is compatible. net481 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETCoreApp 3.1
- Newtonsoft.Json (>= 12.0.1)
- System.Drawing.Common (>= 6.0.0)
-
.NETFramework 3.5
- Newtonsoft.Json (>= 12.0.1)
-
.NETFramework 4.0
- Newtonsoft.Json (>= 12.0.1)
-
.NETFramework 4.5
- Newtonsoft.Json (>= 12.0.1)
-
.NETFramework 4.5.1
- Newtonsoft.Json (>= 12.0.1)
-
.NETFramework 4.5.2
- Newtonsoft.Json (>= 12.0.1)
-
.NETFramework 4.6
- Newtonsoft.Json (>= 12.0.1)
-
.NETFramework 4.6.1
- Newtonsoft.Json (>= 12.0.1)
-
.NETFramework 4.6.2
- Newtonsoft.Json (>= 12.0.1)
-
.NETFramework 4.7
- Newtonsoft.Json (>= 12.0.1)
-
.NETFramework 4.7.1
- Newtonsoft.Json (>= 12.0.1)
-
.NETFramework 4.7.2
- Newtonsoft.Json (>= 12.0.1)
-
.NETFramework 4.8
- Newtonsoft.Json (>= 12.0.1)
-
.NETFramework 4.8.1
- Newtonsoft.Json (>= 12.0.1)
-
.NETStandard 2.0
- Newtonsoft.Json (>= 12.0.1)
- System.Drawing.Common (>= 6.0.0)
-
net5.0
- Newtonsoft.Json (>= 12.0.1)
- System.Drawing.Common (>= 6.0.0)
-
net6.0
- Newtonsoft.Json (>= 12.0.1)
- System.Drawing.Common (>= 6.0.0)
-
net7.0
- Newtonsoft.Json (>= 12.0.1)
- System.Drawing.Common (>= 6.0.0)
NuGet packages (8)
Showing the top 5 NuGet packages that depend on PaddleOCRSharp:
Package | Downloads |
---|---|
Starxcjy.DataAccess.CodeReader
图像处理库 |
|
Docimax.OCR.Core
Package Description |
|
RG3.PF.MklPaddleOCR
1、【RG3.PF.MklPaddleOCR】(数学计算函数和方法等) 5、使用请到github获取 RG3.PF.WebApp.Host 6、6.0.0.77开始,nodeserice迁移到RG3.PF.PinYinScriptEngineCliWrap 7、https://github.com/MKL-NET/MKL.NET 8、https://gitee.com/raoyutian/paddle-ocrsharp 9、https://gitee.com/paddlepaddle/PaddleOCR |
|
PaddleOcrCutPic
兼容4.7 |
|
MHCV
对常用CV(计算机视觉)库的进一步封装,简化操作,集成常用方法。 目前包含:PaddleOCRSharp |
GitHub repositories (4)
Showing the top 4 popular GitHub repositories that depend on PaddleOCRSharp:
Repository | Stars |
---|---|
ZGGSONG/STranslate
A ready-to-use, ready-to-go translation ocr tool developed by WPF/WPF 开发的一款即开即用、即用即走的翻译、OCR工具
|
|
raoyutian/PaddleOCRSharp
PaddleOCRSharp是一个基于百度飞桨PaddleOCR的C++代码修改并封装的.NET的OCR工具类库。包含文本识别、文本检测、表格识别功能。本项目针对小图识别不准的情况下做了优化,比飞桨原代码识别准确率有所提高。 包含总模型仅8.6M的超轻量级中文OCR,单模型支持中英文数字组合识别、竖排文本识别、长文本识别。同时支持多种文本检测。
|
|
xksoft/OcrHelper
桌面图像实时转文字工具
|
|
laosanyuan/HuoHuan
互联网微信群聊二维码获取工具
|
优化非托管代码返回的OCR结果格式