Commit 1973404b 张东亮

ocr同行标签区分

1 个父辈 93e26866
...@@ -10,6 +10,7 @@ using System.IO; ...@@ -10,6 +10,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography.X509Certificates;
using System.Text; using System.Text;
using System.Web;
namespace paddleOCR namespace paddleOCR
{ {
...@@ -145,6 +146,13 @@ namespace paddleOCR ...@@ -145,6 +146,13 @@ namespace paddleOCR
var res = engine.DetectText(imagebyte); var res = engine.DetectText(imagebyte);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
res.TextBlocks.ForEach(s => { score += s.Score; sb.AppendLine(s.Text); }); res.TextBlocks.ForEach(s => { score += s.Score; sb.AppendLine(s.Text); });
//foreach (var item in ocrResult.TextBlocks)
//{
// using (Graphics g = Graphics.FromImage(bitmap))
// {
// g.DrawPolygon(new Pen(Brushes.Red, 2), item.BoxPoints.Select(x => new PointF() { X = x.X, Y = x.Y }).ToArray());
// }
//}
log.Info($"【{item.FullName}】结果:【{score}】【{sb.ToString().Replace("\r", "").Replace("\n", ";")}】"); log.Info($"【{item.FullName}】结果:【{score}】【{sb.ToString().Replace("\r", "").Replace("\n", ";")}】");
if (score > maxScore) if (score > maxScore)
{ {
...@@ -206,7 +214,7 @@ namespace paddleOCR ...@@ -206,7 +214,7 @@ namespace paddleOCR
lineTxt.Value.Sort(delegate (TextBlock x1, TextBlock x2) { if (x1.BoxPoints[0].X > x2.BoxPoints[0].X) return 1; else return -1; }); lineTxt.Value.Sort(delegate (TextBlock x1, TextBlock x2) { if (x1.BoxPoints[0].X > x2.BoxPoints[0].X) return 1; else return -1; });
foreach (var text in lineTxt.Value) foreach (var text in lineTxt.Value)
{ {
log.Info($"行{lineTxt.Key}【{text.BoxPoints[0]}】【{text.BoxPoints[3]}】【{text.Text}】"); log.Info($"行{lineTxt.Key}【{text.ToString()}】");
stringBuilder.Append(text.Text); stringBuilder.Append(text.Text);
} }
stringBuilder.AppendLine(); stringBuilder.AppendLine();
...@@ -255,7 +263,7 @@ namespace paddleOCR ...@@ -255,7 +263,7 @@ namespace paddleOCR
{ {
if (p1y2 > p2y4 || p1y3 < p2y1) return false; if (p1y2 > p2y4 || p1y3 < p2y1) return false;
else if (Math.Abs(p1x1 - p2x0) > intervalPixel) return false; if (Math.Abs(p1x1 - p2x0) > intervalPixel) return false;
else else
return true; return true;
...@@ -264,7 +272,7 @@ namespace paddleOCR ...@@ -264,7 +272,7 @@ namespace paddleOCR
else else
{ {
if (p2y2 > p1y4 || p2y3 < p1y1) return false; if (p2y2 > p1y4 || p2y3 < p1y1) return false;
else if (Math.Abs(p2x1 - p1x0) > intervalPixel) return false; if (Math.Abs(p2x1 - p1x0) > intervalPixel) return false;
else else
return true; return true;
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!