fix merge
Showing
3 changed files
with
215 additions
and
15 deletions
... | @@ -1568,6 +1568,12 @@ BC_FIELD_ORDER_2 = (('BankName', '发卡行名称'), | ... | @@ -1568,6 +1568,12 @@ BC_FIELD_ORDER_2 = (('BankName', '发卡行名称'), |
1568 | 1568 | ||
1569 | IMG_PATH_KEY = 'uniq_img_path_key' | 1569 | IMG_PATH_KEY = 'uniq_img_path_key' |
1570 | IMG_PATH_KEY_2 = 'uniq_img_path_key_2' | 1570 | IMG_PATH_KEY_2 = 'uniq_img_path_key_2' |
1571 | SECTION_IMG_PATH_KEY = 'uniq_section_img_path_key' | ||
1572 | ALL_POSITION_KEY = 'uniq_all_position_key' | ||
1573 | POSITION_KEY = 'uniq_position_key' | ||
1574 | ANGLE_KEY = 'uniq_angle_key' | ||
1575 | FIELD_POSITION_KEY = 'position' | ||
1576 | FIELD_QUAD_KEY = 'quad' | ||
1571 | 1577 | ||
1572 | INFO_SOURCE = ['POS', 'CMS'] | 1578 | INFO_SOURCE = ['POS', 'CMS'] |
1573 | 1579 | ... | ... |
... | @@ -378,7 +378,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -378,7 +378,7 @@ class Command(BaseCommand, LoggerMixin): |
378 | license_summary.setdefault(classify, []).extend(license_data) | 378 | license_summary.setdefault(classify, []).extend(license_data) |
379 | res_list.append((pno, ino, part_idx, consts.RES_SUCCESS)) | 379 | res_list.append((pno, ino, part_idx, consts.RES_SUCCESS)) |
380 | 380 | ||
381 | def license2_process(self, ocr_res_2, license_summary, pid, classify, res_list, pno, ino, part_idx, img_path, do_dda, dda_id_bc_mapping): | 381 | def license2_process(self, ocr_res_2, license_summary, pid, classify, res_list, pno, ino, part_idx, img_path, do_dda, dda_id_bc_mapping, file_data): |
382 | if ocr_res_2.get('ErrorCode') in consts.SUCCESS_CODE_SET: | 382 | if ocr_res_2.get('ErrorCode') in consts.SUCCESS_CODE_SET: |
383 | res_list.append((pno, ino, part_idx, consts.RES_SUCCESS)) | 383 | res_list.append((pno, ino, part_idx, consts.RES_SUCCESS)) |
384 | if pid == consts.BC_PID: | 384 | if pid == consts.BC_PID: |
... | @@ -394,12 +394,51 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -394,12 +394,51 @@ class Command(BaseCommand, LoggerMixin): |
394 | dda_id_bc_mapping.setdefault(consts.BC_FIELD, []).append((bc_no, img_path)) | 394 | dda_id_bc_mapping.setdefault(consts.BC_FIELD, []).append((bc_no, img_path)) |
395 | else: | 395 | else: |
396 | # 营业执照等 | 396 | # 营业执照等 |
397 | for result_dict in ocr_res_2.get('ResultList', []): | 397 | pre, suf = os.path.splitext(img_path) |
398 | src_section_img_path = img_path if file_data is None else '{0}_{1}{2}'.format(pre, part_idx, suf) | ||
399 | |||
400 | is_save = False | ||
401 | for res_idx, result_dict in enumerate(ocr_res_2.get('ResultList', [])): | ||
402 | image_data = result_dict.get('image_data', '') | ||
403 | if len(image_data) > 0: | ||
404 | position = {} | ||
405 | angle = 0 | ||
406 | section_img_path = '{0}_{1}_{2}{3}'.format(pre, part_idx, res_idx, suf) | ||
407 | try: | ||
408 | with open(section_img_path, "wb") as fh: | ||
409 | fh.write(base64.b64decode(image_data.encode())) | ||
410 | except Exception as e: | ||
411 | self.online_log.warn( | ||
412 | '{0} [section img save failed] [img_path={1}]' | ||
413 | ' [part_idx={2}] [res_idx={3}]'.format(self.log_base, img_path, part_idx, res_idx)) | ||
414 | else: | ||
415 | is_save = True | ||
416 | section_img_path = src_section_img_path | ||
417 | position = result_dict.get('position', {}) | ||
418 | angle = result_dict.get('angle', 0) | ||
398 | res_dict = {} | 419 | res_dict = {} |
420 | position_dict = {} | ||
399 | for field_dict in result_dict.get('FieldList', []): | 421 | for field_dict in result_dict.get('FieldList', []): |
400 | res_dict[field_dict.get('chn_key', '')] = field_dict.get('value', '') | 422 | res_dict[field_dict.get('chn_key', '')] = field_dict.get('value', '') |
423 | position_dict[field_dict.get('chn_key', '')] = { | ||
424 | consts.FIELD_POSITION_KEY: field_dict.get('position', {}), | ||
425 | consts.FIELD_QUAD_KEY: field_dict.get('quad', []), | ||
426 | } | ||
427 | position_dict[consts.POSITION_KEY] = position | ||
428 | position_dict[consts.ANGLE_KEY] = angle | ||
401 | res_dict[consts.IMG_PATH_KEY] = img_path | 429 | res_dict[consts.IMG_PATH_KEY] = img_path |
430 | res_dict[consts.SECTION_IMG_PATH_KEY] = section_img_path | ||
431 | res_dict[consts.ALL_POSITION_KEY] = position_dict | ||
402 | license_summary.setdefault(classify, []).append(res_dict) | 432 | license_summary.setdefault(classify, []).append(res_dict) |
433 | |||
434 | if is_save and file_data is not None: | ||
435 | try: | ||
436 | with open(src_section_img_path, "wb") as fh: | ||
437 | fh.write(base64.b64decode(file_data.encode())) | ||
438 | except Exception as e: | ||
439 | self.online_log.warn( | ||
440 | '{0} [section img save failed] [img_path={1}]' | ||
441 | ' [part_idx={2}]'.format(self.log_base, img_path, part_idx)) | ||
403 | else: | 442 | else: |
404 | res_list.append((pno, ino, part_idx, consts.RES_FAILED_2)) | 443 | res_list.append((pno, ino, part_idx, consts.RES_FAILED_2)) |
405 | 444 | ||
... | @@ -978,9 +1017,10 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -978,9 +1017,10 @@ class Command(BaseCommand, LoggerMixin): |
978 | card_name_res.get('data', {}).get('is_exists_name') == 0: | 1017 | card_name_res.get('data', {}).get('is_exists_name') == 0: |
979 | name = '无' | 1018 | name = '无' |
980 | ocr_2_res['Name'] = name | 1019 | ocr_2_res['Name'] = name |
1020 | |||
981 | self.license2_process(ocr_2_res, license_summary, pid, classify, | 1021 | self.license2_process(ocr_2_res, license_summary, pid, classify, |
982 | res_list, pno, ino, part_idx, img_path, | 1022 | res_list, pno, ino, part_idx, img_path, |
983 | do_dda, dda_id_bc_mapping) | 1023 | do_dda, dda_id_bc_mapping, file_data=ocr_data.get('section_img')) |
984 | break | 1024 | break |
985 | else: | 1025 | else: |
986 | res_list.append((pno, ino, part_idx, consts.RES_FAILED_2)) | 1026 | res_list.append((pno, ino, part_idx, consts.RES_FAILED_2)) | ... | ... |
1 | import json | 1 | import json |
2 | import os | ||
3 | import cv2 | ||
2 | import time | 4 | import time |
3 | import logging | 5 | import logging |
4 | import traceback | 6 | import traceback |
7 | import numpy as np | ||
5 | from datetime import datetime, timedelta | 8 | from datetime import datetime, timedelta |
6 | from collections import OrderedDict | 9 | from collections import OrderedDict |
7 | from . import app | 10 | from . import app |
... | @@ -40,6 +43,79 @@ empty_error_type = 1000 | ... | @@ -40,6 +43,79 @@ empty_error_type = 1000 |
40 | des_key = conf.CMS_DES_KEY | 43 | des_key = conf.CMS_DES_KEY |
41 | 44 | ||
42 | 45 | ||
46 | def rotate_bound(image, angle): | ||
47 | # grab the dimensions of the image and then determine the | ||
48 | # center | ||
49 | (h, w) = image.shape[:2] | ||
50 | (cX, cY) = (w // 2, h // 2) | ||
51 | |||
52 | # grab the rotation matrix (applying the negative of the | ||
53 | # angle to rotate clockwise), then grab the sine and cosine | ||
54 | # (i.e., the rotation components of the matrix) | ||
55 | M = cv2.getRotationMatrix2D((cX, cY), angle, 1.0) | ||
56 | cos = np.abs(M[0, 0]) | ||
57 | sin = np.abs(M[0, 1]) | ||
58 | |||
59 | # compute the new bounding dimensions of the image | ||
60 | nW = int((h * sin) + (w * cos)) | ||
61 | nH = int((h * cos) + (w * sin)) | ||
62 | |||
63 | # adjust the rotation matrix to take into account translation | ||
64 | M[0, 2] += (nW / 2) - cX | ||
65 | M[1, 2] += (nH / 2) - cY | ||
66 | |||
67 | # perform the actual rotation and return the image | ||
68 | return cv2.warpAffine(image, M, (nW, nH)) | ||
69 | |||
70 | |||
71 | def build_coordinates(section_position_dict): | ||
72 | if isinstance(section_position_dict, dict): | ||
73 | h_min = section_position_dict.get('top', 0) | ||
74 | w_min = section_position_dict.get('left', 0) | ||
75 | h_max = h_min + section_position_dict.get('height', 0) | ||
76 | w_max = w_min + section_position_dict.get('width', 0) | ||
77 | if h_max > h_min and w_max > w_min: | ||
78 | return True, (h_min, h_max, w_min, w_max) | ||
79 | else: | ||
80 | return False, () | ||
81 | return False, () | ||
82 | |||
83 | |||
84 | def field_build_coordinates(field_position_info): | ||
85 | field_position_dict = field_position_info.get(consts.FIELD_POSITION_KEY, {}) | ||
86 | field_quad_list = field_position_info.get(consts.FIELD_QUAD_KEY, []) | ||
87 | if isinstance(field_quad_list, list) and len(field_quad_list) == 8: | ||
88 | w_list = [field_quad_list[0], field_quad_list[2], field_quad_list[4], field_quad_list[6]] | ||
89 | h_list = [field_quad_list[1], field_quad_list[3], field_quad_list[5], field_quad_list[7]] | ||
90 | h_min = min(h_list) | ||
91 | h_max = max(h_list) | ||
92 | w_min = min(w_list) | ||
93 | w_max = max(w_list) | ||
94 | if h_max > h_min and w_max > w_min: | ||
95 | return True, (h_min, h_max, w_min, w_max) | ||
96 | if isinstance(field_position_dict, dict): | ||
97 | h_min = field_position_dict.get('top', 0) | ||
98 | w_min = field_position_dict.get('left', 0) | ||
99 | h_max = h_min + field_position_dict.get('height', 0) | ||
100 | w_max = w_min + field_position_dict.get('width', 0) | ||
101 | if h_max > h_min and w_max > w_min: | ||
102 | return True, (h_min, h_max, w_min, w_max) | ||
103 | else: | ||
104 | return False, () | ||
105 | return False, () | ||
106 | |||
107 | |||
108 | def img_process(section_img_path, section_position, section_angle): | ||
109 | image = cv2.imread(section_img_path) | ||
110 | is_valid, coord_tuple = build_coordinates(section_position) | ||
111 | if is_valid: | ||
112 | image = image[coord_tuple[0]:coord_tuple[1], coord_tuple[2]:coord_tuple[3], :] | ||
113 | if isinstance(section_angle, int) or isinstance(section_angle, float): | ||
114 | if section_angle != 0: | ||
115 | return rotate_bound(image, section_angle) | ||
116 | return image | ||
117 | |||
118 | |||
43 | # class FakePOS: | 119 | # class FakePOS: |
44 | # | 120 | # |
45 | # def __init__(self, | 121 | # def __init__(self, |
... | @@ -289,6 +365,8 @@ def ca_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -289,6 +365,8 @@ def ca_compare_license(license_en, ocr_res_dict, field_list): |
289 | 365 | ||
290 | is_find = False | 366 | is_find = False |
291 | result_field_list = [] | 367 | result_field_list = [] |
368 | section_img_info = dict() | ||
369 | field_img_path_dict = dict() | ||
292 | ocr_res_str = ocr_res_dict.get(ocr_field) | 370 | ocr_res_str = ocr_res_dict.get(ocr_field) |
293 | if ocr_res_str is not None: | 371 | if ocr_res_str is not None: |
294 | ocr_res_list = json.loads(ocr_res_str) | 372 | ocr_res_list = json.loads(ocr_res_str) |
... | @@ -323,6 +401,8 @@ def ca_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -323,6 +401,8 @@ def ca_compare_license(license_en, ocr_res_dict, field_list): |
323 | break | 401 | break |
324 | 402 | ||
325 | is_find = True | 403 | is_find = True |
404 | section_img_info[consts.SECTION_IMG_PATH_KEY] = ocr_res_list[res_idx].get(consts.SECTION_IMG_PATH_KEY, '') | ||
405 | section_img_info[consts.ALL_POSITION_KEY] = ocr_res_list[res_idx].get(consts.ALL_POSITION_KEY, {}) | ||
326 | 406 | ||
327 | # 过期期限特殊处理 | 407 | # 过期期限特殊处理 |
328 | if special_expiry_date and name == 'idExpiryDate' and result == consts.RESULT_N: | 408 | if special_expiry_date and name == 'idExpiryDate' and result == consts.RESULT_N: |
... | @@ -347,7 +427,42 @@ def ca_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -347,7 +427,42 @@ def ca_compare_license(license_en, ocr_res_dict, field_list): |
347 | for name, value in field_list: | 427 | for name, value in field_list: |
348 | result_field_list.append((name, value, consts.RESULT_N, empty_str, empty_str, ErrorType.NF.value)) | 428 | result_field_list.append((name, value, consts.RESULT_N, empty_str, empty_str, ErrorType.NF.value)) |
349 | 429 | ||
350 | return result_field_list | 430 | if is_find: |
431 | section_img_path = section_img_info.get(consts.SECTION_IMG_PATH_KEY, '') | ||
432 | if os.path.exists(section_img_path): | ||
433 | failed_field = [] | ||
434 | base_img_path = empty_str | ||
435 | for name, _, result, _, img_path, _ in result_field_list: | ||
436 | if result == consts.RESULT_N: | ||
437 | failed_field.append(name) | ||
438 | if base_img_path == empty_str: | ||
439 | base_img_path = img_path | ||
440 | if len(failed_field) > 0: | ||
441 | info = section_img_info.get(consts.ALL_POSITION_KEY, {}) | ||
442 | section_position = info.get(consts.POSITION_KEY, {}) | ||
443 | section_angle = info.get(consts.ANGLE_KEY, 0) | ||
444 | try: | ||
445 | last_img = img_process(section_img_path, section_position, section_angle) | ||
446 | except Exception as e: | ||
447 | for field in failed_field: | ||
448 | field_img_path_dict[field] = base_img_path | ||
449 | else: | ||
450 | pre, suf = os.path.splitext(section_img_path) | ||
451 | for field in failed_field: | ||
452 | try: | ||
453 | res_field = compare_logic[field][0] | ||
454 | is_valid, coord_tuple = field_build_coordinates(info.get(res_field, {})) | ||
455 | if is_valid: | ||
456 | save_path = '{0}_{1}{2}'.format(pre, field, suf) | ||
457 | field_img = last_img[coord_tuple[0]:coord_tuple[1], coord_tuple[2]:coord_tuple[3], :] | ||
458 | cv2.imwrite(save_path, field_img) | ||
459 | field_img_path_dict[field] = save_path | ||
460 | else: | ||
461 | field_img_path_dict[field] = base_img_path | ||
462 | except Exception as e: | ||
463 | field_img_path_dict[field] = base_img_path | ||
464 | |||
465 | return result_field_list, field_img_path_dict | ||
351 | 466 | ||
352 | 467 | ||
353 | def ca_compare_process(compare_info, ocr_res_dict): | 468 | def ca_compare_process(compare_info, ocr_res_dict): |
... | @@ -363,7 +478,7 @@ def ca_compare_process(compare_info, ocr_res_dict): | ... | @@ -363,7 +478,7 @@ def ca_compare_process(compare_info, ocr_res_dict): |
363 | for idx, license_list in info_value.items(): | 478 | for idx, license_list in info_value.items(): |
364 | for license_dict in license_list: | 479 | for license_dict in license_list: |
365 | for license_en, field_list in license_dict.items(): | 480 | for license_en, field_list in license_dict.items(): |
366 | result_field_list = ca_compare_license(license_en, ocr_res_dict, field_list) | 481 | result_field_list, field_img_path_dict = ca_compare_license(license_en, ocr_res_dict, field_list) |
367 | for name, value, result, ocr_str, img_path, error_type in result_field_list: | 482 | for name, value, result, ocr_str, img_path, error_type in result_field_list: |
368 | total_fields += 1 | 483 | total_fields += 1 |
369 | if result == consts.RESULT_N: | 484 | if result == consts.RESULT_N: |
... | @@ -377,14 +492,14 @@ def ca_compare_process(compare_info, ocr_res_dict): | ... | @@ -377,14 +492,14 @@ def ca_compare_process(compare_info, ocr_res_dict): |
377 | consts.HEAD_LIST[4]: value, | 492 | consts.HEAD_LIST[4]: value, |
378 | consts.HEAD_LIST[5]: ocr_str, | 493 | consts.HEAD_LIST[5]: ocr_str, |
379 | consts.HEAD_LIST[6]: result, | 494 | consts.HEAD_LIST[6]: result, |
380 | consts.HEAD_LIST[7]: empty_str, | 495 | consts.HEAD_LIST[7]: field_img_path_dict.get(name, empty_str), |
381 | consts.HEAD_LIST[8]: img_path, | 496 | consts.HEAD_LIST[8]: img_path, |
382 | consts.HEAD_LIST[9]: error_type, | 497 | consts.HEAD_LIST[9]: error_type, |
383 | } | 498 | } |
384 | ) | 499 | ) |
385 | else: | 500 | else: |
386 | for license_en, field_list in info_value.items(): | 501 | for license_en, field_list in info_value.items(): |
387 | result_field_list = ca_compare_license(license_en, ocr_res_dict, field_list) | 502 | result_field_list, field_img_path_dict = ca_compare_license(license_en, ocr_res_dict, field_list) |
388 | for name, value, result, ocr_str, img_path, error_type in result_field_list: | 503 | for name, value, result, ocr_str, img_path, error_type in result_field_list: |
389 | total_fields += 1 | 504 | total_fields += 1 |
390 | if result == consts.RESULT_N: | 505 | if result == consts.RESULT_N: |
... | @@ -398,7 +513,7 @@ def ca_compare_process(compare_info, ocr_res_dict): | ... | @@ -398,7 +513,7 @@ def ca_compare_process(compare_info, ocr_res_dict): |
398 | consts.HEAD_LIST[4]: value, | 513 | consts.HEAD_LIST[4]: value, |
399 | consts.HEAD_LIST[5]: ocr_str, | 514 | consts.HEAD_LIST[5]: ocr_str, |
400 | consts.HEAD_LIST[6]: result, | 515 | consts.HEAD_LIST[6]: result, |
401 | consts.HEAD_LIST[7]: empty_str, | 516 | consts.HEAD_LIST[7]: field_img_path_dict.get(name, empty_str), |
402 | consts.HEAD_LIST[8]: img_path, | 517 | consts.HEAD_LIST[8]: img_path, |
403 | consts.HEAD_LIST[9]: error_type, | 518 | consts.HEAD_LIST[9]: error_type, |
404 | } | 519 | } |
... | @@ -1263,6 +1378,8 @@ def se_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -1263,6 +1378,8 @@ def se_compare_license(license_en, ocr_res_dict, field_list): |
1263 | is_find = False | 1378 | is_find = False |
1264 | no_ocr_result = False | 1379 | no_ocr_result = False |
1265 | result_field_list = [] | 1380 | result_field_list = [] |
1381 | section_img_info = dict() | ||
1382 | field_img_path_dict = dict() | ||
1266 | ocr_res_str = ocr_res_dict.get(ocr_field) | 1383 | ocr_res_str = ocr_res_dict.get(ocr_field) |
1267 | if ocr_res_str is not None: | 1384 | if ocr_res_str is not None: |
1268 | ocr_res_list = json.loads(ocr_res_str) | 1385 | ocr_res_list = json.loads(ocr_res_str) |
... | @@ -1294,6 +1411,8 @@ def se_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -1294,6 +1411,8 @@ def se_compare_license(license_en, ocr_res_dict, field_list): |
1294 | break | 1411 | break |
1295 | 1412 | ||
1296 | is_find = True | 1413 | is_find = True |
1414 | section_img_info[consts.SECTION_IMG_PATH_KEY] = ocr_res_list[res_idx].get(consts.SECTION_IMG_PATH_KEY, '') | ||
1415 | section_img_info[consts.ALL_POSITION_KEY] = ocr_res_list[res_idx].get(consts.ALL_POSITION_KEY, {}) | ||
1297 | 1416 | ||
1298 | # 过期期限特殊处理 | 1417 | # 过期期限特殊处理 |
1299 | if special_expiry_date and name == 'idExpiryDate' and result == consts.RESULT_N: | 1418 | if special_expiry_date and name == 'idExpiryDate' and result == consts.RESULT_N: |
... | @@ -1314,7 +1433,42 @@ def se_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -1314,7 +1433,42 @@ def se_compare_license(license_en, ocr_res_dict, field_list): |
1314 | for name, value in field_list: | 1433 | for name, value in field_list: |
1315 | result_field_list.append((name, value, consts.RESULT_N, empty_str, empty_str, ErrorType.NF.value)) | 1434 | result_field_list.append((name, value, consts.RESULT_N, empty_str, empty_str, ErrorType.NF.value)) |
1316 | 1435 | ||
1317 | return result_field_list, no_ocr_result | 1436 | if is_find: |
1437 | section_img_path = section_img_info.get(consts.SECTION_IMG_PATH_KEY, '') | ||
1438 | if os.path.exists(section_img_path): | ||
1439 | failed_field = [] | ||
1440 | base_img_path = empty_str | ||
1441 | for name, _, result, _, img_path, _ in result_field_list: | ||
1442 | if result == consts.RESULT_N: | ||
1443 | failed_field.append(name) | ||
1444 | if base_img_path == empty_str: | ||
1445 | base_img_path = img_path | ||
1446 | if len(failed_field) > 0: | ||
1447 | info = section_img_info.get(consts.ALL_POSITION_KEY, {}) | ||
1448 | section_position = info.get(consts.POSITION_KEY, {}) | ||
1449 | section_angle = info.get(consts.ANGLE_KEY, 0) | ||
1450 | try: | ||
1451 | last_img = img_process(section_img_path, section_position, section_angle) | ||
1452 | except Exception as e: | ||
1453 | for field in failed_field: | ||
1454 | field_img_path_dict[field] = base_img_path | ||
1455 | else: | ||
1456 | pre, suf = os.path.splitext(section_img_path) | ||
1457 | for field in failed_field: | ||
1458 | try: | ||
1459 | res_field = compare_logic[field][0] | ||
1460 | is_valid, coord_tuple = field_build_coordinates(info.get(res_field, {})) | ||
1461 | if is_valid: | ||
1462 | save_path = '{0}_{1}{2}'.format(pre, field, suf) | ||
1463 | field_img = last_img[coord_tuple[0]:coord_tuple[1], coord_tuple[2]:coord_tuple[3], :] | ||
1464 | cv2.imwrite(save_path, field_img) | ||
1465 | field_img_path_dict[field] = save_path | ||
1466 | else: | ||
1467 | field_img_path_dict[field] = base_img_path | ||
1468 | except Exception as e: | ||
1469 | field_img_path_dict[field] = base_img_path | ||
1470 | |||
1471 | return result_field_list, no_ocr_result, field_img_path_dict | ||
1318 | 1472 | ||
1319 | 1473 | ||
1320 | def se_mvc34_compare(license_en, ocr_res_dict, field_list): | 1474 | def se_mvc34_compare(license_en, ocr_res_dict, field_list): |
... | @@ -1380,7 +1534,7 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list): | ... | @@ -1380,7 +1534,7 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list): |
1380 | for name, value in field_list: | 1534 | for name, value in field_list: |
1381 | result_field_list.append((name, value, consts.RESULT_N, empty_str, empty_str, ErrorType.NF.value)) | 1535 | result_field_list.append((name, value, consts.RESULT_N, empty_str, empty_str, ErrorType.NF.value)) |
1382 | 1536 | ||
1383 | return result_field_list | 1537 | return result_field_list, dict() |
1384 | 1538 | ||
1385 | 1539 | ||
1386 | def se_compare_process(compare_info, ocr_res_dict): | 1540 | def se_compare_process(compare_info, ocr_res_dict): |
... | @@ -1406,7 +1560,7 @@ def se_compare_process(compare_info, ocr_res_dict): | ... | @@ -1406,7 +1560,7 @@ def se_compare_process(compare_info, ocr_res_dict): |
1406 | else: | 1560 | else: |
1407 | strip_list.append((a, b)) | 1561 | strip_list.append((a, b)) |
1408 | failure_field = [] | 1562 | failure_field = [] |
1409 | result_field_list, no_ocr_result = se_compare_license(license_en, ocr_res_dict, strip_list) | 1563 | result_field_list, no_ocr_result, field_img_path_dict = se_compare_license(license_en, ocr_res_dict, field_list) |
1410 | for name, value, result, ocr_str, img_path, error_type in result_field_list: | 1564 | for name, value, result, ocr_str, img_path, error_type in result_field_list: |
1411 | if license_en not in consts.SKIP_CARD or not no_ocr_result: | 1565 | if license_en not in consts.SKIP_CARD or not no_ocr_result: |
1412 | total_fields += 1 | 1566 | total_fields += 1 |
... | @@ -1423,7 +1577,7 @@ def se_compare_process(compare_info, ocr_res_dict): | ... | @@ -1423,7 +1577,7 @@ def se_compare_process(compare_info, ocr_res_dict): |
1423 | consts.HEAD_LIST[4]: value, | 1577 | consts.HEAD_LIST[4]: value, |
1424 | consts.HEAD_LIST[5]: ocr_str, | 1578 | consts.HEAD_LIST[5]: ocr_str, |
1425 | consts.HEAD_LIST[6]: result, | 1579 | consts.HEAD_LIST[6]: result, |
1426 | consts.HEAD_LIST[7]: empty_str, | 1580 | consts.HEAD_LIST[7]: field_img_path_dict.get(name, empty_str), |
1427 | consts.HEAD_LIST[8]: img_path, | 1581 | consts.HEAD_LIST[8]: img_path, |
1428 | consts.HEAD_LIST[9]: error_type, | 1582 | consts.HEAD_LIST[9]: error_type, |
1429 | } | 1583 | } |
... | @@ -1440,9 +1594,9 @@ def se_compare_process(compare_info, ocr_res_dict): | ... | @@ -1440,9 +1594,9 @@ def se_compare_process(compare_info, ocr_res_dict): |
1440 | strip_list.append((a, b)) | 1594 | strip_list.append((a, b)) |
1441 | failure_field = [] | 1595 | failure_field = [] |
1442 | if license_en == consts.MVC34_EN: | 1596 | if license_en == consts.MVC34_EN: |
1443 | result_field_list = se_mvc34_compare(license_en, ocr_res_dict, strip_list) | 1597 | result_field_list, field_img_path_dict = se_mvc34_compare(license_en, ocr_res_dict, field_list) |
1444 | else: | 1598 | else: |
1445 | result_field_list, _ = se_compare_license(license_en, ocr_res_dict, strip_list) | 1599 | result_field_list, _, field_img_path_dict = se_compare_license(license_en, ocr_res_dict, field_list) |
1446 | for name, value, result, ocr_str, img_path, error_type in result_field_list: | 1600 | for name, value, result, ocr_str, img_path, error_type in result_field_list: |
1447 | total_fields += 1 | 1601 | total_fields += 1 |
1448 | if result == consts.RESULT_N: | 1602 | if result == consts.RESULT_N: |
... | @@ -1458,7 +1612,7 @@ def se_compare_process(compare_info, ocr_res_dict): | ... | @@ -1458,7 +1612,7 @@ def se_compare_process(compare_info, ocr_res_dict): |
1458 | consts.HEAD_LIST[4]: value, | 1612 | consts.HEAD_LIST[4]: value, |
1459 | consts.HEAD_LIST[5]: ocr_str, | 1613 | consts.HEAD_LIST[5]: ocr_str, |
1460 | consts.HEAD_LIST[6]: result, | 1614 | consts.HEAD_LIST[6]: result, |
1461 | consts.HEAD_LIST[7]: empty_str, | 1615 | consts.HEAD_LIST[7]: field_img_path_dict.get(name, empty_str), |
1462 | consts.HEAD_LIST[8]: img_path, | 1616 | consts.HEAD_LIST[8]: img_path, |
1463 | consts.HEAD_LIST[9]: error_type, | 1617 | consts.HEAD_LIST[9]: error_type, |
1464 | } | 1618 | } | ... | ... |
-
Please register or sign in to post a comment