限制递归次数
This commit is contained in:
@@ -196,7 +196,7 @@ def zoom_box(box, ratio):
|
|||||||
return [x1, y1, x2, y2]
|
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]
|
full_box = layout[0]
|
||||||
x_len = full_box[2] - full_box[0]
|
x_len = full_box[2] - full_box[0]
|
||||||
y_len = full_box[3] - full_box[1]
|
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
|
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)
|
image = cv2.imread(img_path)
|
||||||
# 截图时偏大一点
|
# 截图时偏大一点
|
||||||
@@ -250,7 +250,7 @@ def find_box_of_content(content, layout, img_path):
|
|||||||
raise e
|
raise e
|
||||||
for layout in layouts:
|
for layout in layouts:
|
||||||
if content in layout[1]:
|
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:
|
if temp_box:
|
||||||
box = [
|
box = [
|
||||||
temp_box[0] + capture_box[0],
|
temp_box[0] + capture_box[0],
|
||||||
|
|||||||
Reference in New Issue
Block a user