我需要直接从我的网络摄像头处理车牌图像,使用python和它的OpenCV库
目前我已经达到了可以单独识别车牌字符的程度,但我仍然需要从图像中删除背景
此背景与字符的颜色相同,因此颜色过滤器工作不太好。 除此之外,我的图像还需要一些调整和清理,我的阈值形态学改变无法处理
我当前的图片如下:
我需要实现以下最终结果:
我现在已经完成了这几行代码,但由于我的努力、参数修改和应用的过滤器,我仍然无法实现我的目标
import cv2
cv2.imread("plate_from_webcam.png")
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
(thresh, imgPB) = cv2.threshold(img, 156, 255, cv2.THRESH_BINARY)
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (1, 2))
imgPB = cv2.morphologyEx(imgPB, cv2.MORPH_OPEN, kernel)
imgRoi = imgPB[y:y + h, x:x + w]
cv2.imshow("ROI", imgRoi)
为了达到预期的结果,下一步应该采取什么措施
在Python/OpenCV中有一种方法
输入:
阈值图像(形态学处理后):
遮罩图像:
结果图像:
相关问题 更多 >
编程相关推荐