自己整理了一些用在车牌识别的数据集,已经人工一张一张的筛选过了,过滤掉模糊的图片、处理有歧义的区域,可以直接采用。
label为labelme的json格式,目标框是polygon多边形,好处是不同角度的车牌都能完全贴合,如图。

整理了三类车牌,分别是蓝牌、绿牌、黄牌(直接点击即可下载)。
若是要进行yolo的目标检测训练,可用以下代码进行转换为yolo的darknet格式:

import json
import os
import shutil
import cv2
import os
from numpy.lib.twodim_base import triu_indices_from
import pandas as pd
from glob import glob
import codecsprint(cv2.__version__)def getBoundingBox(points):              xmin = points[0][0]xmax = points[0][0]ymin = points[0][1]ymax = points[0][1]for p in points:if p[0] > xmax:xmax = p[0]elif p[0] < xmin:xmin = p[0]if p[1] > ymax:ymax = p[1]elif p[1] < ymin:ymin = p[1]return [int(xmin), int(xmax), int(ymin), int(ymax)]def json2txt(json_path, midTxt_path):json_data = json.load(open(json_path))         img_h = json_data["imageHeight"]img_w = json_data["imageWidth"]shape_data = json_data["shapes"]shape_data_len = len(shape_data)img_name = os.path.split(json_path)[-1].split(".json")[0]    name = img_name + '.jpg'                            data = ''for i in range(shape_data_len):lable_name = shape_data[i]["label"]             points = shape_data[i]["points"]                [xmin, xmax, ymin, ymax] = getBoundingBox(points)if xmin <= 0:xmin = 0if ymin <= 0:ymin = 0if xmax >= img_w:  xmax = img_w - 1if ymax >= img_h:ymax = img_h - 1b = name + ' ' + lable_name + ' ' + str(xmin) + ' ' + str(ymin) + ' ' + str(xmax) + ' ' + str(ymax)print(b)data += b + '\n'with open(midTxt_path + '/' + img_name + ".txt", 'w', encoding='utf-8') as f:    f.writelines(data)          def txt2darknet(midTxt_path, img_path):data = pd.DataFrame()filelist = os.listdir(midTxt_path) for file in filelist:                                                   file_path = os.path.join(midTxt_path, file)filename = os.path.splitext(file)[0]imgName = filename + '.jpg'imgPath = os.path.join(img_path, imgName)# for path in img_path:#     imgPath = os.path.join(path, imgName)#     if not os.path.exists(imgPath):#         continue#     else:#         breakif not os.path.exists(imgPath):imgName = filename + '.png'imgPath = os.path.join(img_path, imgName)if not os.path.exists(imgPath):imgName = filename + '.jpeg'imgPath = os.path.join(img_path, imgName)img = cv2.imread(imgPath)print(imgPath)[img_h, img_w, _] = img.shapedata = ""with codecs.open(file_path, 'r', encoding='utf-8',errors='ignore') as f1:for line in f1.readlines():line = line.strip('\n')a = line.split(' ')if int(a[5]) - int(a[3]) <= 15 or int(a[4]) - int(a[2]) <= 15:img[int(a[3]):int(a[5]), int(a[2]):int(a[4]), :] = (0,0,0)continueif a[1] == 'other' or a[1] == 'del':img[int(a[3]):int(a[5]), int(a[2]):int(a[4]), :] = (0,0,0)continueif a[1] == 'plate_p':            # bluea[1] = '0'elif a[1] == 'green_plate':      # greena[1] = '1'elif a[1] == 'yellow_plate_s':   # yellowa[1] = '2'x1 = float(a[2])y1 = float(a[3])w = float(a[4]) - float(a[2])h = float(a[5]) - float(a[3])# if w <= 15 and h <= 15: continuecenter_x = float(a[2]) + w / 2center_y = float(a[3]) + h / 2a[2] = str(center_x / img_w)a[3] = str(center_y / img_h)a[4] = str(w / img_w)a[5] = str(h / img_h)b = a[1] + ' ' + a[2] + ' ' + a[3] + ' ' + a[4] + ' ' + a[5]print(b)data += b + '\n'with open(saved_path + '/' + filename + ".txt", 'w', encoding='utf-8') as f2:    f2.writelines(data)json_path = "/data/license_plate/blue"
midTxt_path = "/data/license_plate/blue/mid"
img_path = "/data/license_plate/blue"
saved_path = '/data/license_plate/save'if not os.path.exists(midTxt_path):os.mkdir(midTxt_path)filelist = os.listdir(json_path)
for file in filelist:old_dir = os.path.join(json_path, file)         if os.path.isdir(old_dir):continue                                    filetype = os.path.splitext(file)[1]            if(filetype != ".json"): continue               json2txt(old_dir, midTxt_path)txt2darknet(midTxt_path, img_path)
shutil.rmtree(midTxt_path)

