最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

python+OpenCV實(shí)現(xiàn)車牌號(hào)碼識(shí)別

 更新時(shí)間:2019年11月08日 13:30:43   作者:PYH1009  
這篇文章主要介紹了python+OpenCV實(shí)現(xiàn)車牌號(hào)碼識(shí)別,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

基于python+OpenCV的車牌號(hào)碼識(shí)別,供大家參考,具體內(nèi)容如下

車牌識(shí)別行業(yè)已具備一定的市場(chǎng)規(guī)模,在電子警察、公路卡口、停車場(chǎng)、商業(yè)管理、汽修服務(wù)等領(lǐng)域已取得了部分應(yīng)用。一個(gè)典型的車輛牌照識(shí)別系統(tǒng)一般包括以下4個(gè)部分:車輛圖像獲取、車牌定位、車牌字符分割和車牌字符識(shí)別

1、車牌定位的主要工作是從獲取的車輛圖像中找到汽車牌照所在位置,并把車牌從該區(qū)域中準(zhǔn)確地分割出來
這里所采用的是利用車牌的顏色(黃色、藍(lán)色、綠色) 來進(jìn)行定位

#定位車牌
def color_position(img,output_path):
 colors = [([26,43,46], [34,255,255]), # 黃色
    ([100,43,46], [124,255,255]), # 藍(lán)色
    ([35, 43, 46], [77, 255, 255]) # 綠色
    ]
 hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
 for (lower, upper) in colors:
  lower = np.array(lower, dtype="uint8") # 顏色下限
  upper = np.array(upper, dtype="uint8") # 顏色上限

  # 根據(jù)閾值找到對(duì)應(yīng)的顏色
  mask = cv2.inRange(hsv, lowerb=lower, upperb=upper)
  output = cv2.bitwise_and(img, img, mask=mask)
  k = mark_zone_color(output,output_path)
  if k==1:
   return 1
  # 展示圖片
  #cv2.imshow("image", img)
  #cv2.imshow("image-color", output)
  #cv2.waitKey(0)
 return 0

2、將車牌提取出來

def mark_zone_color(src_img,output_img):
 #根據(jù)顏色在原始圖像上標(biāo)記
 #轉(zhuǎn)灰度
 gray = cv2.cvtColor(src_img,cv2.COLOR_BGR2GRAY)

 #圖像二值化
 ret,binary = cv2.threshold(gray,0,255,cv2.THRESH_BINARY)
 #輪廓檢測(cè)
 x,contours,hierarchy = cv2.findContours(binary,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)
 #drawing = img
 #cv2.drawContours(drawing, contours, -1, (0, 0, 255), 3) # 填充輪廓顏色
 #cv2.imshow('drawing', drawing)
 #cv2.waitKey(0)
 #print(contours)
 
 temp_contours = [] # 存儲(chǔ)合理的輪廓
 car_plates=[]
 if len(contours)>0:
  for contour in contours:
   if cv2.contourArea(contour) > Min_Area:
    temp_contours.append(contour)
   car_plates = []
   for temp_contour in temp_contours:
    rect_tupple = cv2.minAreaRect(temp_contour)
    rect_width, rect_height = rect_tupple[1]
    if rect_width < rect_height:
     rect_width, rect_height = rect_height, rect_width
    aspect_ratio = rect_width / rect_height
    # 車牌正常情況下寬高比在2 - 5.5之間
    if aspect_ratio > 2 and aspect_ratio < 5.5:
     car_plates.append(temp_contour)
     rect_vertices = cv2.boxPoints(rect_tupple)
     rect_vertices = np.int0(rect_vertices)
   if len(car_plates)==1:
    oldimg = cv2.drawContours(img, [rect_vertices], -1, (0, 0, 255), 2)
    #cv2.imshow("che pai ding wei", oldimg)
    # print(rect_tupple)
    break

 #把車牌號(hào)截取出來
 if len(car_plates)==1:
  for car_plate in car_plates:
   row_min,col_min = np.min(car_plate[:,0,:],axis=0)
   row_max,col_max = np.max(car_plate[:,0,:],axis=0)
   cv2.rectangle(img,(row_min,col_min),(row_max,col_max),(0,255,0),2)
   card_img = img[col_min:col_max,row_min:row_max,:]
   cv2.imshow("img",img)
  cv2.imwrite(output_img + '/' + 'card_img' + '.jpg',card_img)
  cv2.imshow("card_img.",card_img)
  cv2.waitKey(0)
  cv2.destroyAllWindows()
  return 1
 return 0

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

遂川县| 乌兰县| 东乌珠穆沁旗| 东城区| 肇州县| 阆中市| 长武县| 吕梁市| 洪洞县| 山西省| 新和县| 叙永县| 东明县| 香河县| 肥乡县| 甘洛县| 岳西县| 长宁区| 宜兰市| 罗田县| 荆州市| 沈丘县| 高青县| 岳西县| 巧家县| 临江市| 浦县| 永城市| 宜丰县| 彭水| 林州市| 南郑县| 普宁市| 邮箱| 惠州市| 南阳市| 大港区| 仁化县| 莱阳市| 高台县| 繁峙县|