mirror of
https://github.com/RapidAI/RapidOCR.git
synced 2026-11-11 05:20:49 +08:00
* feat: add en/el/th ppocr_v5_rec_mobile paddle/onnx/openvino * test: change to a more secure code
39 lines
772 B
Python
39 lines
772 B
Python
# -*- encoding: utf-8 -*-
|
|
# @Author: SWHL
|
|
# @Contact: liekkaskono@163.com
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
root_dir = Path(__file__).resolve().parent.parent
|
|
sys.path.append(str(root_dir))
|
|
|
|
from rapidocr import RapidOCR
|
|
|
|
tests_dir = root_dir / "tests" / "test_files"
|
|
img_path = tests_dir / "ch_en_num.jpg"
|
|
|
|
|
|
@pytest.fixture()
|
|
def engine():
|
|
engine = RapidOCR()
|
|
return engine
|
|
|
|
|
|
def test_to_json(engine):
|
|
result = engine(img_path)
|
|
|
|
assert result.txts is not None
|
|
result_json = result.to_json()
|
|
assert result_json[0]["txt"] == "正品促销"
|
|
|
|
|
|
def test_to_markdown(engine):
|
|
result = engine(img_path)
|
|
|
|
assert result.txts is not None
|
|
|
|
result_markdown = result.to_markdown()
|
|
assert len(result_markdown.split("\n")) == 11
|