Untitled

 avatar
unknown
plain_text
2 years ago
600 B
5
Indexable
import cv2
import pytesseract
from pytesseract import Output


img = cv2.imread('sample-invoice.jpg')

d = pytesseract.image_to_data(img, output_type=Output.DICT)
# Print the keys of the resulting dictionary to see the available information
print(d.keys())

n_boxes = len(d['text'])
for i in range(n_boxes):
    if float(d['conf'][i]) > 60:  # Check if confidence score is greater than 60
        (x, y, w, h) = (d['left'][i], d['top'][i], d['width'][i], d['height'][i])
        img = cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)

cv2.imshow('img', img)
cv2.waitKey(0)
Editor is loading...
Leave a Comment