fef93cd0 by 王聪

vechie ocr update

1 parent 612221a4
......@@ -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,17 +217,23 @@ 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 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', [])
words_result = ocr_res.get('words_result', {})
registration_bar = words_result.get('registration_bar', [])
for registration in registration_bar:
if registration.get('register_type', '') == '抵押登记':
......@@ -236,11 +243,10 @@ class PosHandler:
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', [])
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
......
......@@ -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_process1(img_file)
de_mortgage_info.update(info)
request_pass = True
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!