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
fd556337
authored
2022-04-18 20:03:04 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add contract 8.5
1 parent
2dc31fab
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
3 deletions
src/celery_compare/tasks.py
src/common/electronic_afc_contract/afc_contract_ocr.py
src/common/electronic_afc_contract/get_char.py
src/celery_compare/tasks.py
View file @
fd55633
...
...
@@ -2970,6 +2970,8 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True
auto_obj
=
auto_class
.
objects
.
filter
(
application_id
=
application_id
,
on_off
=
True
)
.
first
()
if
auto_obj
is
not
None
:
auto_result
=
se_compare_auto
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
,
auto_obj
)
else
:
auto_result
=
None
full_result
=
se_compare
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
,
is_cms
,
auto_result
)
...
...
src/common/electronic_afc_contract/afc_contract_ocr.py
View file @
fd55633
...
...
@@ -6,28 +6,35 @@
# @Description :
from
.get_char
import
Finder
import
numpy
as
np
def
predict
(
pdf_info
):
ocr_results
=
{}
for
pno
in
pdf_info
:
ocr_results
[
pno
]
=
{}
ocr_result
=
[]
for
key
,
block
in
enumerate
(
pdf_info
[
pno
][
'blocks'
]):
if
block
[
'type'
]
!=
0
:
continue
for
line
in
block
[
'lines'
]:
for
span
in
line
[
'spans'
]:
bbox
,
text
=
span
[
'bbox'
],
span
[
'text'
]
if
len
(
text
)
==
0
:
continue
# print(text)
xmin
,
ymin
,
xmax
,
ymax
=
bbox
polygon
=
[
xmin
,
ymin
,
xmax
,
ymin
,
xmax
,
ymax
,
xmin
,
ymax
]
polygon
=
np
.
array
(
polygon
,
dtype
=
np
.
int32
)
.
tolist
()
text
=
text
.
replace
(
":"
,
":"
)
.
replace
(
" "
,
""
)
ocr_results
[
pno
][
key
]
=
[
polygon
,
text
]
ocr_result
.
append
([
polygon
,
text
])
ocr_result
=
sorted
(
ocr_result
,
key
=
lambda
x
:
x
[
0
][
1
],
reverse
=
False
)
# 按 y0 从小到大排
keys
=
list
(
range
(
len
(
ocr_result
)))
ocr_result
=
dict
(
zip
(
keys
,
ocr_result
))
ocr_results
[
pno
]
=
ocr_result
# 输入是整个 PDF 中的信息
f
=
Finder
(
pdf_info
,
ocr_results
=
ocr_results
)
results
=
f
.
get_info
()
return
results
...
...
src/common/electronic_afc_contract/get_char.py
View file @
fd55633
This diff is collapsed.
Click to expand it.
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