- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
pyterresect 的最终调用不返回字符串,而是仅返回该图像每个像素的打印值。
import numpy as np
import cv2
import imutils
from PIL import Image
from pytesseract import image_to_string
count = 0
for c in cnts:
peri = cv2.arcLength(c, True)
approx = cv2.approxPolyDP(c, 0.02 * peri, True)
if len(approx) == 4: # Select the contour with 4 corners
NumberPlateCnt = approx #This is our approx Number Plate Contour
pl=NumberPlateCnt
print(NumberPlateCnt)
if(pl[0][0][1]+10>pl[2][0][1] or pl[0][0][0]+40>pl[2][0][0]):
continue
filter_img = image[pl[0][0][1]:pl[2][0][1],pl[0][0][0]:pl[2][0][0]]
print("Number Plate Detected")
cv2_imshow(filter_img)
Number=pytesseract.image_to_string(filter_img,lang='eng')
print("Number is :",Number)
cv2.waitKey(0)
cv2.drawContours(image, [NumberPlateCnt], -1, (0, 255, 0), 3)
print("Final Image With Number Plate Detected")
cv2_imshow(image)
cv2.waitKey(0) #Wait for user input before closing the images displayed
我在这里得到的数字应该是一些字符串,但它的打印就像我们使用 print 打印图像时得到的某种矩阵。
最佳答案
您得到的矩阵很可能来自您的这行代码:
print(NumberPlateCnt)
并且 pytesseract.image_to_string
只是无法识别您试图获得的矩形轮廓上的任何文本,这意味着以下两行会为您打印一个空结果:
Number=pytesseract.image_to_string(filter_img,lang='eng')
print("Number is :",Number)
由于您正在迭代具有最大面积的等高线,因此输出应如下所示:
Number Plate Detected
Number is :
[[[223 278]]
[[272 279]]
[[274 282]]
[[224 281]]]
“Number is:”字符串是空的,下一次等高线计算迭代将得出以下矩阵结果。
要解决这个问题,您可以检查 PyTesseract 返回的字符串是否包含任何内容,如下所示:
if (len(Number)):
print("Number is :", Number)
只有当它包含 PyTesseract 识别的任何符号时,它才会打印 Number。
关于python - 车辆牌照 OCR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57622389/
我希望向订单输入系统添加一项功能,以实时显示订单位置与指定送货车之间的距离(以公里为单位)。 货车有一个 GPS 跟踪系统,来自 High Point GPS , 带有查询司机位置的API,以LAT/
我正在尝试为 C 中的以下内容动态分配空间,我想知道是否有人可以解释如何操作?字符* (*车辆)[][5]; 这 5 个元素是车辆的详细信息,第一个数组用于不同的车辆。所以我正在尝试为不同的车辆动态分
我有难得的机会在几个小时内与负责为美国交通部实现车辆 2 车辆通信的人员和其他 2 人会面。 您有什么问题要问他吗? 我知道这有点不正常,但这是一个“反向”线程,我觉得他对我想与这个社区分享的主题有一
我对 GraphHopper 路由引擎稳定版本 0.5 有疑问 使用vehicle=car时我可以获取路线,但使用自行车和步行则无法获取路线。 Here is an example在 GraphHop
有谁知道以 PHP、Perl 或 Python(或任何其他语言,我可以轻松转换代码)作为开源/免费软件提供的 ISO 3779 车辆 VIN 解码器库? 即使只是解码 WMI 部分(前 3 个位置)也
我正在尝试使用 L5 分页,一切看起来都很好,直到我点击第二页链接。当我点击它时出现此错误: Laravel 5 Pagination undefined variable vehicles in v
我是一名优秀的程序员,十分优秀!