Graduation Design python OPENCV realization of plate recognition rectangle correction

Source: Internet
Author: User

Main code Reference 79589506

Github:https://github.com/yinghualuowu

The reply has passed, the completion ~

With an affine transformation.

defImg_transform (car_contours,oldimg,pic_width,pic_hight): Car_imgs= []     forCar_rectinchcar_contours:ifCAR_RECT[2] >-1 andCAR_RECT[2] < 1: Angle= 1#For an angle of 1 1, the default is 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] forPointinchBox:ifLeft_point[0] >point[0]: Left_point= PointifLOW_POINT[1] > Point[1]: Low_point= PointifHEIGTH_POINT[1] < point[1]: Heigth_point= PointifRight_point[0] <point[0]: Right_point= PointifLEFT_POINT[1] <= right_point[1]:#Positive AngleNew_right_point = [Right_point[0], heigth_point[1]] Pts2= Np.float32 ([Left_point, Heigth_point, New_right_point])#characters are only highly needed to changePts1 =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 (Heig Th_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)elifLEFT_POINT[1] > Right_point[1]:#Negative AngleNew_left_point = [Left_point[0], heigth_point[1]] Pts2= Np.float32 ([New_left_point, Heigth_point, Right_point])#characters are only highly needed to changePts1 =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_p oint) 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)returnCar_imgs

Graduation Design python OPENCV realization of plate recognition rectangle correction

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.