Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张东亮
/
NS100
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 1973404b
由
张东亮
编写于
2023-04-24 13:34:31 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
ocr同行标签区分
1 个父辈
93e26866
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
11 行增加
和
3 行删除
paddleOCR/PaddleSharpAPI.cs
paddleOCR/PaddleSharpAPI.cs
查看文件 @
1973404
...
@@ -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!
Cancel
请
注册
或
登录
后发表评论