毕业设计 python opencv实现车牌识别 形状定位

主要代码参考https://blog.csdn.net/wzh191920/article/details/79589506

GitHub:https://github.com/yinghualuowu

上文我们已经让图像变成了很多框框,根据原先版本,这种做法可以使用图形定位,因为车牌有尺寸规定啦,这是原版本的代码,还是别动了。

首先,我们设定一个最小的面积值:2000

先把矩形找到,把面积小的排除了,然后根据长宽比再排除一些,接下来保存合适的就行了

def img_findContours(img_contours,oldimg):
    img, contours, hierarchy = cv2.findContours(img_contours, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
    contours = [cnt for cnt in contours if cv2.contourArea(cnt) > Min_Area]
    print("findContours len = ", len(contours))
    # 排除面积最小的点
    debug.img_show(img)
    car_contours = []
    for cnt in contours:

        ant = cv2.minAreaRect(cnt)
        width, height = ant[1]
        if width < height:
            width, height = height, width
        ration = width / height
        print(ration)
        if ration > 2 and ration < 5.5:
            car_contours.append(ant)
            box = cv2.boxPoints(ant)
            box = np.int0(box)
            debug.img_contours(oldimg,box)
    return  car_contours

会发现圈不全,是因为预处理的原因....以后会用其他方式去定位,我们换一个吧

 

转载于:https://www.cnblogs.com/yinghualuowu/p/8857960.html

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值