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
50 lines
1.2 KiB
Python
50 lines
1.2 KiB
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_vis_only_det(engine):
|
|
img_path = tests_dir / "ch_en_num.jpg"
|
|
result = engine(img_path, use_det=True, use_cls=False, use_rec=False)
|
|
vis_img = result.vis()
|
|
assert vis_img.shape[2] == 3
|
|
|
|
|
|
def test_vis_only_rec(engine):
|
|
img_path = tests_dir / "text_rec.jpg"
|
|
result = engine(img_path, use_det=False, use_cls=False, use_rec=True)
|
|
vis_img = result.vis()
|
|
assert vis_img.shape[2] == 3
|
|
|
|
|
|
def test_vis_only_cls(engine):
|
|
img_path = tests_dir / "text_rec.jpg"
|
|
result = engine(img_path, use_det=False, use_cls=True, use_rec=False)
|
|
vis_img = result.vis()
|
|
assert vis_img.shape[2] == 3
|
|
|
|
|
|
def test_vis_det_cls_rec(engine):
|
|
img_path = tests_dir / "ch_en_num.jpg"
|
|
result = engine(img_path, use_det=True, use_cls=True, use_rec=True)
|
|
vis_img = result.vis()
|
|
assert vis_img.shape[2] == 3
|