1、CBLPRD-330k车牌数据集介绍
① 、首先该数据集包含342110张车牌数据
②、该数据集包含各种各样的车牌数据,其中有拖拉机绿牌、新能源小汽车、普通蓝牌等几十种种类的车牌类型
③、该数据集没有对应,需要依据配置文件data.txt来进行解析
配置文件的形式如下:包含文件名称、车牌号码、以及车牌类型
因项目需要,只需要单层车牌,并且不需要“学”等特殊车牌
1),先过滤掉双层车牌以及拖拉机绿牌
def single_plate(plate_info):
if "双层" in plate_info or "拖拉机绿牌" in plate_info:
return False
return True
2)过滤掉 特殊车牌
carplateName="京沪津渝冀晋蒙辽吉黑苏浙皖闽赣鲁豫鄂湘粤桂琼川贵云藏陕甘青宁新港澳挂0123456789ABCDEFGHJKLMNPQRSTUVWXYZ"
def check_chr(image_name):
for chr_info in image_name:
if not chr_info in carplateName:
return False
return True
完整代码如下:
import cv2
import os
import numpy as np
from shutil import copyfile
from PIL import Image
image_path_list = []
car_plate_image_list = []
carplateName="京沪津渝冀晋蒙辽吉黑苏浙皖闽赣鲁豫鄂湘粤桂琼川贵云藏陕甘青宁新港澳挂0123456789ABCDEFGHJKLMNPQRSTUVWXYZ"
def check_chr(image_name):
for chr_info in image_name:
if not chr_info in carplateName:
return False
return True
def single_plate(plate_info):
if "双层" in plate_info or "拖拉机绿牌" in plate_info:
return False
return True
with open('data.txt', 'r', encoding='utf-8') as file:
for line in file:
image_path,image_name,plate_info = line.strip().split(" ")
image_path_list.append([image_path,image_name,plate_info])
for image_info in image_path_list:
image_path,image_name,plate_info = image_info
#print(image_name)
if check_chr(image_name) and single_plate(plate_info):
car_plate_image_list.append(image_info)
#print(len(car_plate_image_list))
for image_info in car_plate_image_list:
image_path,image_name,_ = image_info
file_name = image_name + ".jpg"
img = cv2.imread(image_path)
img = Image.fromarray(img)
img = img.resize((94, 24), Image.LANCZOS)
img = np.asarray(img) #
dst_root = os.path.join("plate_datasets",file_name)
#print(dst_root)
cv2.imwrite(dst_root, img)
标签:info,plate,330k,CBLPRD,image,path,车牌,name
From: https://blog.csdn.net/reset2021/article/details/145139092