Skip to content

Commit 9eb825a

Browse files
committed
test: add test for new param
1 parent 30c4b0c commit 9eb825a

File tree

2 files changed

+14
-32
lines changed

2 files changed

+14
-32
lines changed

demo_wired.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,8 @@
1515

1616
table_rec = WiredTableRecognition()
1717

18-
img_path = "tests/test_files/wired/wired_big_box.png"
19-
html, elasp, polygons, logic_points, ocr_res = table_rec(
20-
img_path,
21-
version="v2", # 默认使用v2线框模型,切换阿里读光模型可改为v1
22-
morph_close=True, # 是否进行形态学操作,辅助找到更多线框,默认为True
23-
more_h_lines=True, # 是否基于线框检测结果进行更多水平线检查,辅助找到更小线框, 默认为True
24-
more_v_lines=True, # 是否基于线框检测结果进行更多垂直线检查,辅助找到更小线框, 默认为True
25-
extend_line=True, # 是否基于线框检测结果进行线段延长,辅助找到更多线框, 默认为True
26-
need_ocr=True, # 是否进行OCR识别, 默认为True
27-
rec_again=True, # 是否针对未识别到文字的表格框,进行单独截取再识别,默认为True
28-
)
18+
img_path = "tests/test_files/wired/table1.png"
19+
html, elasp, polygons, logic_points, ocr_res = table_rec(img_path)
2920

3021
print(f"cost: {elasp:.5f}")
3122

@@ -38,6 +29,6 @@
3829
plot_rec_box_with_logic_info(
3930
img_path, f"{output_dir}/table_rec_box.jpg", logic_points, polygons
4031
)
41-
plot_rec_box(f"{output_dir}/table_rec_box.jpg", f"{output_dir}/ocr_box.jpg", ocr_res)
32+
plot_rec_box(img_path, f"{output_dir}/ocr_box.jpg", ocr_res)
4233

4334
print(f"The results has been saved under {output_dir}")

wired_table_rec/utils_table_recover.py

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -267,17 +267,8 @@ def plot_rec_box_with_logic_info(img_path, output_path, logic_points, sorted_pol
267267

268268
cv2.putText(
269269
img,
270-
f"row:{logic_points[idx][0]}-{logic_points[idx][1]}",
271-
(x0 + 1, y0 + 15),
272-
cv2.FONT_HERSHEY_PLAIN,
273-
font_scale,
274-
(0, 0, 255),
275-
thickness,
276-
)
277-
cv2.putText(
278-
img,
279-
f"col:{logic_points[idx][2]}-{logic_points[idx][3]}",
280-
(x0 + 1, y0 + 40),
270+
f"{idx}-{logic_points[idx]}",
271+
(x1, y1),
281272
cv2.FONT_HERSHEY_PLAIN,
282273
font_scale,
283274
(0, 0, 255),
@@ -312,15 +303,15 @@ def plot_rec_box(img_path, output_path, sorted_polygons):
312303
font_scale = 1.0 # 原先是0.5
313304
thickness = 2 # 原先是1
314305

315-
# cv2.putText(
316-
# img,
317-
# str(idx),
318-
# (x1, y1),
319-
# cv2.FONT_HERSHEY_PLAIN,
320-
# font_scale,
321-
# (0, 0, 255),
322-
# thickness,
323-
# )
306+
cv2.putText(
307+
img,
308+
str(idx),
309+
(x1, y1),
310+
cv2.FONT_HERSHEY_PLAIN,
311+
font_scale,
312+
(0, 0, 255),
313+
thickness,
314+
)
324315
os.makedirs(os.path.dirname(output_path), exist_ok=True)
325316
# 保存绘制后的图像
326317
cv2.imwrite(output_path, img)

0 commit comments

Comments
 (0)