Graduation Design python OpenCV realize the color judgment of license plate recognition

Source: Internet
Author: User

Main code Reference 79589506

Github:https://github.com/yinghualuowu

The reply has passed, the completion ~

This part of the code also includes narrowing the boundaries

defImg_color (CARD_IMGS): Colors= []     forCard_index, card_imginchEnumerate (CARD_IMGS): Green= Yello = Blue = Black = White =0 CARD_IMG_HSV=Cv2.cvtcolor (card_img, Cv2. COLOR_BGR2HSV)#there is a possibility of conversion failure, due to errors in correcting rectangles above        ifCard_img_hsv isNone:Continuerow_num, Col_num= Card_img_hsv.shape[:2] Card_img_count= Row_num *Col_num forIinchRange (row_num): forJinchRange (col_num): H=Card_img_hsv.item (i, J, 0) S= Card_img_hsv.item (I, J, 1) V= Card_img_hsv.item (I, J, 2)                if< H <= 34 andS > 34: Yello+ = 1elif< H <= 99 andS > 34: Green+ = 1elif< H <= 124 andS > 34: Blue+ = 1if0 < H < 180 and0 < S < 255 and0 < V < 46: Black+ = 1elif0 < H < 180 and0 < S < 43 and221 < V < 225: White+ = 1Color="No"limit1= Limit2 =0ifYello * 2 >=Card_img_count:color="Yello"limit1= 11Limit2= 34#some pictures are colored but green        elifGreen * 2 >=Card_img_count:color="Green"limit1= 35Limit2= 99elifBlue * 2 >=Card_img_count:color="Blue"limit1= 100Limit2= 124#some pictures are colored but Violet        elifBlack + White >= card_img_count * 0.7: Color="BW"colors.append (color) Card_imgs[card_index]=card_imgifLimit1 = =0:Continuexl, XR, YH, yl=accurate_place (CARD_IMG_HSV, limit1, limit2, color)ifYL = = YH andXL = =XR:Continueneed_accurate=FalseifYL >=Yh:yl=0 YH=row_num need_accurate=TrueifXL >=XR:XL=0 XR=Col_num need_accurate=Trueifcolor = ="Green": Card_imgs[card_index]=card_imgElse: Card_imgs[card_index]= Card_img[yl:yh, XL:XR]ifColor! ="Green" orYL < (yh-yl)//4Elsecard_img[ YL- ( YH-yl)//4: YH, XL:XR] ifneed_accurate:card_img=Card_imgs[card_index] CARD_IMG_HSV=Cv2.cvtcolor (card_img, Cv2. COLOR_BGR2HSV) XL, XR, YH, yl=accurate_place (CARD_IMG_HSV, limit1, limit2, color)ifYL = = YH andXL = =XR:Continue            ifYL >=Yh:yl=0 YH=row_numifXL >=XR:XL=0 XR=Col_numifcolor = ="Green": Card_imgs[card_index]=card_imgElse: Card_imgs[card_index]= Card_img[yl:yh, XL:XR]ifColor! ="Green" orYL < (yh-yl)//4Elsecard_img[ YL- ( YH-yl)//4: YH, XL:XR] returnColors,card_imgs

Accrate_place part

defaccurate_place (CARD_IMG_HSV, limit1, limit2, color): row_num, Col_num= Card_img_hsv.shape[:2] XL=Col_num XR=0 YH=0 yl=row_num Row_num_limit= 21Col_num_limit= Col_num * 0.8ifColor! ="Green" ElseCol_num * 0.5#Green with gradient     forIinchRange (row_num): Count=0 forJinchRange (col_num): H=Card_img_hsv.item (i, J, 0) S= Card_img_hsv.item (I, J, 1) V= Card_img_hsv.item (I, J, 2)            ifLimit1 < H <= Limit2 and< S and<V:count+ = 1ifCount >Col_num_limit:ifYL >I:yl=IifYH <I:yh=I forJinchRange (col_num): Count=0 forIinchRange (row_num): H=Card_img_hsv.item (i, J, 0) S= Card_img_hsv.item (I, J, 1) V= Card_img_hsv.item (I, J, 2)            ifLimit1 < H <= Limit2 and< S and<V:count+ = 1ifCount > Row_num-Row_num_limit:ifXL >J:XL=JifXR <J:XR=JreturnXL, XR, YH, YL

Graduation Design python OpenCV realize the color judgment of license plate recognition

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.