删除 ocr
This commit is contained in:
parent
2f5be4d780
commit
3dc95e7686
|
|
@ -1,65 +0,0 @@
|
||||||
using PaddleOCRSharp;
|
|
||||||
using System;
|
|
||||||
using System.Drawing;
|
|
||||||
|
|
||||||
public class OcrHelper
|
|
||||||
{
|
|
||||||
|
|
||||||
//private static TesseractEngine engine = new TesseractEngine("./ocr_models", "chi_sim");
|
|
||||||
//public static OCRResult GetOcrResult(Bitmap bitmap)
|
|
||||||
//{
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// using var tempBitmap = new Bitmap(bitmap);
|
|
||||||
// var ocrResult = paddleOCREngine.DetectText(tempBitmap);
|
|
||||||
// return ocrResult;
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// ExceptionNotice.SendAsync(ex, "Ocr文字识别异常!");
|
|
||||||
// throw;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
private static string RootDirectory = EngineBase.GetRootDirectory().TrimEnd('\\') + "\\inference";
|
|
||||||
|
|
||||||
//建议程序全局初始化一次即可,不必每次识别都初始化,容易报错。
|
|
||||||
private static PaddleOCREngine paddleOCREngine = paddleOCREngine = new PaddleOCREngine(new OCRModelConfig()
|
|
||||||
{
|
|
||||||
det_infer = RootDirectory + "\\ch_PP-OCRv3_det_infer",
|
|
||||||
cls_infer= RootDirectory + "\\ch_ppocr_mobile_v2.0_cls_infer",
|
|
||||||
rec_infer = RootDirectory + "\\ch_PP-OCRv3_rec_infer",
|
|
||||||
keys = RootDirectory + "\\ppocr_keys.txt",
|
|
||||||
}, new OCRParameter());
|
|
||||||
|
|
||||||
public static OCRResult GetOcrResult(Bitmap bitmap)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (var tempBitmap = new Bitmap(bitmap))
|
|
||||||
{
|
|
||||||
return paddleOCREngine.DetectText(tempBitmap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static OCRResult GetOcrResult(byte[] bytes)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var ocrResult = paddleOCREngine.DetectText(bytes);
|
|
||||||
return ocrResult;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net48" />
|
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net48" />
|
||||||
<package id="PaddleOCRSharp" version="4.0.1" targetFramework="net48" />
|
|
||||||
</packages>
|
</packages>
|
||||||
Loading…
Reference in New Issue