mirror of
https://github.com/RapidAI/RapidOCR.git
synced 2026-11-11 05:20:49 +08:00
fix: fixed issue #555
* fix: fixed issue #555 * chore: refactor code * chore: refactor code * chore: refactor code * chore: refactor code * chore: refactor code
This commit is contained in:
17 files changed
+248
-222
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 36 KiB |
@@ -13,7 +13,7 @@ sys.path.append(str(root_dir))
|
||||
|
||||
from rapidocr import RapidOCR
|
||||
|
||||
tests_dir = root_dir / "tests" / "test_files"
|
||||
test_dir = root_dir / "tests" / "test_files"
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@@ -22,6 +22,13 @@ def engine():
|
||||
return engine
|
||||
|
||||
|
||||
def test_txts_equal_words(engine):
|
||||
img_path = test_dir / "check_return_word_len.jpeg"
|
||||
result = engine(img_path, return_word_box=True)
|
||||
|
||||
assert len(result.txts) == len(result.word_results)
|
||||
|
||||
|
||||
@mark.parametrize(
|
||||
"img_name,words",
|
||||
[
|
||||
@@ -36,7 +43,7 @@ def engine():
|
||||
],
|
||||
)
|
||||
def test_cn_word_ocr(engine, img_name: str, words: List[str]):
|
||||
img_path = tests_dir / img_name
|
||||
img_path = test_dir / img_name
|
||||
result = engine(img_path, return_word_box=True)
|
||||
txts, _, _ = list(zip(*result.word_results[0]))
|
||||
assert txts == words
|
||||
@@ -47,14 +54,14 @@ def test_cn_word_ocr(engine, img_name: str, words: List[str]):
|
||||
[("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
|
||||
img_path = test_dir / img_name
|
||||
result = engine(img_path, return_word_box=True)
|
||||
txts, _, _ = list(zip(*result.word_results[0]))
|
||||
assert txts[0] == words
|
||||
|
||||
|
||||
def test_en_return_single_char_box(engine):
|
||||
img_path = tests_dir / "en.jpg"
|
||||
img_path = test_dir / "en.jpg"
|
||||
result = engine(img_path, return_word_box=True, return_single_char_box=True)
|
||||
txts, _, _ = list(zip(*result.word_results[0]))
|
||||
assert txts[0] == "3"
|
||||
Reference in new issue
Block a user