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
ca883d6b
authored
2023-02-08 11:19:58 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add cldls & fix FSM AFC noASP
1 parent
ab354761
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
94 additions
and
0 deletions
src/common/electronic_afc_contract/get_char_fsm.py
src/common/electronic_afc_contract/get_char_fsm.py
View file @
ca883d6
...
...
@@ -62,6 +62,7 @@ class Finder:
},
"page_3"
:
{
"合同编号"
:
self
.
item
,
"还款计划表"
:
self
.
item
,
"车辆代理商"
:
self
.
item
,
},
"page_4"
:
{
"合同编号"
:
self
.
item
,
"附加产品融资贷款本金总金额明细"
:
self
.
item
,
...
...
@@ -71,6 +72,7 @@ class Finder:
"page_6"
:
{
"合同编号"
:
self
.
item
,
},
}
if
self
.
is_asp
:
self
.
init_result
[
"page_7"
]
=
{
"合同编号"
:
self
.
item
,
}
self
.
init_result
[
"page_8"
]
=
{
"合同编号"
:
self
.
item
,
...
...
@@ -90,6 +92,25 @@ class Finder:
"日期"
:
self
.
item
,
},
}
else
:
self
.
init_result
[
"page_7"
]
=
{
"合同编号"
:
self
.
item
,
"主借人签字"
:
{
"签字"
:
self
.
item
,
"日期"
:
self
.
item
,
},
"共借人签字"
:
{
"签字"
:
self
.
item
,
"日期"
:
self
.
item
,
},
"保证人1签字"
:
{
"签字"
:
self
.
item
,
"日期"
:
self
.
item
,
},
"保证人2签字"
:
{
"签字"
:
self
.
item
,
"日期"
:
self
.
item
,
},
"见证人签字"
:
{
"签字"
:
self
.
item
,
"日期"
:
self
.
item
,
},
}
def
get_top_iou
(
self
,
poly
,
ocr_result
):
"""传入一个多边形, 找到与之最匹配的多边形
...
...
@@ -398,6 +419,39 @@ class Finder:
seller
[
'words'
]
=
text
return
seller
def
get_cldls
(
self
):
seller
=
self
.
item
.
copy
()
# 先找到 key
anchor_bbox
=
None
for
block
in
self
.
pdf_info
[
'2'
][
'blocks'
]:
if
anchor_bbox
is
not
None
:
break
if
block
[
'type'
]
!=
0
:
continue
for
line
in
block
[
'lines'
]:
if
anchor_bbox
is
not
None
:
break
for
span
in
line
[
'spans'
]:
bbox
,
text
=
span
[
'bbox'
],
span
[
'text'
]
if
text
.
strip
()
==
'车辆代理商'
:
anchor_bbox
=
bbox
# print(anchor_bbox)
# 当找到了 key, 则根据 key 去匹配 value
if
anchor_bbox
:
half_width
=
self
.
pdf_info
[
'2'
][
'width'
]
*
0.5
for
block
in
self
.
pdf_info
[
'2'
][
'blocks'
]:
if
block
[
'type'
]
!=
0
:
continue
for
line
in
block
[
'lines'
]:
for
span
in
line
[
'spans'
]:
bbox
,
text
=
span
[
'bbox'
],
span
[
'text'
]
if
anchor_bbox
[
2
]
<
np
.
mean
(
bbox
[::
2
])
<
half_width
and
\
anchor_bbox
[
1
]
<
np
.
mean
(
bbox
[
1
::
2
])
<
anchor_bbox
[
3
]:
seller
[
'position'
]
=
bbox
seller
[
'words'
]
=
text
return
seller
return
seller
def
get_borrower_collection_account
(
self
):
account
=
self
.
item
.
copy
()
account_name
=
self
.
item
.
copy
()
...
...
@@ -885,6 +939,9 @@ class Finder:
repayment_schedule_table
=
self
.
get_repayment_schedule
()
# print(repayment_schedule_table)
self
.
init_result
[
'page_3'
][
'还款计划表'
]
=
repayment_schedule_table
# 车辆代理商
cldls
=
self
.
get_cldls
()
self
.
init_result
[
'page_3'
][
'车辆代理商'
]
=
cldls
#######################################
# Page 4
# 找合同编号
...
...
@@ -907,6 +964,8 @@ class Finder:
contract_no
=
self
.
get_contract_no
(
page_num
=
'5'
)
# print(contract_no)
self
.
init_result
[
'page_6'
][
'合同编号'
]
=
contract_no
if
self
.
is_asp
:
# Page 7
# 找合同编号
contract_no
=
self
.
get_contract_no
(
page_num
=
'6'
)
...
...
@@ -944,6 +1003,41 @@ class Finder:
# print(signature_name, signature_date)
self
.
init_result
[
'page_8'
][
'见证人签字'
][
'签字'
]
=
signature_name
self
.
init_result
[
'page_8'
][
'见证人签字'
][
'日期'
]
=
signature_date
else
:
# Page 7
# 找合同编号
contract_no
=
self
.
get_contract_no
(
page_num
=
'6'
)
self
.
init_result
[
'page_7'
][
'合同编号'
]
=
contract_no
signature_name
,
signature_date
=
self
.
get_last_page_signature
(
page_num
=
'6'
,
top
=
'合同编号'
,
bottom
=
'共同借款人'
)
if
signature_name
[
'words'
]
==
None
:
signature_name
,
signature_date
=
self
.
get_last_page_signature
(
page_num
=
'6'
,
top
=
'合同编号'
,
bottom
=
'共同借款人(抵押人)'
)
# print(signature_name, signature_date)
self
.
init_result
[
'page_7'
][
'主借人签字'
][
'签字'
]
=
signature_name
self
.
init_result
[
'page_7'
][
'主借人签字'
][
'日期'
]
=
signature_date
signature_name
,
signature_date
=
self
.
get_last_page_signature
(
page_num
=
'6'
,
top
=
'共同借款人'
,
bottom
=
'保证人1'
)
if
signature_name
[
'words'
]
==
None
:
signature_name
,
signature_date
=
self
.
get_last_page_signature
(
page_num
=
'6'
,
top
=
'共同借款人(抵押人)'
,
bottom
=
'保证人1'
)
# print(signature_name, signature_date)
self
.
init_result
[
'page_7'
][
'共借人签字'
][
'签字'
]
=
signature_name
self
.
init_result
[
'page_7'
][
'共借人签字'
][
'日期'
]
=
signature_date
signature_name
,
signature_date
=
self
.
get_last_page_signature
(
page_num
=
'6'
,
top
=
'保证人1'
,
bottom
=
'保证人2'
)
self
.
init_result
[
'page_7'
][
'保证人1签字'
][
'签字'
]
=
signature_name
self
.
init_result
[
'page_7'
][
'保证人1签字'
][
'日期'
]
=
signature_date
signature_name
,
signature_date
=
self
.
get_last_page_signature
(
page_num
=
'6'
,
top
=
'保证人2'
,
bottom
=
'在本人面前亲笔签署本合同'
)
self
.
init_result
[
'page_7'
][
'保证人2签字'
][
'签字'
]
=
signature_name
self
.
init_result
[
'page_7'
][
'保证人2签字'
][
'日期'
]
=
signature_date
signature_name
,
signature_date
=
self
.
get_last_page_signature
(
page_num
=
'6'
,
top
=
'在本人面前亲笔签署本合同'
,
bottom
=
'以下无正文'
)
# print(signature_name, signature_date)
self
.
init_result
[
'page_7'
][
'见证人签字'
][
'签字'
]
=
signature_name
self
.
init_result
[
'page_7'
][
'见证人签字'
][
'日期'
]
=
signature_date
# 重新定制输出
new_results
=
{
"is_asp"
:
self
.
is_asp
,
...
...
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