【发布时间】:2019-12-28 13:09:52
【问题描述】:
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 打印图像时得到的某种矩阵一样。
【问题讨论】:
标签: python python-3.x machine-learning artificial-intelligence