I am working on one project Data extraction from invoices using computer vision in this i am trying to extract data from image invoice using opencv and pytesseract and further i am using Regex for segregate that raw data into different parts like Date, Vendor name, Invoice number, item name and item quantity.at start i am trying to extract Date but stuck with error.
here is my code
import pytesseract
from pytesseract import Output
import cv2
img = cv2.imread('invoice.png')
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])
img = cv2.rectangle(img, (x, y), (x + w, y + h), (0, 0, 255), 2)
cv2.imshow(img,'img')
but i get this error
File "testpdf3.py", line 12, in <module>
cv2.imshow(img,'img')
SystemError: <built-in function imshow> returned NULL without setting an error
The syntax of cv2.imshow() is
cv2.imshow("windowname", image).
In the program, line 12 should be cv2.imshow('img', img).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With