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
1529291b
authored
2020-10-20 11:18:22 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add field order & add RP
1 parent
cc0dc16d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
9 deletions
src/apps/doc/consts.py
src/apps/doc/management/commands/doc_ocr_process.py
src/apps/doc/ocr/wb.py
src/apps/doc/consts.py
View file @
1529291
This diff is collapsed.
Click to expand it.
src/apps/doc/management/commands/doc_ocr_process.py
View file @
1529291
...
...
@@ -159,6 +159,7 @@ class Command(BaseCommand, LoggerMixin):
ed_list
.
append
(
summary
[
6
])
def
license1_process
(
self
,
ocr_data
,
license_summary
,
classify
,
skip_img
,
img_path
):
# 类别:'0'身份证, '1'居住证
license_data
=
ocr_data
.
get
(
'data'
,
[])
if
not
license_data
:
skip_img
.
append
(
self
.
parse_img_path
(
img_path
))
...
...
@@ -174,7 +175,7 @@ class Command(BaseCommand, LoggerMixin):
# res_dict[chn_key] = ocr_res_2.get(en_key, '')
license_summary
.
setdefault
(
classify
,
[])
.
append
(
ocr_res_2
)
else
:
# 营业执照
、行驶证
等
# 营业执照等
for
result_dict
in
ocr_res_2
.
get
(
'ResultList'
,
[]):
res_dict
=
{}
for
field_dict
in
result_dict
.
get
(
'FieldList'
,
[]):
...
...
@@ -224,7 +225,7 @@ class Command(BaseCommand, LoggerMixin):
elif
classify
in
consts
.
LICENSE_CLASSIFY_SET_1
:
# 证件1
self
.
license1_process
(
ocr_data
,
license_summary
,
classify
,
skip_img
,
img_path
)
elif
classify
in
consts
.
LICENSE_CLASSIFY_SET_2
:
# 证件2
pid
,
_
,
_
=
consts
.
LICENSE_CLASSIFY_MAPPING
.
get
(
classify
)
pid
,
_
,
_
,
_
,
_
=
consts
.
LICENSE_CLASSIFY_MAPPING
.
get
(
classify
)
json_data_2
=
{
"pid"
:
str
(
pid
),
"key"
:
conf
.
OCR_KEY
,
...
...
@@ -490,8 +491,7 @@ class Command(BaseCommand, LoggerMixin):
# 识别失败:普通异常,如PDF异常、构建过程异常
# EDMS异常:下载异常-->回队列-->邮件;上传异常-->重新上传队列-->邮件
# 算法异常:第一道异常-->识别失败-->邮件;第二道异常-->识别失败-->邮件
# TODO 协程异步发送OCR请求
# TODO 调用接口重试
# TODO OCR接口调用重试
# TODO 数据库断联问题
def
handle
(
self
,
*
args
,
**
kwargs
):
sleep_second
=
int
(
conf
.
SLEEP_SECOND
)
...
...
src/apps/doc/ocr/wb.py
View file @
1529291
...
...
@@ -360,15 +360,20 @@ class BSWorkbook(Workbook):
self
.
remove
(
self
.
get_sheet_by_name
(
sheet
))
def
license_rebuild
(
self
,
license_summary
,
document_scheme
):
for
classify
,
(
_
,
name
,
field_order
)
in
consts
.
LICENSE_ORDER
:
# 机动车登记证:CA和SE不同顺序
if
classify
==
consts
.
MVC_CLASSIFY
and
document_scheme
==
consts
.
DOC_SCHEME_LIST
[
1
]:
field_order
=
consts
.
MVC_SE_FIELD_ORDER
for
classify
,
(
_
,
name
,
field_order
,
side_diff
,
scheme_diff
)
in
consts
.
LICENSE_ORDER
:
license_list
=
license_summary
.
get
(
classify
)
if
license_list
is
None
:
if
not
license_list
:
continue
ws
=
self
.
create_sheet
(
name
)
if
scheme_diff
and
document_scheme
==
consts
.
DOC_SCHEME_LIST
[
1
]:
classify
=
consts
.
MVC_CLASSIFY_SE
for
license_dict
in
license_list
:
if
classify
==
consts
.
IC_CLASSIFY
and
license_dict
.
get
(
'类别'
)
==
'1'
:
license_summary
.
setdefault
(
consts
.
RP_CLASSIFY
,
[])
.
append
(
license_dict
)
continue
if
side_diff
:
key
,
field_order_yes
,
field_order_no
=
consts
.
FIELD_ORDER_MAP
.
get
(
classify
)
field_order
=
field_order_yes
if
key
in
license_dict
else
field_order_no
for
search_field
,
write_field
in
field_order
:
ws
.
append
((
write_field
,
license_dict
.
get
(
search_field
,
''
)))
ws
.
append
((
None
,
))
...
...
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