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
01314b0c
authored
2022-10-07 22:46:34 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add se oct
1 parent
07c844aa
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
15 deletions
src/celery_compare/tasks.py
src/celery_compare/tasks.py
View file @
01314b0
...
...
@@ -2377,9 +2377,10 @@ def se_compare_license_id(license_en, id_res_list, field_list):
result_field_list
=
[]
section_img_info
=
dict
()
field_img_path_dict
=
dict
()
field_last_idx
=
len
(
field_list
)
-
1
# ocr_res_str = ocr_res_dict.get(ocr_field)
for
ocr_res_str
in
id_res_list
:
for
ca_or_se_idx
,
ocr_res_str
in
enumerate
(
id_res_list
)
:
if
is_find
:
break
...
...
@@ -2428,16 +2429,11 @@ def se_compare_license_id(license_en, id_res_list, field_list):
result
=
getattr
(
cp
,
compare_logic
[
name
][
1
])(
value
,
ocr_str
,
**
compare_logic
[
name
][
2
])
no_key
=
False
if
idx
==
0
and
result
==
consts
.
RESULT_N
and
length
>
1
:
if
idx
==
0
and
result
==
consts
.
RESULT_N
:
if
ca_or_se_idx
==
0
:
break
elif
length
>
1
:
break
is_find
=
True
section_img_info
[
consts
.
SECTION_IMG_PATH_KEY
]
=
ocr_res_list
[
res_idx
]
.
get
(
consts
.
SECTION_IMG_PATH_KEY
,
''
)
section_img_info
[
consts
.
ALL_POSITION_KEY
]
=
ocr_res_list
[
res_idx
]
.
get
(
consts
.
ALL_POSITION_KEY
,
{})
if
special_expiry_date
:
section_img_info
[
consts
.
SECTION_IMG_PATH_KEY_2
]
=
ocr_res_list
[
res_idx
]
.
get
(
consts
.
SECTION_IMG_PATH_KEY_2
,
''
)
section_img_info
[
consts
.
ALL_POSITION_KEY_2
]
=
ocr_res_list
[
res_idx
]
.
get
(
consts
.
ALL_POSITION_KEY_2
,
{})
# 过期期限特殊处理
if
special_expiry_date
and
name
==
'idExpiryDate'
and
result
==
consts
.
RESULT_N
:
...
...
@@ -2448,14 +2444,17 @@ def se_compare_license_id(license_en, id_res_list, field_list):
img_path
=
empty_str
else
:
for
expiry_date
,
(
date_img_path
,
date_res_idx
)
in
expiry_dates
.
items
():
expiry_date_res
=
getattr
(
cp
,
compare_logic
[
name
][
1
])(
value
,
expiry_date
,
**
compare_logic
[
name
][
2
])
expiry_date_res
=
getattr
(
cp
,
compare_logic
[
name
][
1
])(
value
,
expiry_date
,
**
compare_logic
[
name
][
2
])
if
expiry_date_res
==
consts
.
RESULT_N
:
ocr_str
=
expiry_date
img_path
=
date_img_path
special_expiry_date_slice
=
True
section_img_info
[
consts
.
SECTION_IMG_PATH_KEY_2
]
=
ocr_res_list
[
date_res_idx
]
.
get
(
section_img_info
[
consts
.
SECTION_IMG_PATH_KEY_2
]
=
ocr_res_list
[
date_res_idx
]
.
get
(
consts
.
SECTION_IMG_PATH_KEY_2
,
''
)
section_img_info
[
consts
.
ALL_POSITION_KEY_2
]
=
ocr_res_list
[
date_res_idx
]
.
get
(
section_img_info
[
consts
.
ALL_POSITION_KEY_2
]
=
ocr_res_list
[
date_res_idx
]
.
get
(
consts
.
ALL_POSITION_KEY_2
,
{})
break
else
:
...
...
@@ -2466,7 +2465,27 @@ def se_compare_license_id(license_en, id_res_list, field_list):
img_path
=
ocr_res_list
[
res_idx
]
.
get
(
consts
.
IMG_PATH_KEY_2
,
''
)
special_expiry_date_slice
=
True
else
:
img_path
=
ocr_res_list
[
res_idx
]
.
get
(
consts
.
IMG_PATH_KEY
,
''
)
if
result
==
consts
.
RESULT_N
else
empty_str
img_path
=
ocr_res_list
[
res_idx
]
.
get
(
consts
.
IMG_PATH_KEY
,
''
)
if
result
==
consts
.
RESULT_N
else
empty_str
if
ca_or_se_idx
==
0
and
result
==
consts
.
RESULT_N
:
special_expiry_date_slice
=
False
section_img_info
.
pop
(
consts
.
SECTION_IMG_PATH_KEY_2
,
None
)
section_img_info
.
pop
(
consts
.
ALL_POSITION_KEY_2
,
None
)
break
if
ca_or_se_idx
==
1
:
is_find
=
True
elif
idx
==
field_last_idx
:
is_find
=
True
section_img_info
[
consts
.
SECTION_IMG_PATH_KEY
]
=
ocr_res_list
[
res_idx
]
.
get
(
consts
.
SECTION_IMG_PATH_KEY
,
''
)
section_img_info
[
consts
.
ALL_POSITION_KEY
]
=
ocr_res_list
[
res_idx
]
.
get
(
consts
.
ALL_POSITION_KEY
,
{})
if
special_expiry_date
and
consts
.
SECTION_IMG_PATH_KEY_2
not
in
section_img_info
:
section_img_info
[
consts
.
SECTION_IMG_PATH_KEY_2
]
=
ocr_res_list
[
res_idx
]
.
get
(
consts
.
SECTION_IMG_PATH_KEY_2
,
''
)
section_img_info
[
consts
.
ALL_POSITION_KEY_2
]
=
ocr_res_list
[
res_idx
]
.
get
(
consts
.
ALL_POSITION_KEY_2
,
{})
if
isinstance
(
value
,
list
):
value
=
json
.
dumps
(
value
,
ensure_ascii
=
False
)
error_type
=
empty_error_type
if
result
==
consts
.
RESULT_Y
else
ErrorType
.
OCR
.
value
...
...
@@ -3148,8 +3167,8 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True
id_res_list
=
[]
for
field_name
in
consts
.
CA_ADD_COMPARE_FIELDS
:
if
field_name
==
consts
.
IC_OCR_FIELD
:
id_res_list
.
append
(
ocr_res_dict
.
get
(
field_name
))
id_res_list
.
append
(
ca_ocr_res_dict
.
get
(
field_name
)
if
isinstance
(
ca_ocr_res_dict
,
dict
)
else
None
)
id_res_list
.
append
(
ocr_res_dict
.
get
(
field_name
))
if
isinstance
(
ca_ocr_res_dict
,
dict
)
and
isinstance
(
ca_ocr_res_dict
.
get
(
field_name
),
str
):
tmp_ca_result
=
json
.
loads
(
ca_ocr_res_dict
.
get
(
field_name
))
...
...
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