55c99301 by 周伟奇

modify ocr_1 res to list

1 parent 50017fdb
...@@ -494,20 +494,29 @@ class Command(BaseCommand, LoggerMixin): ...@@ -494,20 +494,29 @@ class Command(BaseCommand, LoggerMixin):
494 for img_path, res in ocr_1_res.items(): 494 for img_path, res in ocr_1_res.items():
495 pno, ino = self.parse_img_path(img_path) 495 pno, ino = self.parse_img_path(img_path)
496 if res.get('code') == 1: 496 if res.get('code') == 1:
497 ocr_data = res.get('data', {}) 497 ocr_data_list = res.get('data', [])
498 if not isinstance(ocr_data_list, list):
499 res_list.append((pno, ino, consts.RES_FAILED_1))
500 self.cronjob_log.info('{0} [ocr_1 res error] [img={1}] [res={2}]'.format(
501 self.log_base, img_path, res))
502 else:
503 for part_idx, ocr_data in enumerate(ocr_data_list):
504 ino_part = '{0}-{1}'.format(ino, part_idx)
498 classify = ocr_data.get('classify') 505 classify = ocr_data.get('classify')
499 if classify is None: 506 if classify is None:
500 res_list.append((pno, ino, consts.RES_FAILED_1)) 507 res_list.append((pno, ino_part, consts.RES_FAILED_1))
501 self.cronjob_log.info('{0} [ocr_1 res error] [img={1}] [res={2}]'.format( 508 self.cronjob_log.info('{0} [ocr_1 res error] [img={1}] [res={2}]'.format(
502 self.log_base, img_path, res)) 509 self.log_base, img_path, res))
503 continue 510 continue
504 elif classify in consts.OTHER_CLASSIFY_SET: # 其他类 511 elif classify in consts.OTHER_CLASSIFY_SET: # 其他类
505 res_list.append((pno, ino, consts.RES_SUCCESS_OTHER)) 512 res_list.append((pno, ino_part, consts.RES_SUCCESS_OTHER))
506 continue 513 continue
507 elif classify in consts.LICENSE_CLASSIFY_SET_1: # 证件1 514 elif classify in consts.LICENSE_CLASSIFY_SET_1: # 证件1
508 self.license1_process(ocr_data, license_summary, classify, res_list, pno, ino) 515 self.license1_process(ocr_data, license_summary, classify, res_list, pno, ino_part)
509 elif classify in consts.LICENSE_CLASSIFY_SET_2: # 证件2 516 elif classify in consts.LICENSE_CLASSIFY_SET_2: # 证件2
510 pid, _, _, _, _, _ = consts.LICENSE_CLASSIFY_MAPPING.get(classify) 517 pid, _, _, _, _, _ = consts.LICENSE_CLASSIFY_MAPPING.get(classify)
518 file_data = ocr_data.get('section_img')
519 if file_data is None:
511 with open(img_path, 'rb') as f: 520 with open(img_path, 'rb') as f:
512 base64_data = base64.b64encode(f.read()) 521 base64_data = base64.b64encode(f.read())
513 # 获取解码后的base64值 522 # 获取解码后的base64值
...@@ -548,14 +557,14 @@ class Command(BaseCommand, LoggerMixin): ...@@ -548,14 +557,14 @@ class Command(BaseCommand, LoggerMixin):
548 card_name_res.get('data', {}).get('is_exists_name') == 0: 557 card_name_res.get('data', {}).get('is_exists_name') == 0:
549 name = '无' 558 name = '无'
550 ocr_2_res['Name'] = name 559 ocr_2_res['Name'] = name
551 self.license2_process(ocr_2_res, license_summary, pid, classify, res_list, pno, ino) 560 self.license2_process(ocr_2_res, license_summary, pid, classify, res_list, pno, ino_part)
552 break 561 break
553 else: 562 else:
554 res_list.append((pno, ino, consts.RES_FAILED_2)) 563 res_list.append((pno, ino_part, consts.RES_FAILED_2))
555 self.cronjob_log.warn( 564 self.cronjob_log.warn(
556 '{0} [ocr_2 failed] [img_path={1}]'.format(self.log_base, img_path)) 565 '{0} [ocr_2 failed] [img_path={1}]'.format(self.log_base, img_path))
557 else: # 流水处理 566 else: # 流水处理
558 self.bs_process(wb, ocr_data, bs_summary, unknown_summary, classify, res_list, pno, ino) 567 self.bs_process(wb, ocr_data, bs_summary, unknown_summary, classify, res_list, pno, ino_part)
559 else: 568 else:
560 res_list.append((pno, ino, consts.RES_FAILED_1)) 569 res_list.append((pno, ino, consts.RES_FAILED_1))
561 self.cronjob_log.info('{0} [ocr_1 res error] [img={1}] [res={2}]'.format( 570 self.cronjob_log.info('{0} [ocr_1 res error] [img={1}] [res={2}]'.format(
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!