add img path
Showing
3 changed files
with
25 additions
and
12 deletions
... | @@ -1448,4 +1448,6 @@ SE_SECOND_ID_FIELD_MAPPING = { | ... | @@ -1448,4 +1448,6 @@ SE_SECOND_ID_FIELD_MAPPING = { |
1448 | 1448 | ||
1449 | HEAD_LIST = ['Info', 'Index', 'License', 'Field', 'Input', 'OCR', 'Result', 'Position', 'Image', 'errorType'] | 1449 | HEAD_LIST = ['Info', 'Index', 'License', 'Field', 'Input', 'OCR', 'Result', 'Position', 'Image', 'errorType'] |
1450 | 1450 | ||
1451 | IMG_PATH_KEY = 'uniq_img_path_key' | ||
1452 | |||
1451 | 1453 | ... | ... |
... | @@ -221,10 +221,12 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -221,10 +221,12 @@ class Command(BaseCommand, LoggerMixin): |
221 | dda_ocr_result = {key: value.get('words', '') for key, value in license_data.get('result', {}).items()} | 221 | dda_ocr_result = {key: value.get('words', '') for key, value in license_data.get('result', {}).items()} |
222 | dda_ocr_result[consts.DDA_IMG_PATH] = img_path | 222 | dda_ocr_result[consts.DDA_IMG_PATH] = img_path |
223 | dda_ocr_result[consts.DDA_PRO] = pro | 223 | dda_ocr_result[consts.DDA_PRO] = pro |
224 | dda_ocr_result[consts.IMG_PATH_KEY] = img_path | ||
224 | license_summary.setdefault(classify, []).append(dda_ocr_result) | 225 | license_summary.setdefault(classify, []).append(dda_ocr_result) |
225 | 226 | ||
226 | elif classify == consts.MVC_CLASSIFY: # 车辆登记证 3/4页结果整合 | 227 | elif classify == consts.MVC_CLASSIFY: # 车辆登记证 3/4页结果整合 |
227 | for mvc_dict in license_data: | 228 | for mvc_dict in license_data: |
229 | mvc_dict[consts.IMG_PATH_KEY] = img_path | ||
228 | try: | 230 | try: |
229 | mvc_page = mvc_dict.pop('page') | 231 | mvc_page = mvc_dict.pop('page') |
230 | except Exception as e: | 232 | except Exception as e: |
... | @@ -242,6 +244,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -242,6 +244,7 @@ class Command(BaseCommand, LoggerMixin): |
242 | 244 | ||
243 | elif classify == consts.IC_CLASSIFY: # 身份证真伪 | 245 | elif classify == consts.IC_CLASSIFY: # 身份证真伪 |
244 | for id_card_dict in license_data: | 246 | for id_card_dict in license_data: |
247 | id_card_dict[consts.IMG_PATH_KEY] = img_path | ||
245 | try: | 248 | try: |
246 | base64_img = id_card_dict.pop('base64_img') | 249 | base64_img = id_card_dict.pop('base64_img') |
247 | except Exception as e: | 250 | except Exception as e: |
... | @@ -294,6 +297,8 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -294,6 +297,8 @@ class Command(BaseCommand, LoggerMixin): |
294 | dda_id_bc_mapping.setdefault(consts.IC_FIELD, []).append((ic_name, ic_id, img_path)) | 297 | dda_id_bc_mapping.setdefault(consts.IC_FIELD, []).append((ic_name, ic_id, img_path)) |
295 | license_summary.setdefault(classify, []).extend(license_data) | 298 | license_summary.setdefault(classify, []).extend(license_data) |
296 | else: | 299 | else: |
300 | for res_dict in license_data: | ||
301 | res_dict[consts.IMG_PATH_KEY] = img_path | ||
297 | license_summary.setdefault(classify, []).extend(license_data) | 302 | license_summary.setdefault(classify, []).extend(license_data) |
298 | res_list.append((pno, ino, part_idx, consts.RES_SUCCESS)) | 303 | res_list.append((pno, ino, part_idx, consts.RES_SUCCESS)) |
299 | 304 | ||
... | @@ -305,6 +310,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -305,6 +310,7 @@ class Command(BaseCommand, LoggerMixin): |
305 | # res_dict = {} | 310 | # res_dict = {} |
306 | # for en_key, chn_key in consts.BC_FIELD: | 311 | # for en_key, chn_key in consts.BC_FIELD: |
307 | # res_dict[chn_key] = ocr_res_2.get(en_key, '') | 312 | # res_dict[chn_key] = ocr_res_2.get(en_key, '') |
313 | ocr_res_2[consts.IMG_PATH_KEY] = img_path | ||
308 | license_summary.setdefault(classify, []).append(ocr_res_2) | 314 | license_summary.setdefault(classify, []).append(ocr_res_2) |
309 | if do_dda and isinstance(ocr_res_2.get(consts.BC_KEY_FIELD), str): | 315 | if do_dda and isinstance(ocr_res_2.get(consts.BC_KEY_FIELD), str): |
310 | bc_no = ocr_res_2[consts.BC_KEY_FIELD].strip() | 316 | bc_no = ocr_res_2[consts.BC_KEY_FIELD].strip() |
... | @@ -316,6 +322,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -316,6 +322,7 @@ class Command(BaseCommand, LoggerMixin): |
316 | res_dict = {} | 322 | res_dict = {} |
317 | for field_dict in result_dict.get('FieldList', []): | 323 | for field_dict in result_dict.get('FieldList', []): |
318 | res_dict[field_dict.get('chn_key', '')] = field_dict.get('value', '') | 324 | res_dict[field_dict.get('chn_key', '')] = field_dict.get('value', '') |
325 | res_dict[consts.IMG_PATH_KEY] = img_path | ||
319 | license_summary.setdefault(classify, []).append(res_dict) | 326 | license_summary.setdefault(classify, []).append(res_dict) |
320 | else: | 327 | else: |
321 | res_list.append((pno, ino, part_idx, consts.RES_FAILED_2)) | 328 | res_list.append((pno, ino, part_idx, consts.RES_FAILED_2)) |
... | @@ -922,8 +929,8 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -922,8 +929,8 @@ class Command(BaseCommand, LoggerMixin): |
922 | # self.bs_log.info('[task={0}] [bs_summary={1}]'.format(task_str, merged_bs_summary)) | 929 | # self.bs_log.info('[task={0}] [bs_summary={1}]'.format(task_str, merged_bs_summary)) |
923 | 930 | ||
924 | self.online_log.info('{0} [task={1}] [merged_bs_summary={2}] [license_summary={3}] ' | 931 | self.online_log.info('{0} [task={1}] [merged_bs_summary={2}] [license_summary={3}] ' |
925 | '[res_list={4}]'.format(self.log_base, task_str, merged_bs_summary, | 932 | '[res_list={4}]'.format(self.log_base, task_str, merged_bs_summary, |
926 | license_summary, res_list)) | 933 | license_summary, res_list)) |
927 | 934 | ||
928 | except Exception as e: | 935 | except Exception as e: |
929 | 936 | ||
... | @@ -1023,7 +1030,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -1023,7 +1030,7 @@ class Command(BaseCommand, LoggerMixin): |
1023 | license_list = license_summary.get(classify) | 1030 | license_list = license_summary.get(classify) |
1024 | if not license_list: | 1031 | if not license_list: |
1025 | continue | 1032 | continue |
1026 | if classify == consts.IC_CLASSIFY and ic_merge: | 1033 | if classify == consts.IC_CLASSIFY and ic_merge: # TODO 正反面合并时的img_path处理 |
1027 | license_list[0].update(license_list[1]) | 1034 | license_list[0].update(license_list[1]) |
1028 | license_list.pop(1) | 1035 | license_list.pop(1) |
1029 | elif classify == consts.RP_CLASSIFY and rp_merge: | 1036 | elif classify == consts.RP_CLASSIFY and rp_merge: | ... | ... |
... | @@ -671,12 +671,13 @@ def se_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -671,12 +671,13 @@ def se_compare_license(license_en, ocr_res_dict, field_list): |
671 | result = expiry_date_res | 671 | result = expiry_date_res |
672 | break | 672 | break |
673 | 673 | ||
674 | img_path = ocr_res_list[res_idx].get(consts.IMG_PATH_KEY, '') if result == consts.RESULT_N else empty_str | ||
674 | error_type = empty_str if result == consts.RESULT_Y else ErrorType.OCR.value | 675 | error_type = empty_str if result == consts.RESULT_Y else ErrorType.OCR.value |
675 | result_field_list.append((name, value, result, ocr_str, error_type)) | 676 | result_field_list.append((name, value, result, ocr_str, img_path, error_type)) |
676 | 677 | ||
677 | if not is_find: | 678 | if not is_find: |
678 | for name, value in field_list: | 679 | for name, value in field_list: |
679 | result_field_list.append((name, value, consts.RESULT_N, empty_str, ErrorType.NF.value)) | 680 | result_field_list.append((name, value, consts.RESULT_N, empty_str, empty_str, ErrorType.NF.value)) |
680 | 681 | ||
681 | return result_field_list | 682 | return result_field_list |
682 | 683 | ||
... | @@ -696,6 +697,7 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list): | ... | @@ -696,6 +697,7 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list): |
696 | first_res = None | 697 | first_res = None |
697 | for res_idx in range(length-1, -1, -1): | 698 | for res_idx in range(length-1, -1, -1): |
698 | if consts.TRANSFER_DATE in ocr_res_list[res_idx]: | 699 | if consts.TRANSFER_DATE in ocr_res_list[res_idx]: |
700 | img_path = ocr_res_list[res_idx].get(consts.IMG_PATH_KEY, '') | ||
699 | for idx, transfer_date in enumerate(ocr_res_list[res_idx].get(consts.TRANSFER_DATE, [])): | 701 | for idx, transfer_date in enumerate(ocr_res_list[res_idx].get(consts.TRANSFER_DATE, [])): |
700 | try: | 702 | try: |
701 | transfer_name = ocr_res_list[res_idx].get(consts.TRANSFER_NAME, [])[idx] | 703 | transfer_name = ocr_res_list[res_idx].get(consts.TRANSFER_NAME, [])[idx] |
... | @@ -708,7 +710,8 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list): | ... | @@ -708,7 +710,8 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list): |
708 | core_info = { | 710 | core_info = { |
709 | consts.TRANSFER_NAME: transfer_name, | 711 | consts.TRANSFER_NAME: transfer_name, |
710 | consts.TRANSFER_NUM: transfer_num, | 712 | consts.TRANSFER_NUM: transfer_num, |
711 | consts.TRANSFER_DATE: transfer_date | 713 | consts.TRANSFER_DATE: transfer_date, |
714 | consts.IMG_PATH_KEY: img_path, | ||
712 | } | 715 | } |
713 | page34_date_dict.setdefault(transfer_date, []).append(core_info) | 716 | page34_date_dict.setdefault(transfer_date, []).append(core_info) |
714 | if first_res is None: | 717 | if first_res is None: |
... | @@ -734,12 +737,13 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list): | ... | @@ -734,12 +737,13 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list): |
734 | ocr_str = empty_str | 737 | ocr_str = empty_str |
735 | else: | 738 | else: |
736 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) | 739 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) |
740 | img_path = ocr_res.get(consts.IMG_PATH_KEY, '') if result == consts.RESULT_N else empty_str | ||
737 | error_type = empty_str if result == consts.RESULT_Y else ErrorType.OCR.value | 741 | error_type = empty_str if result == consts.RESULT_Y else ErrorType.OCR.value |
738 | result_field_list.append((name, value, result, ocr_str, error_type)) | 742 | result_field_list.append((name, value, result, ocr_str, img_path, error_type)) |
739 | 743 | ||
740 | if not is_find: | 744 | if not is_find: |
741 | for name, value in field_list: | 745 | for name, value in field_list: |
742 | result_field_list.append((name, value, consts.RESULT_N, empty_str, ErrorType.NF.value)) | 746 | result_field_list.append((name, value, consts.RESULT_N, empty_str, empty_str, ErrorType.NF.value)) |
743 | 747 | ||
744 | return result_field_list | 748 | return result_field_list |
745 | 749 | ||
... | @@ -762,7 +766,7 @@ def se_compare_process(compare_info, ocr_res_dict): | ... | @@ -762,7 +766,7 @@ def se_compare_process(compare_info, ocr_res_dict): |
762 | for license_en, field_list in license_dict.items(): | 766 | for license_en, field_list in license_dict.items(): |
763 | failure_field = [] | 767 | failure_field = [] |
764 | result_field_list = se_compare_license(license_en, ocr_res_dict, field_list) | 768 | result_field_list = se_compare_license(license_en, ocr_res_dict, field_list) |
765 | for name, value, result, ocr_str, error_type in result_field_list: | 769 | for name, value, result, ocr_str, img_path, error_type in result_field_list: |
766 | total_fields += 1 | 770 | total_fields += 1 |
767 | if result == consts.RESULT_N: | 771 | if result == consts.RESULT_N: |
768 | failed_count += 1 | 772 | failed_count += 1 |
... | @@ -778,7 +782,7 @@ def se_compare_process(compare_info, ocr_res_dict): | ... | @@ -778,7 +782,7 @@ def se_compare_process(compare_info, ocr_res_dict): |
778 | 'OCR': ocr_str, | 782 | 'OCR': ocr_str, |
779 | 'Result': result, | 783 | 'Result': result, |
780 | 'Position': empty_str, | 784 | 'Position': empty_str, |
781 | 'Image': empty_str, | 785 | 'Image': img_path, |
782 | 'errorType': error_type, | 786 | 'errorType': error_type, |
783 | } | 787 | } |
784 | ) | 788 | ) |
... | @@ -790,7 +794,7 @@ def se_compare_process(compare_info, ocr_res_dict): | ... | @@ -790,7 +794,7 @@ def se_compare_process(compare_info, ocr_res_dict): |
790 | result_field_list = se_mvc34_compare(license_en, ocr_res_dict, field_list) | 794 | result_field_list = se_mvc34_compare(license_en, ocr_res_dict, field_list) |
791 | else: | 795 | else: |
792 | result_field_list = se_compare_license(license_en, ocr_res_dict, field_list) | 796 | result_field_list = se_compare_license(license_en, ocr_res_dict, field_list) |
793 | for name, value, result, ocr_str, error_type in result_field_list: | 797 | for name, value, result, ocr_str, img_path, error_type in result_field_list: |
794 | total_fields += 1 | 798 | total_fields += 1 |
795 | if result == consts.RESULT_N: | 799 | if result == consts.RESULT_N: |
796 | failed_count += 1 | 800 | failed_count += 1 |
... | @@ -806,7 +810,7 @@ def se_compare_process(compare_info, ocr_res_dict): | ... | @@ -806,7 +810,7 @@ def se_compare_process(compare_info, ocr_res_dict): |
806 | 'OCR': ocr_str, | 810 | 'OCR': ocr_str, |
807 | 'Result': result, | 811 | 'Result': result, |
808 | 'Position': empty_str, | 812 | 'Position': empty_str, |
809 | 'Image': empty_str, | 813 | 'Image': img_path, |
810 | 'errorType': error_type, | 814 | 'errorType': error_type, |
811 | } | 815 | } |
812 | ) | 816 | ) | ... | ... |
-
Please register or sign in to post a comment