我用python下的opencv读取汽车牌照 下面的代码运行良好
_,thresh = cv2.threshold(Cropped,70,255,cv2.THRESH_BINARY_INV)
kernel = cv2.getStructuringElement(cv2.MORPH_CROSS,(3,3))
dilated = cv2.dilate(thresh,kernel,iterations = 0)
contoursX, hierarchy = cv2.findContours(thresh,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_NONE)
(contoursX, boundingBoxes) = contours.sort_contours(contoursX, method="left-to-right")
for contour in contoursX:
[x,y,w,h] = cv2.boundingRect(contour)
cv2.rectangle(Cropped, (x, y), (x + w, y + h), (90, 0, 255), 2)
plt.imshow(Cropped, cmap="gray", vmin=0, vmax=255)
plt.show()
如您所见,我已经对图像进行了灰度处理,并对其进行了crope,代码中的图像是Cropped
这个代码对我很有用
原始图片(在croping和灰度之后):
我应该改变轮廓函数中的attributus方法,还是玩颜色
我也在想,也许可以做一些聚类算法作为k-均值聚类黑鬼,但不知道如何或是否会工作。你知道吗
任何帮助:D
原始第二图像
目前没有回答
相关问题 更多 >
编程相关推荐