Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yinnxinn
chineseocr
提交
c0eef572
C
chineseocr
项目概览
yinnxinn
/
chineseocr
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
chineseocr
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c0eef572
编写于
8月 25, 2018
作者:
W
wenlihaoyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
web页面显示OCR识别时间
上级
d0c41f60
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
10 deletion
+14
-10
app.py
app.py
+4
-2
static/js/helps.js
static/js/helps.js
+8
-6
templates/ocr.html
templates/ocr.html
+2
-2
未找到文件。
app.py
浏览文件 @
c0eef572
...
...
@@ -43,6 +43,7 @@ class OCR:
f
.
write
(
imgString
)
img
=
Image
.
open
(
path
).
convert
(
"RGB"
)
W
,
H
=
img
.
size
timeTake
=
time
.
time
()
_
,
result
,
angle
=
model
.
model
(
img
,
detectAngle
=
True
,
config
=
dict
(
MAX_HORIZONTAL_GAP
=
200
,
MIN_V_OVERLAPS
=
0.6
,
MIN_SIZE_SIM
=
0.6
,
...
...
@@ -56,12 +57,13 @@ class OCR:
textmodel
=
'opencv_dnn_detect'
),
leftAdjust
=
True
,
rightAdjust
=
True
,
alph
=
0.1
)
timeTake
=
time
.
time
()
-
timeTake
res
=
map
(
lambda
x
:{
'w'
:
x
[
'w'
],
'h'
:
x
[
'h'
],
'cx'
:
x
[
'cx'
],
'cy'
:
x
[
'cy'
],
'degree'
:
x
[
'degree'
],
'text'
:
x
[
'text'
]},
result
)
res
=
list
(
res
)
os
.
remove
(
path
)
return
json
.
dumps
(
res
,
ensure_ascii
=
False
)
return
json
.
dumps
(
{
'res'
:
res
,
'timeTake'
:
round
(
timeTake
,
4
)}
,
ensure_ascii
=
False
)
...
...
static/js/helps.js
浏览文件 @
c0eef572
...
...
@@ -12,7 +12,9 @@ function postImg(){
success
:
function
(
d
){
loadingGif
(
'
loadingGif
'
);
imgJson
[
'
num
'
]
=
0
;
//防止重复提交
imgJson
[
"
result
"
]
=
JSON
.
parse
(
d
);
res
=
JSON
.
parse
(
d
);
imgJson
[
"
result
"
]
=
res
[
'
res
'
];
imgJson
[
"
timeTake
"
]
=
res
[
'
timeTake
'
];
getChildDetail
();
W
=
imgJson
[
"
width
"
];
H
=
imgJson
[
"
height
"
];
...
...
@@ -75,7 +77,7 @@ function FunimgPreview(avatarSlect,avatarPreview,myCanvas) {
function
getChildDetail
(){
jQuery
(
"
#billmodeltable
"
).
remove
();
childResult
=
imgJson
[
"
result
"
];
createTable
(
childResult
);
//新建table
createTable
(
childResult
,
imgJson
[
'
timeTake
'
]
);
//新建table
}
...
...
@@ -83,19 +85,19 @@ function getChildDetail(){
//根据获取的数据,创建table
//创建table
function
createTable
(
result
){
function
createTable
(
result
,
timeTake
){
//根据获取的数据,创建table
jQuery
(
"
#mytable
"
).
empty
();
var
jsObject
=
result
;
//var jsObject = [{"name":10,"value":20},{"name":10,"value":20}];
var
p
=
"
<h
2>识别结果为:</h2>
"
var
tableString
=
"
<table id='billmodeltable' class='gridtable'><tr><th>序号</th><th>值</th></tr>
"
var
p
=
"
<h
3>耗时:
"
+
timeTake
+
"
秒 ,识别结果为:</h3>
"
;
var
tableString
=
p
+
"
<table id='billmodeltable' class='gridtable'><tr><th>序号</th><th>值</th></tr>
"
for
(
var
i
=
0
;
i
<
jsObject
.
length
;
i
++
){
tableString
+=
"
<tr><td><p>
"
+
i
+
"
</p></td><td><p contenteditable='true'>
"
+
jsObject
[
i
][
"
text
"
]
+
"
</p></td></tr>
"
;
}
tableString
+=
"
</table>
"
;
jQuery
(
"
#mytable
"
).
append
(
p
);
//
jQuery("#mytable").append(p);
jQuery
(
"
#mytable
"
).
append
(
tableString
);
}
...
...
templates/ocr.html
浏览文件 @
c0eef572
...
...
@@ -40,9 +40,9 @@ table.gridtable td {
imgJson
=
{
"
imgString
"
:
""
,
"
num
"
:
0
,
"
url
"
:
""
,
"
result
"
:
""
"
result
"
:
""
,
"
timeTake
"
:
0.0
};
</script>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录