Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
周伟奇
/
bmw-ocr
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
b17b3c65
authored
2021-06-14 02:55:11 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add img count
1 parent
615edaa5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
8 deletions
src/apps/doc/consts.py
src/apps/doc/ocr/wb.py
src/apps/doc/consts.py
View file @
b17b3c6
...
...
@@ -99,6 +99,7 @@ RES_FAILED = '识别失败'
RES_FAILED_1
=
'识别失败(阶段1)'
RES_FAILED_2
=
'识别失败(阶段2)'
RES_FAILED_3
=
'识别失败(阶段1数据格式错误)'
RES_FAILED_SET
=
{
RES_FAILED
,
RES_FAILED_1
,
RES_FAILED_2
,
RES_FAILED_3
}
CARD_RATIO
=
0.9
UNKNOWN_CARD
=
'未知卡号'
...
...
src/apps/doc/ocr/wb.py
View file @
b17b3c6
...
...
@@ -310,13 +310,15 @@ class BSWorkbook(Workbook):
month_mapping
.
setdefault
(
item
,
[])
.
append
(
(
ws
.
title
,
idx_list
[
i
]
+
min_row
,
idx_list
[
i
+
1
]
+
min_row
-
1
,
day_mean
))
def
build_metadata_rows
(
self
,
confidence
,
code
,
print_time
,
start_date
,
end_date
):
def
build_metadata_rows
(
self
,
confidence
,
code
,
print_time
,
start_date
,
end_date
,
res_count_tuple
):
if
start_date
is
None
or
end_date
is
None
:
timedelta
=
None
else
:
timedelta
=
(
end_date
-
start_date
)
.
days
metadata_rows
=
[
(
'流水识别置信度'
,
confidence
),
(
'图片总数'
,
res_count_tuple
[
0
]),
(
'识别成功'
,
res_count_tuple
[
1
]),
self
.
blank_row
,
self
.
code_header
,
]
...
...
@@ -330,8 +332,8 @@ class BSWorkbook(Workbook):
)
return
metadata_rows
def
build_meta_sheet
(
self
,
role_name
,
card
,
confidence
,
code
,
print_time
,
start_date
,
end_date
):
metadata_rows
=
self
.
build_metadata_rows
(
confidence
,
code
,
print_time
,
start_date
,
end_date
)
def
build_meta_sheet
(
self
,
role_name
,
card
,
confidence
,
code
,
print_time
,
start_date
,
end_date
,
res_count_tuple
):
metadata_rows
=
self
.
build_metadata_rows
(
confidence
,
code
,
print_time
,
start_date
,
end_date
,
res_count_tuple
)
if
not
isinstance
(
role_name
,
str
):
role_name
=
consts
.
UNKNOWN_ROLE
ms
=
self
.
create_sheet
(
'{0}{1}({2})'
.
format
(
self
.
meta_sheet_title
,
role_name
,
card
))
...
...
@@ -595,7 +597,7 @@ class BSWorkbook(Workbook):
ms
.
append
(
row
)
self
.
remove
(
tmp2_ws
)
def
bs_rebuild
(
self
,
bs_summary
):
def
bs_rebuild
(
self
,
bs_summary
,
res_count_tuple
):
# bs_summary = {
# '卡号': {
# 'classify': 0,
...
...
@@ -656,7 +658,8 @@ class BSWorkbook(Workbook):
summary
.
get
(
'code'
),
summary
.
get
(
'print_time'
),
start_date
,
end_date
)
end_date
,
res_count_tuple
)
# 3.创建月份表、提取/高亮关键行
# 倒序处理
...
...
@@ -737,21 +740,35 @@ class BSWorkbook(Workbook):
res_list
.
sort
(
key
=
lambda
x
:
(
x
[
0
],
x
[
1
],
x
[
2
]))
ws
=
self
.
create_sheet
(
consts
.
RES_SHEET_NAME
)
ws
.
append
(
consts
.
RES_SHEET_HEADER
)
success_count
=
0
for
res_tuple
in
res_list
:
if
res_tuple
[
-
1
]
not
in
consts
.
RES_FAILED_SET
:
success_count
+=
1
ws
.
append
(
res_tuple
)
return
len
(
res_list
),
success_count
else
:
return
0
,
0
def
move_res_sheet
(
self
):
sheet
=
self
.
get_sheet_by_name
(
consts
.
RES_SHEET_NAME
)
idx
=
self
.
_sheets
.
index
(
sheet
)
del
self
.
_sheets
[
idx
]
self
.
_sheets
.
append
(
sheet
)
def
remove_base_sheet
(
self
):
if
len
(
self
.
sheetnames
)
>
1
:
self
.
remove
(
self
.
get_sheet_by_name
(
'Sheet'
))
def
rebuild
(
self
,
bs_summary
,
license_summary
,
res_list
,
document_scheme
):
res_count_tuple
=
self
.
res_sheet
(
res_list
)
count_list
=
[(
consts
.
MODEL_FIELD_BS
,
len
(
bs_summary
))]
if
document_scheme
==
consts
.
DOC_SCHEME_LIST
[
1
]:
self
.
license_rebuild
(
license_summary
,
document_scheme
,
count_list
)
self
.
bs_rebuild
(
bs_summary
)
self
.
bs_rebuild
(
bs_summary
,
res_count_tuple
)
else
:
self
.
bs_rebuild
(
bs_summary
)
self
.
bs_rebuild
(
bs_summary
,
res_count_tuple
)
self
.
license_rebuild
(
license_summary
,
document_scheme
,
count_list
)
self
.
res_sheet
(
res_list
)
self
.
move_res_sheet
(
)
self
.
remove_base_sheet
()
return
count_list
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment