PaddleOCR.Onnx
1.2.0
dotnet add package PaddleOCR.Onnx --version 1.2.0
NuGet\Install-Package PaddleOCR.Onnx -Version 1.2.0
<PackageReference Include="PaddleOCR.Onnx" Version="1.2.0" />
paket add PaddleOCR.Onnx --version 1.2.0
#r "nuget: PaddleOCR.Onnx, 1.2.0"
// Install PaddleOCR.Onnx as a Cake Addin #addin nuget:?package=PaddleOCR.Onnx&version=1.2.0 // Install PaddleOCR.Onnx as a Cake Tool #tool nuget:?package=PaddleOCR.Onnx&version=1.2.0
如果对你有用或者喜欢,那就给颗星赞,点个赞。谢谢!
一、介绍
本项目使用ONNX模型,速度更快。本项目同时支持X64和X86的CPU上上用。 本项目是一个基于PaddleOCR的C++代码修改并基于Microsoft.ML封装的.NET的工具类库。包含文本识别、文本检测、基于文本检测结果的统计分析的表格识别功能,同时针对小图识别不准的情况下,做了优化,提高识别准确率。包含总模型仅8.6M的超轻量级中文OCR,单模型支持中英文数字组合识别、竖排文本识别、长文本识别。同时支持多种文本检测。 项目封装极其简化,实际调用仅几行代码,极大的方便了中下游开发者的使用和降低了PaddleOCR的使用入门级别,同时提供不同的.NET框架使用,方便各个行业应用开发与部署。Nuget包即装即用,可以离线部署,不需要网络就可以识别的高精度中英文OCR。
目前不支持win7及以下操作系统。
本项目目前支持以下NET框架:
net461;net462;net47;net471;net48;net481;
netstandard2.0;netcoreapp3.1;
net5.0;net6.0;net7.0;
代码推荐使用VS2022版本编译。
OCR识别模型库支持官方所有的模型,也支持自己训练的模型。
本项目部署自带的一种轻量版8.6M模型库、服务器版模型库(更准确,需要自行下载),可以自行更改模型库适用实际需求。
模型需要转成ONNX格式采用被本项目所使用。 PaddleOCR模型转换
如果需要修改成服务器版模型库,参考代码如下:(假设服务器版模型库在运行目录的文件夹inferenceserver下)
//自带轻量版中英文模型
// OCRModelConfig config = null;
//服务器中英文模型
//OCRModelConfig config = new OCRModelConfig();
//string root = Environment.CurrentDirectory;
//string modelPathroot = root + @"\inferenceserver";
//config.det_infer = modelPathroot + @"\ch_ppocr_server_v2.0_det_infer.onnx";
//config.cls_infer = modelPathroot + @"\ch_ppocr_mobile_v2.0_cls_infer.onnx";
//config.rec_infer = modelPathroot + @"\ch_ppocr_server_v2.0_rec_infer.onnx";
//config.keys = modelPathroot + @"\ppocr_keys.txt";
//英文和数字模型
OCRModelConfig config = new OCRModelConfig();
string root = Environment.CurrentDirectory;
string modelPathroot = root + @"\en";
config.det_infer = modelPathroot + @"\ch_PP-OCRv2_det_infer";
config.cls_infer = modelPathroot + @"\ch_ppocr_mobile_v2.0_cls_infer.onnx";
config.rec_infer = modelPathroot + @"\en_number_mobile_v2.0_rec_infer.onnx";
config.keys = modelPathroot + @"\en_dict.txt";
PaddleOCREngine engine = new PaddleOCREngine(config, oCRParameter);
二、.NET使用示例
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "*.*|*.bmp;*.jpg;*.jpeg;*.tiff;*.tiff;*.png";
if (ofd.ShowDialog() != DialogResult.OK) return;
var imagebyte = File.ReadAllBytes(ofd.FileName);
Bitmap bitmap = new Bitmap(new MemoryStream(imagebyte));
OCRModelConfig config = null;
OCRParameter oCRParameter = new OCRParameter ();
OCRResult ocrResult = new OCRResult();
//建议程序全局初始化一次即可,不必每次识别都初始化,容易报错。
PaddleOCREngine engine = new PaddleOCREngine(config, oCRParameter);
{
ocrResult = engine.DetectText(bitmap );
}
if (ocrResult != null)
{
MessageBox.Show(ocrResult.Text,"识别结果");
}
QQ交流群:318860399 ,有问题可以加QQ群咨询。
微信公众号:明月心技术学堂。
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 is compatible. |
.NET Framework | net461 is compatible. net462 is compatible. net463 was computed. net47 is compatible. net471 is compatible. net472 was computed. 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
- clipper_standard (>= 0.0.1)
- Emgu.CV (>= 4.4.0.4099)
- Emgu.CV.runtime.windows (>= 4.4.0.4099)
- Microsoft.ML.OnnxRuntime (>= 1.11.0)
- Microsoft.ML.OnnxRuntime.Managed (>= 1.11.0)
- System.Drawing.Common (>= 6.0.0)
-
.NETFramework 4.6.1
- clipper_standard (>= 0.0.1)
- Emgu.CV (>= 4.4.0.4099)
- Emgu.CV.runtime.windows (>= 4.4.0.4099)
- Microsoft.ML.OnnxRuntime (>= 1.11.0)
- Microsoft.ML.OnnxRuntime.Managed (>= 1.11.0)
-
.NETFramework 4.6.2
- clipper_standard (>= 0.0.1)
- Emgu.CV (>= 4.4.0.4099)
- Emgu.CV.runtime.windows (>= 4.4.0.4099)
- Microsoft.ML.OnnxRuntime (>= 1.11.0)
- Microsoft.ML.OnnxRuntime.Managed (>= 1.11.0)
-
.NETFramework 4.7
- clipper_standard (>= 0.0.1)
- Emgu.CV (>= 4.4.0.4099)
- Emgu.CV.runtime.windows (>= 4.4.0.4099)
- Microsoft.ML.OnnxRuntime (>= 1.11.0)
- Microsoft.ML.OnnxRuntime.Managed (>= 1.11.0)
-
.NETFramework 4.7.1
- clipper_standard (>= 0.0.1)
- Emgu.CV (>= 4.4.0.4099)
- Emgu.CV.runtime.windows (>= 4.4.0.4099)
- Microsoft.ML.OnnxRuntime (>= 1.11.0)
- Microsoft.ML.OnnxRuntime.Managed (>= 1.11.0)
-
.NETFramework 4.8
- clipper_standard (>= 0.0.1)
- Emgu.CV (>= 4.4.0.4099)
- Emgu.CV.runtime.windows (>= 4.4.0.4099)
- Microsoft.ML.OnnxRuntime (>= 1.11.0)
- Microsoft.ML.OnnxRuntime.Managed (>= 1.11.0)
-
.NETFramework 4.8.1
- clipper_standard (>= 0.0.1)
- Emgu.CV (>= 4.4.0.4099)
- Emgu.CV.runtime.windows (>= 4.4.0.4099)
- Microsoft.ML.OnnxRuntime (>= 1.11.0)
- Microsoft.ML.OnnxRuntime.Managed (>= 1.11.0)
-
.NETStandard 2.0
- clipper_standard (>= 0.0.1)
- Emgu.CV (>= 4.4.0.4099)
- Emgu.CV.runtime.windows (>= 4.4.0.4099)
- Microsoft.ML.OnnxRuntime (>= 1.11.0)
- Microsoft.ML.OnnxRuntime.Managed (>= 1.11.0)
- System.Drawing.Common (>= 6.0.0)
-
.NETStandard 2.1
- clipper_standard (>= 0.0.1)
- Emgu.CV (>= 4.4.0.4099)
- Emgu.CV.runtime.windows (>= 4.4.0.4099)
- Microsoft.ML.OnnxRuntime (>= 1.11.0)
- Microsoft.ML.OnnxRuntime.Managed (>= 1.11.0)
- System.Drawing.Common (>= 6.0.0)
-
net5.0
- clipper_standard (>= 0.0.1)
- Emgu.CV (>= 4.4.0.4099)
- Emgu.CV.runtime.windows (>= 4.4.0.4099)
- Microsoft.ML.OnnxRuntime (>= 1.11.0)
- Microsoft.ML.OnnxRuntime.Managed (>= 1.11.0)
- System.Drawing.Common (>= 6.0.0)
-
net6.0
- clipper_standard (>= 0.0.1)
- Emgu.CV (>= 4.4.0.4099)
- Emgu.CV.runtime.windows (>= 4.4.0.4099)
- Microsoft.ML.OnnxRuntime (>= 1.11.0)
- Microsoft.ML.OnnxRuntime.Managed (>= 1.11.0)
- System.Drawing.Common (>= 6.0.0)
-
net7.0
- clipper_standard (>= 0.0.1)
- Emgu.CV (>= 4.4.0.4099)
- Emgu.CV.runtime.windows (>= 4.4.0.4099)
- Microsoft.ML.OnnxRuntime (>= 1.11.0)
- Microsoft.ML.OnnxRuntime.Managed (>= 1.11.0)
- System.Drawing.Common (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.