Skip to content

Commit

Permalink
Almost complete
Browse files Browse the repository at this point in the history
  • Loading branch information
SWHL committed Sep 13, 2021
1 parent e13c8aa commit 737c380
Show file tree
Hide file tree
Showing 12 changed files with 6,740 additions and 87 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,6 @@ dmypy.json

# Pyre type checker
.pyre/

.vscode
*.onnx
Binary file added assets/1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/1.mp4
Binary file not shown.
27 changes: 27 additions & 0 deletions demo_rapidocr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# !/usr/bin/env python
# -*- encoding: utf-8 -*-
# @Author: SWHL
# @Contact: [email protected]
import cv2
from rapidocr import TextSystem

det_model_path = "resources/models/ch_PP-OCRv2_det_infer.onnx"
cls_model_path = "resources/models/ch_ppocr_mobile_v2.0_cls_infer.onnx"
rec_model_path = "resources/models/ch_mobile_v2.0_rec_infer.onnx"
dict_path = "resources/ppocr_keys_v1.txt"

ocr_system = TextSystem(det_model_path,
rec_model_path,
cls_model_path,
dict_path)


if __name__ == '__main__':
image_path = 'tmp.jpg'
img = cv2.imread(image_path)

dt_boxes, rec_res = ocr_system(img)
txts = [rec_res[i][0] for i in range(len(rec_res))]

for txt in txts:
print(txt)
24 changes: 24 additions & 0 deletions example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# !/usr/bin/env python
# -*- encoding: utf-8 -*-
# @Author: SWHL
# @Contact: [email protected]
from rapidocr import TextSystem

from videocr import get_subtitles

det_model_path = "resources/models/ch_PP-OCRv2_det_infer.onnx"
cls_model_path = "resources/models/ch_ppocr_mobile_v2.0_cls_infer.onnx"
rec_model_path = "resources/models/ch_mobile_v2.0_rec_infer.onnx"
dict_path = "resources/ppocr_keys_v1.txt"

ocr_system = TextSystem(det_model_path,
rec_model_path,
cls_model_path,
dict_path)


if __name__ == '__main__':
print(get_subtitles('assets/1.mp4',
ocr_system,
sim_threshold=70,
conf_threshold=0.8))
Empty file added resources/models/placeholder
Empty file.
Loading

0 comments on commit 737c380

Please sign in to comment.