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
59da79a4
authored
2021-10-05 16:50:10 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
slice part 1
1 parent
85d82a3e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
3 deletions
src/apps/doc/consts.py
src/apps/doc/management/commands/ocr_process.py
src/apps/doc/consts.py
View file @
59da79a
...
...
@@ -1542,6 +1542,9 @@ BC_FIELD_ORDER_2 = (('BankName', '发卡行名称'),
IMG_PATH_KEY
=
'uniq_img_path_key'
IMG_PATH_KEY_2
=
'uniq_img_path_key_2'
POSITION_KEY
=
'uniq_position_key'
SECTION_KEY
=
'uniq_section_key'
ANGLE_KEY
=
'uniq_angle_key'
INFO_SOURCE
=
[
'POS'
,
'CMS'
]
...
...
src/apps/doc/management/commands/ocr_process.py
View file @
59da79a
...
...
@@ -373,7 +373,7 @@ class Command(BaseCommand, LoggerMixin):
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
):
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
,
section_img_path
=
None
):
if
ocr_res_2
.
get
(
'ErrorCode'
)
in
consts
.
SUCCESS_CODE_SET
:
res_list
.
append
((
pno
,
ino
,
part_idx
,
consts
.
RES_SUCCESS
))
if
pid
==
consts
.
BC_PID
:
...
...
@@ -390,10 +390,17 @@ class Command(BaseCommand, LoggerMixin):
else
:
# 营业执照等
for
result_dict
in
ocr_res_2
.
get
(
'ResultList'
,
[]):
position
=
result_dict
.
get
(
'position'
,
{})
angle
=
result_dict
.
get
(
'angle'
,
0
)
res_dict
=
{}
position_dict
=
{}
for
field_dict
in
result_dict
.
get
(
'FieldList'
,
[]):
res_dict
[
field_dict
.
get
(
'chn_key'
,
''
)]
=
field_dict
.
get
(
'value'
,
''
)
res_dict
[
consts
.
IMG_PATH_KEY
]
=
img_path
position_dict
[
field_dict
.
get
(
'chn_key'
,
''
)]
=
field_dict
.
get
(
'position'
,
[])
position_dict
[
consts
.
SECTION_KEY
]
=
position
position_dict
[
consts
.
ANGLE_KEY
]
=
angle
res_dict
[
consts
.
IMG_PATH_KEY
]
=
section_img_path
if
isinstance
(
section_img_path
,
str
)
else
img_path
res_dict
[
consts
.
POSITION_KEY
]
=
position_dict
license_summary
.
setdefault
(
classify
,
[])
.
append
(
res_dict
)
else
:
res_list
.
append
((
pno
,
ino
,
part_idx
,
consts
.
RES_FAILED_2
))
...
...
@@ -972,9 +979,23 @@ class Command(BaseCommand, LoggerMixin):
card_name_res
.
get
(
'data'
,
{})
.
get
(
'is_exists_name'
)
==
0
:
name
=
'无'
ocr_2_res
[
'Name'
]
=
name
section_img_path
=
None
try
:
if
ocr_2_res
.
get
(
'ErrorCode'
)
in
consts
.
SUCCESS_CODE_SET
:
pre
,
suf
=
os
.
path
.
splitext
(
img_path
)
section_img_path
=
'{0}_{1}{2}'
.
format
(
pre
,
part_idx
,
suf
)
with
open
(
section_img_path
,
"wb"
)
as
fh
:
fh
.
write
(
base64
.
b64decode
(
file_data
.
encode
()))
except
Exception
as
e
:
self
.
online_log
.
warn
(
'{0} [section img save failed] [img_path={1}]'
' [part_idx={2}]'
.
format
(
self
.
log_base
,
img_path
,
part_idx
))
self
.
license2_process
(
ocr_2_res
,
license_summary
,
pid
,
classify
,
res_list
,
pno
,
ino
,
part_idx
,
img_path
,
do_dda
,
dda_id_bc_mapping
)
do_dda
,
dda_id_bc_mapping
,
section_img_path
=
section_img_path
)
break
else
:
res_list
.
append
((
pno
,
ino
,
part_idx
,
consts
.
RES_FAILED_2
))
...
...
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