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