如果想要矩形rectangle形状的目标框的json格式,再用以下代码转换:

# -*- coding: utf-8 -*-
import json
import cv2
from glob import glob
import ostxt_path = '/license_plate/save/'   # darknet格式
saved_path = '/data/license_plate/json/'
img_path = '/data/license_plate/blue/images/'files = glob(txt_path + "*.txt")
# files = os.listdir(txt_path)
# print(files)
files = [i.split('/')[-1].split('.txt')[0] for i in files]
print(files)for file in files:print(file)txt_file = txt_path + file + '.txt'img_file = img_path + file + '.jpg'if not os.path.exists(img_file):img_file = img_path + file + '.png'if not os.path.exists(img_file):img_file = img_path + file + '.jpeg'print(img_file)img = cv2.imread(img_file)# print(img)imgw = img.shape[1]imgh = img.shape[0]xi = []yi = []xa = []ya = []Label = []with open(txt_file, 'r') as f:             for line in f.readlines():line = line.strip('\n')            a = line.split(' ')  label = 'other'if a[0] == '0':label = 'plate_p'   elif a[0] == '1':label = 'green_plate'   elif a[0] == '2':label = 'yellow_plate_s'  Label.append(label)print(Label)centerx=float(a[1])*imgwcentery=float(a[2])*imghw=float(a[3])*imgwh=float(a[4])*imghxmin = centerx - w/2xmax= centerx + w/2ymin= centery - h/2ymax = centery + h/2xi.append(xmin)yi.append(ymin)xa.append(xmax)ya.append(ymax)# for j in range(0, len(files)):labelme_formate = {"version": "4.2.9","flags": {},"lineColor": [0, 255, 0, 128],"fillColor": [255, 0, 0, 128],"imagePath": os.path.split(img_file)[-1],"imageHeight": imgh,"imageWidth": imgw}labelme_formate['imageData'] = Noneshapes = []for i in range(0, len(xi)):s = {"label": Label[i], "line_color": None, "fill_color": None, "shape_type": "rectangle"}points = [[xi[i], yi[i]],[xa[i], ya[i]]]s['points'] = pointsshapes.append(s)labelme_formate['shapes'] = shapesjson.dump(labelme_formate, open(saved_path + file + ".json", 'w'), ensure_ascii=False, indent=2)print(saved_path + file + ".json")

欢迎私信一起学习交流!

