test: add unit testings of issue 440 (#445)

This commit is contained in:
SWHL authored and GitHub committed 2025-06-06 22:42:41 +08:00
1 parent f40638d739
commit dcbe0d7efa
3 files changed
+4 -1

No files matched your search

+3
View File
@@ -79,6 +79,7 @@ class CalRecBoxes:
"""
if not rec_txt or word_info.line_txt_len == 0:
return [], [], []
bbox_points = quads_to_rect_bbox(bbox[None, ...])
avg_col_width = (bbox_points[2] - bbox_points[0]) / word_info.line_txt_len
@@ -166,8 +167,10 @@ class CalRecBoxes:
) -> float:
if txt_len == 0:
return 0.0
if len(width_list) > 0:
return sum(width_list) / len(width_list)
return (bbox_x1 - bbox_x0) / txt_len
@staticmethod
Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

+1 -1
View File
@@ -448,7 +448,7 @@ def test_cn_word_ocr(engine, img_name: str, words: List[str]):
@pytest.mark.parametrize(
"img_name,words",
[("issue_170.png", "TEST")],
[("issue_170.png", "TEST"), ("return_word_debug.jpg", "3F1")],
)
def test_en_word_ocr(engine, img_name: str, words: str):
img_path = tests_dir / img_name