vechie ocr update
Showing
2 changed files
with
16 additions
and
10 deletions
| ... | @@ -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,17 +217,23 @@ class PosHandler: | ... | @@ -216,17 +217,23 @@ 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: |
| 227 | LoggerMixin.exception_log.error( | ||
| 228 | "[PosHandler de_mortgage_ocr_process1] request error, url: %s, response: %s", | ||
| 229 | url, response.text) | ||
| 230 | return result_obj | ||
| 231 | result = response.json() | ||
| 232 | data = result.get('data', []) | ||
| 233 | for item in data: | ||
| 234 | ocr_res = item.get('data', {}) | ||
| 228 | if ocr_res.get('page', '') == 'page_34': | 235 | if ocr_res.get('page', '') == 'page_34': |
| 229 | words_result = ocr_res.get('words_result', []) | 236 | words_result = ocr_res.get('words_result', {}) |
| 230 | registration_bar = words_result.get('registration_bar', []) | 237 | registration_bar = words_result.get('registration_bar', []) |
| 231 | for registration in registration_bar: | 238 | for registration in registration_bar: |
| 232 | if registration.get('register_type', '') == '抵押登记': | 239 | if registration.get('register_type', '') == '抵押登记': |
| ... | @@ -236,11 +243,10 @@ class PosHandler: | ... | @@ -236,11 +243,10 @@ class PosHandler: |
| 236 | register_info = registration.get('register_info', {}) | 243 | register_info = registration.get('register_info', {}) |
| 237 | result_obj['deMortgageDate'] = register_info.get('解除抵押日期', '') | 244 | result_obj['deMortgageDate'] = register_info.get('解除抵押日期', '') |
| 238 | elif ocr_res.get('page', '') == 'page_12': | 245 | elif ocr_res.get('page', '') == 'page_12': |
| 239 | words_result = ocr_res.get('words_result', []) | 246 | words_result = ocr_res.get('words_result', {}) |
| 240 | for _, word_result in words_result.items(): | 247 | for _, word_result in words_result.items(): |
| 241 | if word_result.get('chinese_key', '') == '1.机动车所有人/身份证名称/号码': | 248 | if word_result.get('chinese_key', '') == '1.机动车所有人/身份证名称/号码': |
| 242 | result_obj['customerName'] = word_result.get('words', '').split('/')[0] | 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 | ... | ... |
-
Please register or sign in to post a comment