1

Using Pytesseract, how can I get word coordinates as output from OCR?

import pytesseract
from pytesseract import Output
import cv2

img = cv2.imread('C:/Users/temp/Desktop/Invoice.jpg')

d = pytesseract.image_to_data(img, output_type=Output.DICT)
n_boxes = len(d['level'])
for i in range(n_boxes):
    (x, y, w, h) = (d['left'][i], d['top'][i], d['width'][i], d['height'][i])
    cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)

cv2.imshow('img', img)
cv2.waitKey(0)

OCR is done, but word coordinates are not returned.

Makyen
  • 31,849
  • 12
  • 86
  • 121
  • https://cloud.google.com/functions/docs/tutorials/ocr#functions-clone-sample-repository-python – M-- Feb 28 '20 at 16:07

0 Answers0