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
cc3a4534
authored
2021-08-17 17:16:43 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add img path
1 parent
03d5853c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
10 deletions
src/apps/doc/consts.py
src/apps/doc/management/commands/ocr_process.py
src/celery_compare/tasks.py
src/apps/doc/consts.py
View file @
cc3a453
...
...
@@ -1448,4 +1448,6 @@ SE_SECOND_ID_FIELD_MAPPING = {
HEAD_LIST
=
[
'Info'
,
'Index'
,
'License'
,
'Field'
,
'Input'
,
'OCR'
,
'Result'
,
'Position'
,
'Image'
,
'errorType'
]
IMG_PATH_KEY
=
'uniq_img_path_key'
...
...
src/apps/doc/management/commands/ocr_process.py
View file @
cc3a453
...
...
@@ -221,10 +221,12 @@ class Command(BaseCommand, LoggerMixin):
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
dda_ocr_result
[
consts
.
IMG_PATH_KEY
]
=
img_path
license_summary
.
setdefault
(
classify
,
[])
.
append
(
dda_ocr_result
)
elif
classify
==
consts
.
MVC_CLASSIFY
:
# 车辆登记证 3/4页结果整合
for
mvc_dict
in
license_data
:
mvc_dict
[
consts
.
IMG_PATH_KEY
]
=
img_path
try
:
mvc_page
=
mvc_dict
.
pop
(
'page'
)
except
Exception
as
e
:
...
...
@@ -242,6 +244,7 @@ class Command(BaseCommand, LoggerMixin):
elif
classify
==
consts
.
IC_CLASSIFY
:
# 身份证真伪
for
id_card_dict
in
license_data
:
id_card_dict
[
consts
.
IMG_PATH_KEY
]
=
img_path
try
:
base64_img
=
id_card_dict
.
pop
(
'base64_img'
)
except
Exception
as
e
:
...
...
@@ -294,6 +297,8 @@ class Command(BaseCommand, LoggerMixin):
dda_id_bc_mapping
.
setdefault
(
consts
.
IC_FIELD
,
[])
.
append
((
ic_name
,
ic_id
,
img_path
))
license_summary
.
setdefault
(
classify
,
[])
.
extend
(
license_data
)
else
:
for
res_dict
in
license_data
:
res_dict
[
consts
.
IMG_PATH_KEY
]
=
img_path
license_summary
.
setdefault
(
classify
,
[])
.
extend
(
license_data
)
res_list
.
append
((
pno
,
ino
,
part_idx
,
consts
.
RES_SUCCESS
))
...
...
@@ -305,6 +310,7 @@ class Command(BaseCommand, LoggerMixin):
# res_dict = {}
# for en_key, chn_key in consts.BC_FIELD:
# res_dict[chn_key] = ocr_res_2.get(en_key, '')
ocr_res_2
[
consts
.
IMG_PATH_KEY
]
=
img_path
license_summary
.
setdefault
(
classify
,
[])
.
append
(
ocr_res_2
)
if
do_dda
and
isinstance
(
ocr_res_2
.
get
(
consts
.
BC_KEY_FIELD
),
str
):
bc_no
=
ocr_res_2
[
consts
.
BC_KEY_FIELD
]
.
strip
()
...
...
@@ -316,6 +322,7 @@ class Command(BaseCommand, LoggerMixin):
res_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
license_summary
.
setdefault
(
classify
,
[])
.
append
(
res_dict
)
else
:
res_list
.
append
((
pno
,
ino
,
part_idx
,
consts
.
RES_FAILED_2
))
...
...
@@ -1023,7 +1030,7 @@ class Command(BaseCommand, LoggerMixin):
license_list
=
license_summary
.
get
(
classify
)
if
not
license_list
:
continue
if
classify
==
consts
.
IC_CLASSIFY
and
ic_merge
:
if
classify
==
consts
.
IC_CLASSIFY
and
ic_merge
:
# TODO 正反面合并时的img_path处理
license_list
[
0
]
.
update
(
license_list
[
1
])
license_list
.
pop
(
1
)
elif
classify
==
consts
.
RP_CLASSIFY
and
rp_merge
:
...
...
src/celery_compare/tasks.py
View file @
cc3a453
...
...
@@ -671,12 +671,13 @@ def se_compare_license(license_en, ocr_res_dict, field_list):
result
=
expiry_date_res
break
img_path
=
ocr_res_list
[
res_idx
]
.
get
(
consts
.
IMG_PATH_KEY
,
''
)
if
result
==
consts
.
RESULT_N
else
empty_str
error_type
=
empty_str
if
result
==
consts
.
RESULT_Y
else
ErrorType
.
OCR
.
value
result_field_list
.
append
((
name
,
value
,
result
,
ocr_str
,
error_type
))
result_field_list
.
append
((
name
,
value
,
result
,
ocr_str
,
img_path
,
error_type
))
if
not
is_find
:
for
name
,
value
in
field_list
:
result_field_list
.
append
((
name
,
value
,
consts
.
RESULT_N
,
empty_str
,
ErrorType
.
NF
.
value
))
result_field_list
.
append
((
name
,
value
,
consts
.
RESULT_N
,
empty_str
,
empty_str
,
ErrorType
.
NF
.
value
))
return
result_field_list
...
...
@@ -696,6 +697,7 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list):
first_res
=
None
for
res_idx
in
range
(
length
-
1
,
-
1
,
-
1
):
if
consts
.
TRANSFER_DATE
in
ocr_res_list
[
res_idx
]:
img_path
=
ocr_res_list
[
res_idx
]
.
get
(
consts
.
IMG_PATH_KEY
,
''
)
for
idx
,
transfer_date
in
enumerate
(
ocr_res_list
[
res_idx
]
.
get
(
consts
.
TRANSFER_DATE
,
[])):
try
:
transfer_name
=
ocr_res_list
[
res_idx
]
.
get
(
consts
.
TRANSFER_NAME
,
[])[
idx
]
...
...
@@ -708,7 +710,8 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list):
core_info
=
{
consts
.
TRANSFER_NAME
:
transfer_name
,
consts
.
TRANSFER_NUM
:
transfer_num
,
consts
.
TRANSFER_DATE
:
transfer_date
consts
.
TRANSFER_DATE
:
transfer_date
,
consts
.
IMG_PATH_KEY
:
img_path
,
}
page34_date_dict
.
setdefault
(
transfer_date
,
[])
.
append
(
core_info
)
if
first_res
is
None
:
...
...
@@ -734,12 +737,13 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list):
ocr_str
=
empty_str
else
:
result
=
getattr
(
cp
,
compare_logic
[
name
][
1
])(
value
,
ocr_str
,
**
compare_logic
[
name
][
2
])
img_path
=
ocr_res
.
get
(
consts
.
IMG_PATH_KEY
,
''
)
if
result
==
consts
.
RESULT_N
else
empty_str
error_type
=
empty_str
if
result
==
consts
.
RESULT_Y
else
ErrorType
.
OCR
.
value
result_field_list
.
append
((
name
,
value
,
result
,
ocr_str
,
error_type
))
result_field_list
.
append
((
name
,
value
,
result
,
ocr_str
,
img_path
,
error_type
))
if
not
is_find
:
for
name
,
value
in
field_list
:
result_field_list
.
append
((
name
,
value
,
consts
.
RESULT_N
,
empty_str
,
ErrorType
.
NF
.
value
))
result_field_list
.
append
((
name
,
value
,
consts
.
RESULT_N
,
empty_str
,
empty_str
,
ErrorType
.
NF
.
value
))
return
result_field_list
...
...
@@ -762,7 +766,7 @@ def se_compare_process(compare_info, ocr_res_dict):
for
license_en
,
field_list
in
license_dict
.
items
():
failure_field
=
[]
result_field_list
=
se_compare_license
(
license_en
,
ocr_res_dict
,
field_list
)
for
name
,
value
,
result
,
ocr_str
,
error_type
in
result_field_list
:
for
name
,
value
,
result
,
ocr_str
,
img_path
,
error_type
in
result_field_list
:
total_fields
+=
1
if
result
==
consts
.
RESULT_N
:
failed_count
+=
1
...
...
@@ -778,7 +782,7 @@ def se_compare_process(compare_info, ocr_res_dict):
'OCR'
:
ocr_str
,
'Result'
:
result
,
'Position'
:
empty_str
,
'Image'
:
empty_str
,
'Image'
:
img_path
,
'errorType'
:
error_type
,
}
)
...
...
@@ -790,7 +794,7 @@ def se_compare_process(compare_info, ocr_res_dict):
result_field_list
=
se_mvc34_compare
(
license_en
,
ocr_res_dict
,
field_list
)
else
:
result_field_list
=
se_compare_license
(
license_en
,
ocr_res_dict
,
field_list
)
for
name
,
value
,
result
,
ocr_str
,
error_type
in
result_field_list
:
for
name
,
value
,
result
,
ocr_str
,
img_path
,
error_type
in
result_field_list
:
total_fields
+=
1
if
result
==
consts
.
RESULT_N
:
failed_count
+=
1
...
...
@@ -806,7 +810,7 @@ def se_compare_process(compare_info, ocr_res_dict):
'OCR'
:
ocr_str
,
'Result'
:
result
,
'Position'
:
empty_str
,
'Image'
:
empty_str
,
'Image'
:
img_path
,
'errorType'
:
error_type
,
}
)
...
...
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