fix dda
Showing
1 changed file
with
20 additions
and
6 deletions
... | @@ -79,15 +79,29 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -79,15 +79,29 @@ class Command(BaseCommand, LoggerMixin): |
79 | 79 | ||
80 | def license1_process(self, ocr_data, all_res, classify): | 80 | def license1_process(self, ocr_data, all_res, classify): |
81 | # 类别:'0'身份证, '1'居住证 | 81 | # 类别:'0'身份证, '1'居住证 |
82 | license_data = ocr_data.get('data', []) | 82 | license_data = ocr_data.get('data') |
83 | if not license_data: | 83 | if not license_data: |
84 | return | 84 | return |
85 | if isinstance(license_data, dict): | ||
86 | license_data.pop('base64_img', '') | ||
85 | if classify == consts.IC_CLASSIFY: | 87 | if classify == consts.IC_CLASSIFY: |
86 | for id_card_dict in license_data: | 88 | id_card_dict = {} |
87 | try: | 89 | card_type = license_data.get('type', '') |
88 | id_card_dict.pop('base64_img') | 90 | is_ic = card_type.startswith('身份证') |
89 | except Exception as e: | 91 | is_info_side = card_type.endswith('信息面') |
90 | continue | 92 | id_card_dict['类别'] = '0' if is_ic else '1' |
93 | if is_ic: | ||
94 | field_map = consts.IC_MAP_0 if is_info_side else consts.IC_MAP_1 | ||
95 | else: | ||
96 | field_map = consts.RP_MAP_0 if is_info_side else consts.RP_MAP_1 | ||
97 | for write_field, search_field in field_map: | ||
98 | id_card_dict[write_field] = license_data.get('words_result', {}).get(search_field, {}).get('words', '') | ||
99 | if not is_info_side: | ||
100 | start_time = license_data.get('words_result', {}).get('签发日期', {}).get('words', '') | ||
101 | end_time = license_data.get('words_result', {}).get('失效日期', {}).get('words', '') | ||
102 | id_card_dict['有效期限'] = '{0}-{1}'.format(start_time, end_time) | ||
103 | all_res.setdefault(classify, []).append(id_card_dict) | ||
104 | else: | ||
91 | all_res.setdefault(classify, []).extend(license_data) | 105 | all_res.setdefault(classify, []).extend(license_data) |
92 | 106 | ||
93 | def license2_process(self, ocr_data, all_res, classify, img_path): | 107 | def license2_process(self, ocr_data, all_res, classify, img_path): | ... | ... |
-
Please register or sign in to post a comment