车牌识别数据集(蓝牌、黄牌、绿牌)及相关转换代码相关推荐

  1. Python3.6+OpenCV3中国车牌识别( 蓝牌、绿牌、黄牌)

    点击下载:Python3.6+OpenCV3中国车牌识别( 蓝牌.绿牌.黄牌) 文件大小:81M 源码说明:带中文注释 文档说明:WORD格式 PDF说明提取码:61ic 操作视频:MP4格式 视频演 ...

  2. 【重磅推荐】中国车牌识别数据集(CBLPRD):China-Balanced-License-Plate-Recognition-Dataset-330k

    大家好!今天我向大家推荐一个由我创建的全新开源数据集:China-Balanced-License-Plate-Recognition-Dataset-330k.这是一个高质量.平衡的中国车牌识别数据 ...

  3. 车牌识别数据集_行人再识别数据集

    目前行人再识别的数据集比较常用的有:Market-1501. DukeMTMC-reID.CUHK03,后面有时间会上传如何处理数据集的代码.目前常使用的方式:数据集下有以下几个文件夹: train: ...

  4. 不需要分层的双层车牌识别新方案

    序言 车牌识别目前算是比较常见的OCR应用,各大停车场的门口均能看见,国内的车牌分为多种,有单层.有双层,有黄牌.蓝牌.绿牌等等,目前基本上都是基于检测加识别的方案进行,检测通常是一阶段的检测器:YO ...

  5. 我用AI回怼美女汽车销售系列[yolo车牌识别](四)

    上期回顾 上一期中,我们从数据增强角度,对车牌识别进行了mixup,彷射变换,模糊处理等,最终在ccpd数据集的测试集上面将t将top1准确率从0.9683提升到了0.991(提升了2.3个点),但是 ...

  6. 我用AI回怼美女汽车销售系列[yolo车牌识别](二)

    前期回顾: 在上一期介绍了事情的起因,为什么要做yolo车牌识别,以及最终的网络结构.(链接在这里:(141条消息) 我用AI回怼美女汽车销售系列[yolo车牌识别](一)_cjnewstar111的 ...

  7. HyperLPR3车牌识别-Linux/MacOS使用:C/C++库编译

    简介 HyperLPR在2023年初已经更新到了v3的版本,该版本与先前的版本一样都是用于识别中文车牌的开源图像算法项目,最新的版本的源码可从github中提取:https://github.com/ ...

  8. 智能驾驶 车牌检测和识别(三)《CRNN和LPRNet实现车牌识别(含车牌识别数据集和训练代码)》

    智能驾驶 车牌检测和识别(三)<CRNN和LPRNet实现车牌识别(含车牌识别数据集和训练代码)> 目录 智能驾驶 车牌检测和识别(三)<CRNN和LPRNet实现车牌识别(含车牌识 ...

  9. 智能驾驶 车牌检测和识别(五)《C++实现车牌检测和识别(可实时车牌识别)》

    智能驾驶 车牌检测和识别(五)<C++实现车牌检测和识别(可实时车牌识别)> 目录 智能驾驶 车牌检测和识别(五)<C++实现车牌检测和识别(可实时车牌识别)> 1. 前言 2 ...

最新文章

  1. 熬了一个通宵,终于把7千万个Key删完了
  2. 室内使用酒精消毒的时候一定要注意开窗!!!
  3. cuda nvprof 输出结果的理解和优化空间
  4. 通过Rman定期删除归档脚本
  5. 使用GridView做出列选择效果(获取动态生成的控件.鼠标点选GridView.Ajax控件)
  6. 关于用批处理写ftp上传文件
  7. Spark Scala当中reduceByKey的用法
  8. Python爬取网页中表格数据并导出为Excel文件
  9. 解决dpdk中出现IOMMU not found的问题
  10. Go实现 爬虫v0.1
  11. 灰色关联分析_(案例)相关分析之灰色关联度
  12. Pycharm中英文语言切换以及背景色更改问题
  13. 四 国内IP核相关企业及其分析
  14. 业务流程图(TFD)实例
  15. 如何查看电脑上曾记录的账号密码
  16. 以太坊的单位wei是什么?
  17. LMS学习管理系统综述
  18. 充分利用 cpu_充分利用设计学校(已更新)
  19. Ardunio开发实例-敲击传感器
  20. python之信用卡ATM(第五天)

热门文章

  1. PHP get数据 curl实现 申通快递查询
  2. 计算机软件硕士论文参考文献,计算机软件硕士论文参考文献.doc
  3. Mybatis 配置p6spy
  4. 四通OKI 5330SC 针式打印机驱动
  5. 菜鸟学ffmpeg音视频技术之6 mac截屏
  6. 关注年底“高送转”概念
  7. bezier曲线解析与代码(c++)
  8. 百度地图添加SVG矢量图标
  9. Project ‘cv_bridge‘ specifies ‘/usr/include/opencv‘ as an include dir, which is not found.的解决方法
  10. input 必填项(文本框text,文件file)