优化图片的存储,及时删除处理过程中产生的图片
This commit is contained in:
@@ -54,11 +54,11 @@ def find_boxes(content, layout, offset=0, length=None, improve=False, image_path
|
||||
if improve:
|
||||
# 再次识别,提高精度
|
||||
image = cv2.imread(image_path)
|
||||
img_name, img_ext = image_util.parse_save_path(image_path)
|
||||
img_name, img_ext = common_util.parse_save_path(image_path)
|
||||
# 截图时偏大一点
|
||||
capture_box = common_util.zoom_rectangle(box, 0.2)
|
||||
captured_image = image_util.capture(image, capture_box)
|
||||
captured_image_path = image_util.get_save_path(f'{img_name}.capture.{img_ext}')
|
||||
captured_image_path = common_util.get_processed_img_path(f'{img_name}.capture.{img_ext}')
|
||||
cv2.imwrite(captured_image_path, captured_image)
|
||||
captured_a4_img_path, offset_x, offset_y = image_util.expand_to_a4_size(captured_image_path)
|
||||
try:
|
||||
@@ -170,7 +170,7 @@ def handle_image_for_mask(split_result):
|
||||
def mask_photo(img_path, name, id_card_num, color=(255, 255, 255)):
|
||||
def _mask(ip, n, icn, c):
|
||||
i = cv2.imread(ip)
|
||||
img_name, img_ext = image_util.parse_save_path(ip)
|
||||
img_name, img_ext = common_util.parse_save_path(ip)
|
||||
do_mask = False
|
||||
split_results = image_util.split(ip)
|
||||
for split_result in split_results:
|
||||
@@ -188,7 +188,7 @@ def mask_photo(img_path, name, id_card_num, color=(255, 255, 255)):
|
||||
result[3] + y_offset,
|
||||
)
|
||||
cv2.rectangle(i, (int(result[0]), int(result[1])), (int(result[2]), int(result[3])), c, -1, 0)
|
||||
masked_path = image_util.get_save_path(f'{img_name}.mask.{img_ext}')
|
||||
masked_path = common_util.get_processed_img_path(f'{img_name}.mask.{img_ext}')
|
||||
cv2.imwrite(masked_path, i)
|
||||
return do_mask, masked_path
|
||||
|
||||
@@ -222,7 +222,7 @@ def photo_mask(pk_phhd, name, id_card_num):
|
||||
img_url = ufile.get_private_url(phrec.cfjaddress)
|
||||
if not img_url:
|
||||
continue
|
||||
img_path = image_util.save_to_local(img_url)
|
||||
img_path = common_util.save_to_local(img_url)
|
||||
is_masked, image = mask_photo(img_path, name, id_card_num)
|
||||
|
||||
# 如果涂抹了要备份以及更新
|
||||
|
||||
Reference in New Issue
Block a user