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
fef93cd0
authored
2022-11-14 16:13:02 +0800
by
王聪
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
vechie ocr update
1 parent
612221a4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
23 deletions
src/apps/doc/mixins.py
src/pos/views.py
src/apps/doc/mixins.py
View file @
fef93cd
...
...
@@ -6,6 +6,7 @@ from .models import HILDoc, AFCDoc, AFCSEOCRResult, AFCOCRResult, HILSEOCRResult
from
.
import
consts
from
prese.compare
import
pre_compare
,
get_empty_result
from
common.mixins
import
LoggerMixin
from
settings
import
conf
class
MPOSHandler
:
...
...
@@ -184,9 +185,9 @@ class PosHandler:
'application'
:
''
,
'deMortgageDate'
:
''
}
url
=
'http://file-classification.situdata.com/bs/all'
json_data
=
{
"file"
:
img_base64
,
"classify"
:
consts
.
MVC_CLASSIFY
,
"version"
:
"green"
}
try
:
url
=
conf
.
OCR_URL_FOLDER
response
=
requests
.
post
(
url
,
json
=
json_data
)
if
response
.
status_code
!=
200
:
return
result_obj
...
...
@@ -216,31 +217,36 @@ class PosHandler:
'application'
:
''
,
'deMortgageDate'
:
''
}
url
=
'http://file-classification.situdata.com/bs/all'
url
=
conf
.
OCR_URL_FOLDER
json_data
=
{
"file"
:
img_base64
,
"classify"
:
consts
.
MVC_CLASSIFY
,
"version"
:
"green"
}
try
:
response
=
requests
.
post
(
url
,
json
=
json_data
)
if
response
.
status_code
!=
200
:
return
result_obj
# unicode转中文
response
.
encoding
=
'unicode_escape'
ocr_res
=
response
.
json
()
if
ocr_res
.
get
(
'page'
,
''
)
==
'page_34'
:
words_result
=
ocr_res
.
get
(
'words_result'
,
[])
registration_bar
=
words_result
.
get
(
'registration_bar'
,
[])
for
registration
in
registration_bar
:
if
registration
.
get
(
'register_type'
,
''
)
==
'抵押登记'
:
register_info
=
registration
.
get
(
'register_info'
,
{})
result_obj
[
'application'
]
=
register_info
.
get
(
'抵押权人姓名/名称'
,
''
)
elif
registration
.
get
(
'register_type'
,
''
)
==
'解除抵押'
:
register_info
=
registration
.
get
(
'register_info'
,
{})
result_obj
[
'deMortgageDate'
]
=
register_info
.
get
(
'解除抵押日期'
,
''
)
elif
ocr_res
.
get
(
'page'
,
''
)
==
'page_12'
:
words_result
=
ocr_res
.
get
(
'words_result'
,
[])
for
_
,
word_result
in
words_result
.
items
():
if
word_result
.
get
(
'chinese_key'
,
''
)
==
'1.机动车所有人/身份证名称/号码'
:
result_obj
[
'customerName'
]
=
word_result
.
get
(
'words'
,
''
)
.
split
(
'/'
)[
0
]
if
response
.
status_code
!=
200
:
LoggerMixin
.
exception_log
.
error
(
"[PosHandler de_mortgage_ocr_process1] request error, url:
%
s, response:
%
s"
,
url
,
response
.
text
)
return
result_obj
result
=
response
.
json
()
data
=
result
.
get
(
'data'
,
[])
for
item
in
data
:
ocr_res
=
item
.
get
(
'data'
,
{})
if
ocr_res
.
get
(
'page'
,
''
)
==
'page_34'
:
words_result
=
ocr_res
.
get
(
'words_result'
,
{})
registration_bar
=
words_result
.
get
(
'registration_bar'
,
[])
for
registration
in
registration_bar
:
if
registration
.
get
(
'register_type'
,
''
)
==
'抵押登记'
:
register_info
=
registration
.
get
(
'register_info'
,
{})
result_obj
[
'application'
]
=
register_info
.
get
(
'抵押权人姓名/名称'
,
''
)
elif
registration
.
get
(
'register_type'
,
''
)
==
'解除抵押'
:
register_info
=
registration
.
get
(
'register_info'
,
{})
result_obj
[
'deMortgageDate'
]
=
register_info
.
get
(
'解除抵押日期'
,
''
)
elif
ocr_res
.
get
(
'page'
,
''
)
==
'page_12'
:
words_result
=
ocr_res
.
get
(
'words_result'
,
{})
for
_
,
word_result
in
words_result
.
items
():
if
word_result
.
get
(
'chinese_key'
,
''
)
==
'1.机动车所有人/身份证名称/号码'
:
result_obj
[
'customerName'
]
=
word_result
.
get
(
'words'
,
''
)
.
split
(
'/'
)[
0
]
except
Exception
as
e
:
LoggerMixin
.
running_log
.
error
(
"[PosHandler de_mortgage_ocr_process
] error"
,
exc_info
=
1
)
LoggerMixin
.
exception_log
.
error
(
"[PosHandler de_mortgage_ocr_process1
] error"
,
exc_info
=
1
)
return
result_obj
...
...
src/pos/views.py
View file @
fef93cd
...
...
@@ -88,7 +88,7 @@ class DeMortgageView(GenericView):
de_mortgage_info
=
{}
# 绿本必须分开ocr
for
img_file
in
img_files
:
info
=
PosHandler
.
de_mortgage_ocr_process
(
img_file
)
info
=
PosHandler
.
de_mortgage_ocr_process
1
(
img_file
)
de_mortgage_info
.
update
(
info
)
request_pass
=
True
...
...
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