2021SC@SDUSC
源代码下载地址:https://gitee.com/zeusees/HyperLPR
源码配置的详情见第一篇分析
本篇内容将继续根据小组分配的任务进行分析,内容如下:
一、finemappingVertical(...)函数
image_rgb = fv.finemappingVertical(image_rgb)
image_rgb = fv.finemappingVertical(image_rgb)
可以看出作者对图片执行了两次finemappingVertical操作。finemappingVertical源码如下:
def finemappingVertical(image):
resized = cv2.resize(image,(66,16))
resized = resized.astype(np.float)/255
res= model.predict(np.array([resized]))[0]
print("keras_predict",res)
res =res*image.shape[1]
res = res.astype(np.int)
H,T = res
H-=3
if H<0:
H=0
T+=2;
if T>= image.shape[1]-1:
T= image.shape[1]-1
image = image[0:35,H:T+2]
image = cv2.resize(image, (int(136), int(36)))
return image
先使用resize函数将已裁剪的图片再进行裁剪操作。
再使用astype函数来将原来灰度图颜色通道[0, 255]转化为float类型[0,1]
后self.modelFineMapping.predict函数输入66*16(float),输入进模型进行测试
model = getModel()
model.load_weights("./model/model12.h5")
model_finemapping()模型位于文件夹的该位置下:
该模型也是一个卷积神经网络模型,通过模型处理后,再次对文字进行裁剪输出。
keras网络模型:对车牌文字的左右边界进行回归
通过modelFineMapping.loadweights()函数加载模型文件
通过modelFineMapping.predict输出网络结果
输入:16*66*3 tensor
输出:长度为2的tensor
总结:该函数是车牌精定位,先使用resize函数将已裁剪的图片再进行裁剪操作。再使用astype函数来将原来灰度图颜色通道[0, 255]转化为float类型[0,1]。后self.modelFineMapping.predict函数输入66*16(float),输入进模型进行测试。该模型也是一个卷积神经网络模型,通过模型处理后,再次进行裁剪输出。通过modelFineMapping.loadweights()函数加载模型文件。最后输出裁剪后的图像,将各个文字的左右边界裁剪下来,识别出文字。
参考文章:HyperLPR车牌识别代码解读
CSDN博主:口袋的天空Zard
原文链接:https://blog.csdn.net/qq_37423198/article/details/81266401