fef93cd0 by 王聪

vechie ocr update

1 parent 612221a4
...@@ -6,6 +6,7 @@ from .models import HILDoc, AFCDoc, AFCSEOCRResult, AFCOCRResult, HILSEOCRResult ...@@ -6,6 +6,7 @@ from .models import HILDoc, AFCDoc, AFCSEOCRResult, AFCOCRResult, HILSEOCRResult
6 from . import consts 6 from . import consts
7 from prese.compare import pre_compare, get_empty_result 7 from prese.compare import pre_compare, get_empty_result
8 from common.mixins import LoggerMixin 8 from common.mixins import LoggerMixin
9 from settings import conf
9 10
10 11
11 class MPOSHandler: 12 class MPOSHandler:
...@@ -184,9 +185,9 @@ class PosHandler: ...@@ -184,9 +185,9 @@ class PosHandler:
184 'application': '', 185 'application': '',
185 'deMortgageDate': '' 186 'deMortgageDate': ''
186 } 187 }
187 url = 'http://file-classification.situdata.com/bs/all'
188 json_data = {"file": img_base64, "classify": consts.MVC_CLASSIFY, "version": "green"} 188 json_data = {"file": img_base64, "classify": consts.MVC_CLASSIFY, "version": "green"}
189 try: 189 try:
190 url = conf.OCR_URL_FOLDER
190 response = requests.post(url, json=json_data) 191 response = requests.post(url, json=json_data)
191 if response.status_code != 200: 192 if response.status_code != 200:
192 return result_obj 193 return result_obj
...@@ -216,31 +217,36 @@ class PosHandler: ...@@ -216,31 +217,36 @@ class PosHandler:
216 'application': '', 217 'application': '',
217 'deMortgageDate': '' 218 'deMortgageDate': ''
218 } 219 }
219 url = 'http://file-classification.situdata.com/bs/all' 220 url = conf.OCR_URL_FOLDER
220 json_data = {"file": img_base64, "classify": consts.MVC_CLASSIFY, "version": "green"} 221 json_data = {"file": img_base64, "classify": consts.MVC_CLASSIFY, "version": "green"}
221 try: 222 try:
222 response = requests.post(url, json=json_data) 223 response = requests.post(url, json=json_data)
223 if response.status_code != 200:
224 return result_obj
225 # unicode转中文 224 # unicode转中文
226 response.encoding = 'unicode_escape' 225 response.encoding = 'unicode_escape'
227 ocr_res = response.json() 226 if response.status_code != 200:
228 if ocr_res.get('page', '') == 'page_34': 227 LoggerMixin.exception_log.error(
229 words_result = ocr_res.get('words_result', []) 228 "[PosHandler de_mortgage_ocr_process1] request error, url: %s, response: %s",
230 registration_bar = words_result.get('registration_bar', []) 229 url, response.text)
231 for registration in registration_bar: 230 return result_obj
232 if registration.get('register_type', '') == '抵押登记': 231 result = response.json()
233 register_info = registration.get('register_info', {}) 232 data = result.get('data', [])
234 result_obj['application'] = register_info.get('抵押权人姓名/名称', '') 233 for item in data:
235 elif registration.get('register_type', '') == '解除抵押': 234 ocr_res = item.get('data', {})
236 register_info = registration.get('register_info', {}) 235 if ocr_res.get('page', '') == 'page_34':
237 result_obj['deMortgageDate'] = register_info.get('解除抵押日期', '') 236 words_result = ocr_res.get('words_result', {})
238 elif ocr_res.get('page', '') == 'page_12': 237 registration_bar = words_result.get('registration_bar', [])
239 words_result = ocr_res.get('words_result', []) 238 for registration in registration_bar:
240 for _, word_result in words_result.items(): 239 if registration.get('register_type', '') == '抵押登记':
241 if word_result.get('chinese_key', '') == '1.机动车所有人/身份证名称/号码': 240 register_info = registration.get('register_info', {})
242 result_obj['customerName'] = word_result.get('words', '').split('/')[0] 241 result_obj['application'] = register_info.get('抵押权人姓名/名称', '')
242 elif registration.get('register_type', '') == '解除抵押':
243 register_info = registration.get('register_info', {})
244 result_obj['deMortgageDate'] = register_info.get('解除抵押日期', '')
245 elif ocr_res.get('page', '') == 'page_12':
246 words_result = ocr_res.get('words_result', {})
247 for _, word_result in words_result.items():
248 if word_result.get('chinese_key', '') == '1.机动车所有人/身份证名称/号码':
249 result_obj['customerName'] = word_result.get('words', '').split('/')[0]
243 except Exception as e: 250 except Exception as e:
244 LoggerMixin.running_log.error("[PosHandler de_mortgage_ocr_process] error", exc_info=1) 251 LoggerMixin.exception_log.error("[PosHandler de_mortgage_ocr_process1] error", exc_info=1)
245 return result_obj 252 return result_obj
246
......
...@@ -88,7 +88,7 @@ class DeMortgageView(GenericView): ...@@ -88,7 +88,7 @@ class DeMortgageView(GenericView):
88 de_mortgage_info = {} 88 de_mortgage_info = {}
89 # 绿本必须分开ocr 89 # 绿本必须分开ocr
90 for img_file in img_files: 90 for img_file in img_files:
91 info = PosHandler.de_mortgage_ocr_process(img_file) 91 info = PosHandler.de_mortgage_ocr_process1(img_file)
92 de_mortgage_info.update(info) 92 de_mortgage_info.update(info)
93 93
94 request_pass = True 94 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!