Skip to content

Commit 0afb17b

Browse files
Create TextSimple.py
1 parent fd0b6b9 commit 0afb17b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import cv2
2+
import pytesseract
3+
import numpy as np
4+
from PIL import ImageGrab
5+
import time
6+
7+
8+
pytesseract.pytesseract.tesseract_cmd = 'C:\\Program Files\\Tesseract-OCR\\tesseract.exe'
9+
img = cv2.imread('1.png')
10+
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
11+
12+
#############################################
13+
#### Detecting Characters ######
14+
#############################################
15+
hImg, wImg,_ = img.shape
16+
boxes = pytesseract.image_to_boxes(img)
17+
for b in boxes.splitlines():
18+
print(b)
19+
b = b.split(' ')
20+
print(b)
21+
x, y, w, h = int(b[1]), int(b[2]), int(b[3]), int(b[4])
22+
cv2.rectangle(img, (x,hImg- y), (w,hImg- h), (50, 50, 255), 2)
23+
cv2.putText(img,b[0],(x,hImg- y+25),cv2.FONT_HERSHEY_SIMPLEX,1,(50,50,255),2)
24+
25+
26+
cv2.imshow('img', img)
27+
cv2.waitKey(0)

0 commit comments

Comments
 (0)