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
评论列表
文章目录