[英]Error : How to fix "SystemError: <built-in function imshow> returned NULL without setting an error" in Opencv python
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.我正在研究一个项目使用计算机视觉从发票中提取数据,我正在尝试使用 opencv 和 pytesseract 从图像发票中提取数据,并且我正在使用正则Regex
将原始数据分离到不同的部分,如日期、供应商名称、发票编号,项目名称和项目数量。在开始时,我试图提取日期但遇到错误。
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)
. cv2.imshow()
的语法是cv2.imshow("windowname", image)
。 In the program, line 12 should be cv2.imshow('img', img)
.在程序中,第 12 行应该是cv2.imshow('img', img)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.