本文共 1748 字,大约阅读时间需要 5 分钟。
?????????????Python???OpenCV??cv2??????????????????????????????????
?????????????????????????????????????????
??????????????????????????????????????Canny??????????????????????????????????????????????cv2.rectangle??????????????????
???????????????????????????????????????cv2.grabCut?????????????????????????????????????????????????????????????????
??????????????????????????????????????????????????????????????????????
??????????????????????
?????????????????????????????R?G?B??????????????
???????????????????????????????????????????????????????????????
Sobel?????Sobel????????????Sobel???????????????????????????????
?????????????????????????????127??????255???127??????0??????????????????
??????????????????????????????????????????????????
????????????????????????????????????????????????????
?????????????????????????????????
??????????????????????????????????????
?????????????????
import cv2import numpy as np# ????gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)# ????kernel = np.ones(3,3)smoothed = cv2.blur(gray, (3,3))# Sobel??grad_x = cv2.Sobel(gray, 1, 0, 3)grad_y = cv2.Sobel(gray, 0, 1, 3)# ?????binary = cv2.threshold(smoothed, 127, 255, 0)# ?????dilation = cv2.dilation(binary, np.ones(3,3))erode = cv2.erode(binary, np.ones(3,3))# ?????car_plate = np.where(erode > 0, 1, 0)# ??????rect = cv2.selectROI(img, car_plate)x1, y1 = rect[0], rect[1]x2, y2 = rect[2], rect[3]# ????plate = img[y1:y2, x1:x2]# ????# ?????????????????
????????????????????????????????????????????
???????????????????????????
?????????????????????????????????????????
?????????????????????????????????????????????????????
???????????????????????????????????????
???????????????????????????????????
转载地址:http://alsfk.baihongyu.com/