脚本宝典收集整理的这篇文章主要介绍了PaddleOCRSharp,2022年,你来的晚了些,一款.NET离线使用的高精度OCR,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
本项目是一个基于百度飞桨的PaddleOCR的C++代码修改并封装的.NET的类库。包含文本识别、文本检测、基于文本检测结果的统计分析的表格识别功能,同时针对小图识别不准的情况下,做了优化,提高识别准确率。项目封装极其简化,实际调用仅一行代码,极大的方便了中下游开发者的使用和降低了PaddleOCR的使用入门级别,同时提供不同的.NET框架使用,方便各个行业应用开发与部署。
其中PaddleOCR.dll文件是基于开源项目PaddleOCR的C++代码修改而成的C++动态库,基于oPEncv的x64编译而成的。
模型库支持轻量版(本项目)、服务器版模型库(更准确),可以自行更改模型库适用实际需求。
关于源码编译,建议采用vs2019及以上版本编译,如果遇到无法编译,请切换成release后再切换回debug即可。
本项目包含文本识别、文本检测、基于文本检测结果的统计分析的表格识别功能,同时针对小图识别不准的情况下,做了优化,提高识别准确率。项目封装极其简化,实际调用仅一行代码,极大的方便了中下游开发者的使用和降低了PaddleOCR的使用入门级别,同时提供不同的.NET框架使用,支持框架如下:
net40;net461;netstandard2.0;netcoreapP3.1;net5.0;
方便各个行业应用开发与部署。
C++示例代码
1 #include <iostream> 2 #include <Windows.h> 3 #include "include/PaddleOCR.h" 4 #include "include/OCRResult.h" 5 #include <tchar.h> 6 #include "string" 7 #PRagma comment (lib,"PaddleOCR.lib") 8 using namespace std; 9 int main() 10 { 11 LpOCRResult lpocrreult; 12 modeldata md; 13 OCRParameter parameter; 14 char path[MAX_PATH]; 15 GetcurrentDirectoryA(MAX_PATH, path); 16 string cls_infer(path); 17 cls_infer += "\inference\ch_ppocr_mobile_v2.0_cls_infer"; 18 string rec_infer(path); 19 rec_infer += "\inference\ch_PP-OCRv2_rec_infer"; 20 string det_infer(path); 21 det_infer += "\inference\ch_PP-OCRv2_det_infer"; 22 string ocrkeys(path); 23 ocrkeys += "\inference\ppocr_keys.txt"; 24 string imagefile(path); 25 imagefile += "\test.png"; 26 md.cls_infer = const_cast<char*>(cls_infer.c_str()); 27 md.rec_infer = const_cast<char*>(rec_infer.c_str()); 28 md.det_infer = const_cast<char*>(det_infer.c_str()); 29 md.keys = const_cast<char*>(ocrkeys.c_str()); 30 md.imagefile = const_cast<char*>(imagefile.c_str()); 31 int cout =detect(md.det_infer, md.cls_infer, md.rec_infer, md.keys, md.imagefile, parameter, &lpocrreult); 32 for (size_t i = 0; i < cout; i++) 33 { 34 wstring ss =(WCHAR*)(lpocrreult->pOCRText[i].ptext); 35 std::wcout <<ss; 36 } 37 FreeDetectMem(lpocrreult); 38 }
.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)); OCRResult ocrResult = PaddleOCRSharp.PaddleOCRHelper.DetectText(bitmap,null); if (ocrResult != null) { MessageBox.Show(ocrResult.Text,"识别结果"); }
PaddleOCRSharp项目地址: 码云:https://gitee.COM/raoyutian/paddle-ocrsharpgithub:https://github.com/raoyutian/PaddleOCRSharp
QQ群:318860399
以上是脚本宝典为你收集整理的PaddleOCRSharp,2022年,你来的晚了些,一款.NET离线使用的高精度OCR全部内容,希望文章能够帮你解决PaddleOCRSharp,2022年,你来的晚了些,一款.NET离线使用的高精度OCR所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。