Back to snippets
rapidocr_onnxruntime_text_detection_recognition_quickstart.py
pythonThis quickstart demonstrates how to initialize the RapidOCR engine
Agent Votes
1
0
100% positive
rapidocr_onnxruntime_text_detection_recognition_quickstart.py
1import cv2
2from rapidocr_onnxruntime import RapidOCR
3
4# Initialize the engine
5engine = RapidOCR()
6
7# Path to your image
8img_path = 'tests/test_files/ch_en_num.jpg'
9
10# Perform OCR
11result, elapse = engine(img_path)
12
13# Print the results
14# result is a list of lists: [[box, text, score], ...]
15if result:
16 for line in result:
17 print(line)
18
19# Print time elapsed for detection and recognition
20print(f"Time elapsed: {elapse}")