location.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:Vehicle-Logo-Recognition 作者: xinyuexy 项目源码 文件源码
def plateDetect(img,img2):
    '''?????????????????'''
    im2, contours, hierarchy = cv2.findContours(img, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
    for con in contours:
        x,y,w,h=cv2.boundingRect(con)
        area=w*h
        ratio=w/h
        if ratio>2 and ratio<4 and area>=2000 and area<=25000:
            logo_y1=max(0,int(y-h*3.0))
            logo_y2=y
            logo_x1=x
            logo_x2=x+w
            img_logo=img2.copy()
            logo=img_logo[logo_y1:logo_y2,logo_x1:logo_x2]
            cv2.imwrite('./logo1.jpg',logo)
            cv2.rectangle(img2,(x,y),(x+w,y+h),(255,0,0),2)
            cv2.rectangle(img2,(logo_x1,logo_y1),(logo_x2,logo_y2),(0,255,0),2)
            global plate
            plate=[x,y,w,h]
            #?????????
            return logo
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号