π Awesome OCR multiple programing languages toolkits based on ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT and PyTorch.
# -*- encoding: utf-8 -*-
# @Author: SWHL
# @Contact: [email protected]
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