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
0c6c7693
authored
2020-10-29 12:03:09 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add bank card name
1 parent
cfe2b64f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
3 deletions
src/apps/doc/consts.py
src/apps/doc/management/commands/doc_ocr_process.py
src/apps/doc/ocr/wb.py
src/apps/doc/consts.py
View file @
0c6c769
...
...
@@ -836,7 +836,8 @@ BC_PID = 4
# ('Date', '日期'))
BC_FIELD_ORDER
=
((
'BankName'
,
'发卡行名称'
),
(
'CardNum'
,
'银行卡号'
),
(
'CardType'
,
'银行卡类型'
),)
(
'CardType'
,
'银行卡类型'
),
(
'Name'
,
'持卡人姓名'
),)
SUCCESS_CODE_SET
=
{
'0'
,
0
}
...
...
src/apps/doc/management/commands/doc_ocr_process.py
View file @
0c6c769
...
...
@@ -34,6 +34,7 @@ class Command(BaseCommand, LoggerMixin):
# ocr相关
self
.
ocr_url_1
=
conf
.
OCR_URL_1
self
.
ocr_url_2
=
conf
.
OCR_URL_2
self
.
ocr_url_3
=
conf
.
BC_URL
# EDMS web_service_api
self
.
edms
=
EDMS
(
conf
.
EDMS_USER
,
conf
.
EDMS_PWD
)
# 优雅退出信号:15
...
...
@@ -198,6 +199,13 @@ class Command(BaseCommand, LoggerMixin):
if
response
.
status
==
200
:
return
await
response
.
json
()
@staticmethod
async
def
fetch_bc_name_result
(
url
,
json_data
):
async
with
aiohttp
.
ClientSession
(
connector
=
aiohttp
.
TCPConnector
(
ssl
=
False
))
as
session
:
async
with
session
.
post
(
url
,
data
=
json_data
)
as
response
:
if
response
.
status
==
200
:
return
await
response
.
json
()
async
def
img_2_ocr_2_wb
(
self
,
wb
,
img_path
,
bs_summary
,
unknown_summary
,
license_summary
,
skip_img
):
with
open
(
img_path
,
'rb'
)
as
f
:
base64_data
=
base64
.
b64encode
(
f
.
read
())
...
...
@@ -239,6 +247,13 @@ class Command(BaseCommand, LoggerMixin):
# 识别结果
self
.
cronjob_log
.
info
(
'{0} [ocr_2 result] [img={1}] [res={2}]'
.
format
(
self
.
log_base
,
img_path
,
ocr_res_2
))
if
classify
==
consts
.
BC_CLASSIFY
:
name
=
'有'
json_data_1
[
'card_res'
]
=
ocr_res_2
card_name_res
=
await
self
.
fetch_bc_name_result
(
self
.
ocr_url_3
,
json_data_1
)
if
card_name_res
.
get
(
'code'
)
==
1
and
card_name_res
.
get
(
'data'
,
{})
.
get
(
'is_exists_name'
)
==
0
:
name
=
'无'
ocr_res_2
[
'Name'
]
=
name
self
.
license2_process
(
ocr_res_2
,
license_summary
,
pid
,
classify
,
skip_img
,
img_path
)
else
:
# 流水处理
self
.
bs_process
(
wb
,
ocr_data
,
bs_summary
,
unknown_summary
,
img_path
,
classify
,
skip_img
)
...
...
src/apps/doc/ocr/wb.py
View file @
0c6c769
...
...
@@ -281,10 +281,14 @@ class BSWorkbook(Workbook):
# 4.逗号与句号处理
if
len
(
res_str
)
>=
4
:
period_idx
=
len
(
res_str
)
-
3
if
res_str
[
period_idx
]
==
'.'
and
res_str
[
period_idx
-
1
]
==
','
:
if
res_str
[
period_idx
]
==
'.'
and
res_str
[
period_idx
-
1
]
in
{
','
,
'.'
}:
# 364,.92 364..92
res_str
=
'{0}{1}'
.
format
(
res_str
[:
period_idx
-
1
],
res_str
[
period_idx
:])
elif
res_str
[
period_idx
]
==
','
:
res_str
=
'{0}.{1}'
.
format
(
res_str
[:
period_idx
],
res_str
[
period_idx
+
1
:])
if
res_str
[
period_idx
-
1
]
in
{
','
,
'.'
}:
# 364.,92 364,,92
pre_idx
=
period_idx
-
1
else
:
# 364,92
pre_idx
=
period_idx
res_str
=
'{0}.{1}'
.
format
(
res_str
[:
pre_idx
],
res_str
[
period_idx
+
1
:])
return
res_str
def
build_month_sheet
(
self
,
ms
,
card
,
month_mapping
,
is_reverse
,
statistics_header_info
,
max_column
):
...
...
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