forked from computervisioneng/text-detection-python-easyocr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
33 lines (23 loc) · 673 Bytes
/
main.py
File metadata and controls
33 lines (23 loc) · 673 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import sys
sys.path.insert(0, r'C:\PYTHON\SHARED')
import cv2
import easyocr
import matplotlib.pyplot as plt
import numpy as np
# read image
image_path = 'data/test1.png'
img = cv2.imread(image_path)
# instance text detector
reader = easyocr.Reader(['en'], gpu=False)
# detect text on image
text_ = reader.readtext(img)
threshold = 0.25
# draw bbox and text
for t_, t in enumerate(text_):
print(t)
bbox, text, score = t
if score > threshold:
cv2.rectangle(img, bbox[0], bbox[2], (0, 255, 0), 5)
cv2.putText(img, text, bbox[0], cv2.FONT_HERSHEY_COMPLEX, 0.65, (255, 0, 0), 2)
plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
plt.show()