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
5c7e5769
authored
2021-05-31 10:55:19 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
dda excel
1 parent
23c4a341
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
20 deletions
src/apps/doc/consts.py
src/apps/doc/management/commands/ocr_process.py
src/apps/doc/ocr/wb.py
src/apps/doc/consts.py
View file @
5c7e576
...
...
@@ -836,7 +836,7 @@ MVI_FIELD_ORDER = (('发票代码', '发票代码'),
(
'主管税务机关及代码'
,
'主管税务机关及代码'
),
(
'吨位'
,
'吨位'
),
(
'限乘人数'
,
'限乘人数'
),)
IC_PID
=
VAT_PID
=
VATS_PID
=
MVC_PID
=
MVI_PID
=
RP_PID
=
None
IC_PID
=
VAT_PID
=
VATS_PID
=
MVC_PID
=
MVI_PID
=
RP_PID
=
DDA_PID
=
None
# 营业执照
BL_CN_NAME
=
'营业执照'
...
...
@@ -944,6 +944,24 @@ BC_FIELD_ORDER = (('BankName', '发卡行名称'),
DDA_CN_NAME
=
'DDA'
DDA_CLASSIFY
=
38
DDA_IC_NAME
=
'customer_name'
DDA_IC_ID
=
'customer_id'
DDA_BC_NAME
=
'account_name'
DDA_BC_ID
=
'account_id'
DDA_FIELD_ORDER
=
{
"title"
:
"授权书标题"
,
"check_Num"
:
"缴费编号"
,
"to_company"
:
"收款企业"
,
"to_bank"
:
"收款银行"
,
DDA_IC_NAME
:
"客户姓名"
,
DDA_IC_ID
:
"客户身份证号"
,
DDA_BC_NAME
:
"账户姓名"
,
DDA_BC_ID
:
"账户号码"
,
"signature"
:
"客户签名"
,
"signature_date"
:
"签名日期"
}
SUCCESS_CODE_SET
=
{
'0'
,
0
}
FIELD_ORDER_MAP
=
{
...
...
@@ -977,7 +995,9 @@ LICENSE_ORDER = ((MVI_CLASSIFY, (MVI_PID, MVI_CN_NAME, MVI_FIELD_ORDER, False, F
(
DL_CLASSIFY
,
(
DL_PID
,
DL_CN_NAME
,
None
,
True
,
False
,
MODEL_FIELD_DL
)),
(
PP_CLASSIFY
,
(
PP_PID
,
PP_CN_NAME
,
PP_FIELD_ORDER
,
False
,
False
,
MODEL_FIELD_PP
)),
(
MVC_CLASSIFY
,
(
MVC_PID
,
MVC_CN_NAME
,
None
,
True
,
True
,
MODEL_FIELD_MVC
)),
(
VAT_CLASSIFY
,
(
VAT_PID
,
VAT_CN_NAME
,
VAT_FIELD_ORDER
,
False
,
False
,
MODEL_FIELD_VAT
)))
(
VAT_CLASSIFY
,
(
VAT_PID
,
VAT_CN_NAME
,
VAT_FIELD_ORDER
,
False
,
False
,
MODEL_FIELD_VAT
)),
(
DDA_CLASSIFY
,
(
DDA_PID
,
DDA_CN_NAME
,
DDA_FIELD_ORDER
,
False
,
False
,
None
)),
)
FOLDER_LICENSE_ORDER
=
((
MVI_CLASSIFY
,
(
MVI_PID
,
MVI_CN_NAME
,
MVI_FIELD_ORDER
,
False
,
False
,
MODEL_FIELD_MVI
)),
(
IC_CLASSIFY
,
(
IC_PID
,
IC_CN_NAME
,
None
,
True
,
False
,
MODEL_FIELD_IC
)),
...
...
@@ -1204,10 +1224,6 @@ BC_FIELD = 'BC'
IC_KEY_FIELD
=
(
'姓名'
,
'公民身份号码'
)
BC_KEY_FIELD
=
'CardNum'
DDA_IC_NAME
=
'customer_name'
DDA_IC_ID
=
'customer_id'
DDA_BC_NAME
=
'account_name'
DDA_BC_ID
=
'account_id'
DDA_IMG_PATH
=
'img_path'
DDA_PRO
=
'pro'
...
...
@@ -1218,3 +1234,7 @@ DDA_MAPPING = [
(
DDA_BC_ID
,
BC_FIELD
),
]
DDA_PRO_MIN
=
0.6
...
...
src/apps/doc/management/commands/ocr_process.py
View file @
5c7e576
...
...
@@ -199,17 +199,14 @@ class Command(BaseCommand, LoggerMixin):
if
not
license_data
:
res_list
.
append
((
pno
,
ino
,
part_idx
,
consts
.
RES_SUCCESS_EMPTY
))
return
res_list
.
append
((
pno
,
ino
,
part_idx
,
consts
.
RES_SUCCESS
))
if
classify
==
consts
.
DDA_CLASSIFY
:
# DDA处理
pro
=
ocr_data
.
get
(
'confidence'
)
dda_ocr_result
=
{
consts
.
DDA_IC_NAME
:
license_data
.
get
(
'result'
,
{})
.
get
(
consts
.
DDA_IC_NAME
,
{})
.
get
(
'words'
,
''
),
consts
.
DDA_IC_ID
:
license_data
.
get
(
'result'
,
{})
.
get
(
consts
.
DDA_IC_ID
,
{})
.
get
(
'words'
,
''
),
consts
.
DDA_BC_NAME
:
license_data
.
get
(
'result'
,
{})
.
get
(
consts
.
DDA_BC_NAME
,
{})
.
get
(
'words'
,
''
),
consts
.
DDA_BC_ID
:
license_data
.
get
(
'result'
,
{})
.
get
(
consts
.
DDA_BC_ID
,
{})
.
get
(
'words'
,
''
),
consts
.
DDA_IMG_PATH
:
img_path
,
consts
.
DDA_PRO
:
pro
}
pro
=
ocr_data
.
get
(
'confidence'
,
0
)
if
pro
<
consts
.
DDA_PRO_MIN
:
res_list
.
append
((
pno
,
ino
,
part_idx
,
consts
.
RES_SUCCESS_EMPTY
))
return
dda_ocr_result
=
{
key
:
value
.
get
(
'words'
,
''
)
for
key
,
value
in
license_data
.
get
(
'result'
,
{})
.
items
()}
dda_ocr_result
[
consts
.
DDA_IMG_PATH
]
=
img_path
dda_ocr_result
[
consts
.
DDA_PRO
]
=
pro
license_summary
.
setdefault
(
classify
,
[])
.
append
(
dda_ocr_result
)
elif
classify
==
consts
.
MVC_CLASSIFY
:
# 车辆登记证 3/4页结果整合
...
...
@@ -304,6 +301,7 @@ class Command(BaseCommand, LoggerMixin):
license_summary
.
setdefault
(
classify
,
[])
.
extend
(
license_data
)
else
:
license_summary
.
setdefault
(
classify
,
[])
.
extend
(
license_data
)
res_list
.
append
((
pno
,
ino
,
part_idx
,
consts
.
RES_SUCCESS
))
def
license2_process
(
self
,
ocr_res_2
,
license_summary
,
pid
,
classify
,
res_list
,
pno
,
ino
,
part_idx
,
img_path
,
do_dda
,
dda_id_bc_mapping
):
if
ocr_res_2
.
get
(
'ErrorCode'
)
in
consts
.
SUCCESS_CODE_SET
:
...
...
@@ -1046,9 +1044,10 @@ class Command(BaseCommand, LoggerMixin):
if
len
(
dda_res_list
)
>
0
:
dda_res_list
.
sort
(
key
=
lambda
x
:
x
.
get
(
consts
.
DDA_PRO
,
0
),
reverse
=
True
)
tmp_best_dda_res
=
dda_res_list
[
0
]
if
tmp_best_dda_res
.
get
(
consts
.
DDA_PRO
,
0
)
>=
0.6
:
best_dda_res
=
tmp_best_dda_res
best_dda_res
=
dda_res_list
[
0
]
# tmp_best_dda_res = dda_res_list[0]
# if tmp_best_dda_res.get(consts.DDA_PRO, 0) >= consts.DDA_PRO_MIN:
# best_dda_res = tmp_best_dda_res
self
.
online_log
.
info
(
'{0} [dda process] [task={1}] [dda={2}]'
.
format
(
self
.
log_base
,
task_str
,
dda_res_list
))
...
...
src/apps/doc/ocr/wb.py
View file @
5c7e576
...
...
@@ -654,7 +654,8 @@ class BSWorkbook(Workbook):
ws
.
append
((
write_field
,
field_value
))
ws
.
append
((
None
,
))
count
+=
1
count_list
.
append
((
field_str
,
count
))
if
field_str
is
not
None
:
count_list
.
append
((
field_str
,
count
))
def
simple_license_rebuild
(
self
,
license_summary
,
document_scheme
):
# for ic_license_dict in license_summary.get(consts.IC_CLASSIFY, []):
...
...
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