资源简介
opencv 实现车牌定位,矫正 切割
代码片段和文件信息
import cv2
import numpy as np
import matplotlib.pyplot as plt
import pickle
def resize_photo(imgArr MAX_WIDTH=800):
img = imgArr
rows cols = img.shape[:2] # 获取输入图像的高和宽
if cols > MAX_WIDTH:
change_rate = MAX_WIDTH / cols
img = cv2.resize(img (MAX_WIDTH int(rows * change_rate)) interpolation=cv2.INTER_AREA)
pic_hight pic_width = img.shape[:2]
#cv2.imshow(‘text_.jpg‘img)
return img pic_hight pic_width
def predict(imgArr):
img_copy = imgArr.copy()
img_copy_ = cv2.GaussianBlur(img_copy (5 5) 0 0 cv2.BORDER_DEFAULT)
gray_img = cv2.cvtColor(img_copy_ cv2.COLOR_BGR2GRAY)
# 高斯滤波
kernel = np.ones((23 23) np.uint8)
# 形态学变化,开运算
img_opening = cv2.morphologyEx(gray_img cv2.MORPH_OPEN k
评论
共有 条评论