Skip to content

📄 Awesome OCR multiple programing languages toolkits based on ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT and PyTorch.

Fix bug of CLI

SWHL83463eaaf0ef
diff --git a/docs/doc_whl_rapidocr_ort.md b/docs/doc_whl_rapidocr_ort.md
index 0feab30..5e6035d 100644
--- a/docs/doc_whl_rapidocr_ort.md
+++ b/docs/doc_whl_rapidocr_ort.md
@@ -10,21 +10,46 @@ $ pip install rapidocr-onnxruntime
```
### 2. Use.
-```python
-import cv2
-from rapidocr_onnxruntime import RapidOCR
+- Run by script.
+ ```python
+ import cv2
+ from rapidocr_onnxruntime import RapidOCR
-rapid_ocr = RapidOCR()
+ rapid_ocr = RapidOCR()
-img = cv2.imread('test_images/ch_en_num.jpg')
+ img_path = 'tests/test_files/ch_en_num.jpg'
-result, elapse_list = rapid_ocr(img)
-print(result)
-print(elapse_list)
+ # str
+ result = rapid_ocr(img_path)
-# result: [[dt_boxes], txt, score]
-# 示例:[[左上, 右上, 右下, 左下], '小明', '0.99']
+ # np.ndarray
+ img = cv2.imread('tests/test_files/ch_en_num.jpg')
+ result = rapid_ocr(img)
-# elapse_list: [det_elapse, cls_elapse, rec_elapse]
-# all_elapse = det_elapse + cls_elapse + rec_elapse
-```
+ # bytes
+ with open(img_path, 'rb') as f:
+ result = rapid_ocr(f.read())
+
+ # Path
+ result = rapid_ocr(Path(img_path))
+ print(result)
+
+ # result: [[dt_boxes], txt, score]
+ # 示例:[[左上, 右上, 右下, 左下], '小明', '0.99']
+
+ # elapse_list: [det_elapse, cls_elapse, rec_elapse]
+ # all_elapse = det_elapse + cls_elapse + rec_elapse
+ ```
+
+- Run by command line.
+ ```bash
+ $ rapidocr_onnxruntime -h
+ usage: rapidocr_onnxruntime [-h] [-img IMG_PATH] [-p]
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -img IMG_PATH, --img_path IMG_PATH
+ -p, --print_cost
+
+ $ rapidocr_onnxruntime -img tests/test_files/ch_en_num.jpg
+ ```
\ No newline at end of file
diff --git a/docs/doc_whl_rapidocr_vino.md b/docs/doc_whl_rapidocr_vino.md
index cbcbace..71c6be8 100644
--- a/docs/doc_whl_rapidocr_vino.md
+++ b/docs/doc_whl_rapidocr_vino.md
@@ -11,21 +11,46 @@ $ pip install rapidocr-openvino
### 2. Use.
-```python
-import cv2
-from rapidocr_openvino import RapidOCR
+- Run by script.
+ ```python
+ import cv2
+ from rapidocr_openvino import RapidOCR
-rapid_ocr = RapidOCR()
+ rapid_ocr = RapidOCR()
-img = cv2.imread('test_images/ch_en_num.jpg')
+ img_path = 'tests/test_files/ch_en_num.jpg'
-result, elapse_list = rapid_ocr(img)
-print(result)
-print(elapse_list)
+ # str
+ result = rapid_ocr(img_path)
-# result: [[dt_boxes], txt, score]
-# 示例:[[左上, 右上, 右下, 左下], '小明', '0.99']
+ # np.ndarray
+ img = cv2.imread('tests/test_files/ch_en_num.jpg')
+ result = rapid_ocr(img)
-# elapse_list: [det_elapse, cls_elapse, rec_elapse]
-# all_elapse = det_elapse + cls_elapse + rec_elapse
-```
+ # bytes
+ with open(img_path, 'rb') as f:
+ result = rapid_ocr(f.read())
+
+ # Path
+ result = rapid_ocr(Path(img_path))
+ print(result)
+
+ # result: [[dt_boxes], txt, score]
+ # 示例:[[左上, 右上, 右下, 左下], '小明', '0.99']
+
+ # elapse_list: [det_elapse, cls_elapse, rec_elapse]
+ # all_elapse = det_elapse + cls_elapse + rec_elapse
+ ```
+
+- Run by command line.
+ ```bash
+ $ rapidocr_openvino -h
+ usage: rapidocr_openvino [-h] [-img IMG_PATH] [-p]
+
+ optional arguments:
+ -h, --help show this help message and exit
+ -img IMG_PATH, --img_path IMG_PATH
+ -p, --print_cost
+
+ $ rapidocr_openvino -img tests/test_files/ch_en_num.jpg
+ ```
\ No newline at end of file
diff --git a/python/rapidocr_onnxruntime/rapid_ocr_api.py b/python/rapidocr_onnxruntime/rapid_ocr_api.py
index 1198d44..c81583d 100644
--- a/python/rapidocr_onnxruntime/rapid_ocr_api.py
+++ b/python/rapidocr_onnxruntime/rapid_ocr_api.py
@@ -175,7 +175,7 @@ class RapidOCR():
def main():
- parser = argparse.ArgumentParser('RapidOCR')
+ parser = argparse.ArgumentParser()
parser.add_argument('-img', '--img_path', type=str, default=None)
parser.add_argument('-p', '--print_cost',
action='store_true', default=False)
diff --git a/python/rapidocr_openvino/rapid_ocr_api.py b/python/rapidocr_openvino/rapid_ocr_api.py
index 1198d44..c81583d 100644
--- a/python/rapidocr_openvino/rapid_ocr_api.py
+++ b/python/rapidocr_openvino/rapid_ocr_api.py
@@ -175,7 +175,7 @@ class RapidOCR():
def main():
- parser = argparse.ArgumentParser('RapidOCR')
+ parser = argparse.ArgumentParser()
parser.add_argument('-img', '--img_path', type=str, default=None)
parser.add_argument('-p', '--print_cost',
action='store_true', default=False)