ocr_test.py 721 B

1234567891011121314151617181920212223242526272829303132
  1. # This Python file uses the following encoding: utf-8
  2. # @author runhey
  3. # github https://github.com/runhey
  4. import cv2
  5. from module.ocr.ppocr import TextSystem
  6. # from ppocronnx.predict_system import TextSystem
  7. if __name__ == "__main__":
  8. text_sys = TextSystem()
  9. # 检测并识别文本
  10. img = cv2.imread('D:/test_single1.jpg')
  11. if img is None:
  12. print("Error: img is None")
  13. exit(1)
  14. res = text_sys.detect_and_ocr(img)
  15. if res is None:
  16. print("Error: res is None")
  17. exit(1)
  18. for boxed_result in res:
  19. print("{}, {:.3f}".format(boxed_result.ocr_text, boxed_result.score))
  20. print(boxed_result.box)
  21. res = text_sys.ocr_single_line(img)
  22. print(res)