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
39401151
authored
2022-11-14 16:13:59 +0800
by
王聪
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Delete test.py
1 parent
fef93cd0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
114 deletions
src/pos/test.py
src/pos/test.py
deleted
100644 → 0
View file @
fef93cd
import
json
import
requests
import
logging
import
base64
logger
=
logging
.
getLogger
()
def
de_mortgage_ocr_process
(
img_base64
):
result_obj
=
{
'customerName'
:
''
,
'application'
:
''
,
'deMortgageDate'
:
''
}
url
=
'http://file-classification.situdata.com/bs/all'
json_data
=
{
"file"
:
img_base64
,
"classify"
:
28
,
"version"
:
"green"
}
try
:
response
=
requests
.
post
(
url
,
json
=
json_data
)
response
.
encoding
=
'unicode_escape'
ocr_res
=
response
.
json
()
print
(
ocr_res
)
# ocr_res = ocr_res.decode('unicode_escape')
data
=
ocr_res
.
get
(
'data'
,
[])
for
classify_data
in
data
:
result_data
=
classify_data
.
get
(
'data'
,
{})
results
=
result_data
.
get
(
'results'
)
if
result_data
.
get
(
'page'
,
''
)
==
'VehicleRegArea'
:
if
results
.
get
(
'register_type'
,
-
1
)
==
1
:
info
=
results
.
get
(
'解除抵押日期'
,
{})
result_obj
[
'deMortgageDate'
]
=
info
.
get
(
'words'
,
''
)
elif
results
.
get
(
'register_type'
,
-
1
)
==
0
:
info
=
results
.
get
(
'抵押权人姓名/名称'
,
{})
result_obj
[
'application'
]
=
info
.
get
(
'words'
,
''
)
elif
result_data
.
get
(
'page'
,
''
)
==
'VehicleRCI'
:
print
(
'----------------------'
)
info
=
results
.
get
(
'1.机动车所有人/身份证名称/号码'
,
{})
result_obj
[
'customerName'
]
=
info
.
get
(
'words'
,
''
)
.
split
(
'/'
)[
0
]
except
Exception
as
e
:
logger
.
error
(
e
)
# LoggerMixin.running_log.error('[PosHandler de_mortgage_ocr_process] [error={0}]'.format(e.format_exc()))
result_obj
=
{
'customerName'
:
''
,
'application'
:
''
,
'deMortgageDate'
:
''
}
return
result_obj
de_mortgage_comments
=
{
'customerName'
:
(
'机动车所有人识别不一致'
,
),
'application'
:
(
'抵押权人姓名/名称识别不一致'
,
),
'deMortgageDate'
:
(
'解除抵押日期不一致'
,
)
}
def
view
(
args
):
img_files
=
args
.
get
(
'file_base64'
,
[])
customer_name
=
args
.
get
(
'customerName'
,
''
)
application
=
args
.
get
(
'application'
,
''
)
de_mortgage_date
=
args
.
get
(
'deMortgageDate'
)
fields_input
=
{
'customerName'
:
customer_name
,
'application'
:
application
,
'deMortgageDate'
:
de_mortgage_date
}
de_mortgage_info
=
{}
# 绿本必须分开ocr
for
img_file
in
img_files
:
info
=
de_mortgage_ocr_process
(
img_file
)
de_mortgage_info
.
update
(
info
)
request_pass
=
True
fields_result
=
[]
for
field_name
,
input_val
in
fields_input
.
items
():
field_result
=
{
"name"
:
field_name
,
"input"
:
input_val
,
"ocr"
:
de_mortgage_info
.
get
(
field_name
,
''
),
"field_is_pass"
:
False
,
"comments"
:
''
}
# result, _ = cp.common_compare(field_result['input'], field_result['ocr'])
# if result == cp.RESULT_Y:
# fields_result['field_is_pass'] = result
# else:
# request_pass = False
# fields_result['comments'] = de_mortgage_comments.get(field_name, '')
fields_result
.
append
(
field_result
)
result
=
{
"is_pass"
:
request_pass
,
"fields"
:
fields_result
}
print
(
result
)
if
__name__
==
'__main__'
:
# print(u'编号'.encode('ascii'))
# print(b"\u7f16\u53f7".decode('unicode_escape'))
img_base64
=
r'C:\Users\EDY\Desktop\1280X1280 (1).PNG'
# img_base64 = r'C:\Users\EDY\Desktop\1280X1280.PNG'
with
open
(
img_base64
,
'rb'
)
as
f
:
content
=
f
.
read
()
args
=
{
'file_base64'
:
[
str
(
base64
.
b64encode
(
content
),
'utf-8'
)]
}
view
(
args
)
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