畢業設計 python opencv實現車牌識別 矩形矯正

來源:互聯網
上載者:User

標籤:hub   href   git   角度   .net   def   war   ima   sdn   

主要代碼參考79589506

GitHub:https://github.com/yinghualuowu

答辯通過了,補完~

用的是仿射變換

def img_Transform(car_contours,oldimg,pic_width,pic_hight):    car_imgs = []    for car_rect in car_contours:        if car_rect[2] > -1 and car_rect[2] < 1:            angle = 1            # 對於角度為-1 1之間時,預設為1        else:            angle = car_rect[2]        car_rect = (car_rect[0], (car_rect[1][0] + 5, car_rect[1][1] + 5), angle)        box = cv2.boxPoints(car_rect)        heigth_point = right_point = [0, 0]        left_point = low_point = [pic_width, pic_hight]        for point in box:            if left_point[0] > point[0]:                left_point = point            if low_point[1] > point[1]:                low_point = point            if heigth_point[1] < point[1]:                heigth_point = point            if right_point[0] < point[0]:                right_point = point        if left_point[1] <= right_point[1]:  # 正角度            new_right_point = [right_point[0], heigth_point[1]]            pts2 = np.float32([left_point, heigth_point, new_right_point])  # 字元只是高度需要改變            pts1 = np.float32([left_point, heigth_point, right_point])            M = cv2.getAffineTransform(pts1, pts2)            dst = cv2.warpAffine(oldimg, M, (pic_width, pic_hight))            point_limit(new_right_point)            point_limit(heigth_point)            point_limit(left_point)            car_img = dst[int(left_point[1]):int(heigth_point[1]), int(left_point[0]):int(new_right_point[0])]            car_imgs.append(car_img)        elif left_point[1] > right_point[1]:  # 負角度            new_left_point = [left_point[0], heigth_point[1]]            pts2 = np.float32([new_left_point, heigth_point, right_point])  # 字元只是高度需要改變            pts1 = np.float32([left_point, heigth_point, right_point])            M = cv2.getAffineTransform(pts1, pts2)            dst = cv2.warpAffine(oldimg, M, (pic_width, pic_hight))            point_limit(right_point)            point_limit(heigth_point)            point_limit(new_left_point)            car_img = dst[int(right_point[1]):int(heigth_point[1]), int(new_left_point[0]):int(right_point[0])]            car_imgs.append(car_img)    return car_imgs

 

畢業設計 python opencv實現車牌識別 矩形矯正

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.