diff --git a/photo_mask.py b/photo_mask.py index 6275a64..de1dc61 100644 --- a/photo_mask.py +++ b/photo_mask.py @@ -196,7 +196,7 @@ def zoom_box(box, ratio): return [x1, y1, x2, y2] -def find_box_of_content(content, layout, img_path): +def find_box_of_content(content, layout, img_path, improve=True): full_box = layout[0] x_len = full_box[2] - full_box[0] y_len = full_box[3] - full_box[1] @@ -232,7 +232,7 @@ def find_box_of_content(content, layout, img_path): ] is_abnormal = box[3] - box[1] < (box[2] - box[0]) * len(content) / 2 - if is_abnormal: + if is_abnormal and improve: # 比例异常,再次识别 image = cv2.imread(img_path) # 截图时偏大一点 @@ -250,7 +250,7 @@ def find_box_of_content(content, layout, img_path): raise e for layout in layouts: if content in layout[1]: - temp_box = find_box_of_content(content, layout, temp_file.name) + temp_box = find_box_of_content(content, layout, temp_file.name, False) if temp_box: box = [ temp_box[0] + capture_box[0],