首页天道酬勤python图像识别与提取,python车牌识别系统开源代码

python图像识别与提取,python车牌识别系统开源代码

admin 05-13 07:43 149次浏览

以下是关于如何解决你的问题的大致想法。 在此基础上可以更加努力。 必须从图像中提取编号,并将图像发送到tesseract。 读代码注释,看看我要做什么。 在import numpy as np上

导入cv2

导入类型服务

import matplotlib.pyplot as plt

img=cv2.im read ((/home/muthu/documents/3r9oq.jpg ) )

#convert my image to grayscale

gray=cv2.cvtcolor(img,cv2.COLOR_BGR2GRAY )。

# performadaptivethresholdsothaticanextractpropercontoursfromtheimage

# needthistoextractthenameplatefromtheimage。

thresh=cv2.adaptive threshold (gray,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY,11,2 )

contours,h=cv2.findContours(Thresh,1,2 ) ) ) ) ) ) ) ) )。

#once I have the contours list,ineedtofindthecontourswhichformrectangles。

# thecontourscanbeapproximatedtominimumpolygons,polygonsofsize4areprobablyrectangles

largest _ rectangle=[ 0,0 ]

for cnt in contours:

approx=cv2.approxpolydp(CNT,0.01 * cv2.arc长度(CNT,True ),True ) )

iflen(approx )==4: # polygons with4pointsiswhatineed。

area=cv2.contourarea(CNT ) ) ) )。

ifarealargest _ rectangle [0] :

# findthepolygonwhichhasthelargestsize。

largest _ rectangle=[ cv2.contour area (CNT ),CNT,approx]

x,y,w,h=cv2.bounding rect (largest _ rectangle [1]

# croptherectangletogetthenumberplate。

roi=img[y:y h,x:x w]

#cv2.drawcontours(img,[largest_rectangle[1]],0,((0,0,255 ),(-1 ) ) ) ) ) ) ) ) )

PLT.imshow(ROI,cmap='gray ' ) )。

plt.show () )

输出为牌照,如下所示。

现在,将这个裁剪后的图像传递给马赛克。 在

^{pr2}$

共享的样本图像的输出如下所示。 在

如果将车牌图像的透视转换为边界框的矩形,然后删除周围多余的边界框,分析将更加准确。 如果你也需要帮助的话请告诉我。 在

上面的代码不适用于第二个图像。 因为如果使用它的话,我们会过滤掉有四条边的多边形进行搜索。 我希望你有这个想法。 在

计算机毕业设计ssm汽车租赁管理系统n5s69系统+程序+源码+lw+远程部署
matlab神经网络图像识别,基于matlab的车牌识别系统设计 数码相机和ccd有什么区别,CCD和CMOS
相关内容