Commit aec75728 张东亮

paddle识别异常处理

1 个父辈 4ec07436
......@@ -143,6 +143,8 @@ namespace paddleOCR
List<TextBlock> list = new List<TextBlock>();
foreach (var item in dir.GetFiles())
{
try
{
float score = 0f;
var imagebyte = File.ReadAllBytes(item.FullName);
var res = engine.DetectText(imagebyte);
......@@ -162,6 +164,12 @@ namespace paddleOCR
list = res.TextBlocks;
}
}
catch (Exception ex)
{
log.Error($"{item.FullName}异常", ex);
}
}
log.Info($"使用识别分数【{maxScore}】");
Dictionary<int, List<TextBlock>> lines = new Dictionary<int, List<TextBlock>>();
int line = 0, idx = 0, i = 1;
......@@ -390,19 +398,19 @@ namespace paddleOCR
foreach (var entity in list)
{
double avgY = entity.BoxPoints.Average(a => a.Y);
if (Math.Abs(lastYAvg - avgY)<threshold)
if (Math.Abs(lastYAvg - avgY) < threshold)
{
mergedTextlist.Add(new StringIntPair(entity.Text, entity.BoxPoints[0].X));
}
else
{
if (mergedTextlist.Count!=0)
if (mergedTextlist.Count != 0)
{
var stringdata = mergedTextlist.OrderBy(a => a.IntValue);
string str = "";
foreach (var item in stringdata)
{
str+= item.StringValue+" ";
str += item.StringValue + " ";
}
stringLists.Add(str);
mergedTextlist.Clear();
......@@ -417,7 +425,7 @@ namespace paddleOCR
string str = "";
foreach (var item in stringdata)
{
str += item.StringValue+" ";
str += item.StringValue + " ";
}
stringLists.Add(str);
mergedTextlist.Clear();
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!