CCPD数据集

官网:https://github.com/detectRecog/CCPD

其它介绍:https://blog.csdn.net/qianbin3200896/article/details/103009221

CCPD (Chinese City Parking Dataset, ECCV)

provinces = ["皖", "沪", "津", "渝", "冀", "晋", "蒙", "辽", "吉", "黑", "苏", "浙", "京", "闽", "赣", "鲁", "豫", "鄂", "湘", "粤", "桂", "琼", "川", "贵", "云", "藏", "陕", "甘", "青", "宁", "新", "警", "学", "O"]
alphabets = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
             'X', 'Y', 'Z', 'O']
ads = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
       'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'O']

官网github给的3个列表最后都有一个字母O,不是数字0,当作结尾符号,因为中国车牌没有大写字母O,其实也没有大写字母I

省份简称里的"警" 公安内部车, "学" 驾校的车,车牌号没有小写字母

图片名称例子

name = "025-95_113-154&383_386&473-386&473_177&454_154&383_363&402-0_0_22_27_27_33_16-37-15.jpg"

print(len(name.split('-')))
print(name.split('-'))

结果如下

7
['025', '95_113', '154&383_386&473', '386&473_177&454_154&383_363&402', '0_0_22_27_27_33_16', '37', '15.jpg']

分割成了7段

  • 154&383_386&473:车牌框的第1、第4个点
  • 0_0_22_27_27_33_16:省份简称_字母_5个字母或数字组合

2020年绿牌数据

车牌号有8位 

train数量

5769
['./CCPD2020/ccpd_green/train/0245182291667-88_93-221&481_490&573-489&561_221&573_223&485_490&481-0_0_3_25_29_31_31_31-132-139.jpg',
 './CCPD2020/ccpd_green/train/0161783854167-93_97-255&489_465&566-465&566_258&553_255&489_461&495-0_0_3_24_27_26_31_30-148-296.jpg',
 './CCPD2020/ccpd_green/train/0133203125-90_102-228&515_426&583-426&583_240&582_228&518_413&515-0_0_5_24_29_33_33_30-121-38.jpg']
val数量
import glob

val_dir = './CCPD2020/ccpd_green/val'
val_imgPaths = glob.glob(val_dir+'/*.jpg')
print(len(val_imgPaths))
print(val_imgPaths[0])
1001
./CCPD2020/ccpd_green/val/04189453125-105_107-165&464_435&620-435&620_172&540_165&464_433&532-0_0_3_25_29_29_30_30-95-92.jpg
test数量
import glob

test_dir = './CCPD2020/ccpd_green/test'
test_imgPaths = glob.glob(test_dir+'/*.jpg')
print(len(test_imgPaths))
print(test_imgPaths[0])
5006
./CCPD2020/ccpd_green/test/00954022988505747-90_263-190&522_356&574-356&574_195&571_190&522_351&523-0_0_3_29_32_26_26_26-151-54.jpg
画框

用上面这张图为例

import os

imgPath = 'CCPD2020/ccpd_green/val/02-84_90-245&479_437&584-437&551_245&584_245&503_429&479-0_0_3_24_33_26_33_26-103-32.jpg'

print(os.path.splitext(imgPath))

打印如下

('CCPD2020/ccpd_green/val/02-84_90-245&479_437&584-437&551_245&584_245&503_429&479-0_0_3_24_33_26_33_26-103-32', '.jpg')

分割图片名称

import os

imgPath = 'CCPD2020/ccpd_green/val/02-84_90-245&479_437&584-437&551_245&584_245&503_429&479-0_0_3_24_33_26_33_26-103-32.jpg'

numName, _ = os.path.splitext(imgPath)
print(numName.split('-'))

打印如下

['CCPD2020/ccpd_green/val/02', '84_90', '245&479_437&584', '437&551_245&584_245&503_429&479', '0_0_3_24_33_26_33_26', '103', '32']

分割框的2个坐标

import os

imgPath = 'CCPD2020/ccpd_green/val/02-84_90-245&479_437&584-437&551_245&584_245&503_429&479-0_0_3_24_33_26_33_26-103-32.jpg'

numName, _ = os.path.splitext(imgPath)
x1_y1,x2_y2 = numName.split('-')[2].split('_')
print(x1_y1,x2_y2)
x1,y1 = x1_y1.split('&')
x2,y2 = x2_y2.split('&')
print(x1,y1,x2,y2)

打印如下

245&479 437&584
245 479 437 584

显示框

import os
import cv2

imgPath = 'CCPD2020/ccpd_green/val/02-84_90-245&479_437&584-437&551_245&584_245&503_429&479-0_0_3_24_33_26_33_26-103-32.jpg'

numName, _ = os.path.splitext(imgPath)
x1_y1,x2_y2 = numName.split('-')[2].split('_')
x1,y1 = x1_y1.split('&')
x2,y2 = x2_y2.split('&')

img = cv2.imread(imgPath)
cv2.rectangle(img, (int(x1),int(y1)), (int(x2), int(y2)), (0, 0, 255), 2)
cv2.imshow('img',img)
cv2.waitKey(10000)
cv2.destroyAllWindows()

车牌号名称
import os
import cv2

imgPath = 'CCPD2020/ccpd_green/val/02-84_90-245&479_437&584-437&551_245&584_245&503_429&479-0_0_3_24_33_26_33_26-103-32.jpg'

numName, _ = os.path.splitext(imgPath)
print(numName.split('-')[4])
print(numName.split('-')[4].split('_'))

打印如下

0_0_3_24_33_26_33_26
['0', '0', '3', '24', '33', '26', '33', '26']

换成号码

import os
import cv2

provinces = ["皖", "沪", "津", "渝", "冀", "晋", "蒙", "辽", "吉", "黑", 
             "苏", "浙", "京", "闽", "赣", "鲁", "豫", "鄂", "湘", "粤", 
             "桂", "琼", "川", "贵", "云", "藏", "陕", "甘", "青", "宁", 
             "新", "警", "学", "O"]
alphabets = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 
             'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
             'X', 'Y', 'Z', 'O']
ads = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 
       'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
       'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', 
       '8', '9', 'O']

imgPath = 'CCPD2020/ccpd_green/val/02-84_90-245&479_437&584-437&551_245&584_245&503_429&479-0_0_3_24_33_26_33_26-103-32.jpg'

numName, _ = os.path.splitext(imgPath)
index = [int(i) for i in numName.split('-')[4].split('_')]
first_index = index[0]
second_index = index[1]
last5_index = index[2:]

print(provinces[first_index],alphabets[second_index])
print([ads[i] for i in last5_index])

打印如下

皖 A
['D', '0', '9', '2', '9', '2']

拼成号码
import os
import cv2

provinces = ["皖", "沪", "津", "渝", "冀", "晋", "蒙", "辽", "吉", "黑", 
             "苏", "浙", "京", "闽", "赣", "鲁", "豫", "鄂", "湘", "粤", 
             "桂", "琼", "川", "贵", "云", "藏", "陕", "甘", "青", "宁", 
             "新", "警", "学", "O"]
alphabets = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 
             'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
             'X', 'Y', 'Z', 'O']
ads = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 
       'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
       'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', 
       '8', '9', 'O']

imgPath = 'CCPD2020/ccpd_green/val/02-84_90-245&479_437&584-437&551_245&584_245&503_429&479-0_0_3_24_33_26_33_26-103-32.jpg'

numName, _ = os.path.splitext(imgPath)
index = [int(i) for i in numName.split('-')[4].split('_')]
first_index = index[0]
second_index = index[1]
last5_index = index[2:]

s = ''
for i in [ads[i] for i in last5_index]:
    s += i

print(provinces[first_index]+alphabets[second_index]+s)

打印如下

皖AD09292

裁剪车牌保存
import os
import cv2

provinces = ["皖", "沪", "津", "渝", "冀", "晋", "蒙", "辽", "吉", "黑", 
             "苏", "浙", "京", "闽", "赣", "鲁", "豫", "鄂", "湘", "粤", 
             "桂", "琼", "川", "贵", "云", "藏", "陕", "甘", "青", "宁", 
             "新", "警", "学", "O"]
alphabets = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 
             'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
             'X', 'Y', 'Z', 'O']
ads = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 
       'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
       'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', 
       '8', '9', 'O']

imgPath = 'CCPD2020/ccpd_green/val/02-84_90-245&479_437&584-437&551_245&584_245&503_429&479-0_0_3_24_33_26_33_26-103-32.jpg'

numName, _ = os.path.splitext(imgPath)
index = [int(i) for i in numName.split('-')[4].split('_')]
first_index = index[0]
second_index = index[1]
last5_index = index[2:]
s = ''
for i in [ads[i] for i in last5_index]: s += i
imgName = provinces[first_index]+alphabets[second_index]+s+'.jpg'

x1_y1,x2_y2 = numName.split('-')[2].split('_')
x1,y1 = x1_y1.split('&')
x2,y2 = x2_y2.split('&')
img = cv2.imread(imgPath)
img_crop = img[int(y1):int(y2),int(x1):int(x2)]
cv2.imwrite(imgName,img_crop)

train/val/test的图片是否重名
import glob

train_dir = './CCPD2020/ccpd_green/train'
train_imgPaths = glob.glob(train_dir+'/*.jpg')

val_dir = './CCPD2020/ccpd_green/val'
val_imgPaths = glob.glob(val_dir+'/*.jpg')

test_dir = './CCPD2020/ccpd_green/test'
test_imgPaths = glob.glob(test_dir+'/*.jpg')

print(len(train_imgPaths)+len(val_imgPaths)+len(test_imgPaths))

merge = set()
merge.update(train_imgPaths,val_imgPaths,test_imgPaths)
print(len(merge))

打印如下

11776
11776

没有重名的图片

合并train/val/test文件夹

把train/val/test文件夹下的图片拷到green文件夹

11776
 同一车牌是否多次采集
import glob
import os
import cv2

provinces = ["皖", "沪", "津", "渝", "冀", "晋", "蒙", "辽", "吉", "黑", "苏", "浙", "京", "闽", "赣", "鲁", "豫", "鄂", "湘", "粤", 
             "桂", "琼", "川", "贵", "云", "藏", "陕", "甘", "青", "宁", "新", "警", "学", "O"]
alphabets = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
             'X', 'Y', 'Z', 'O']
ads = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
       'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'O']

def get_chepai(path):
       numName, _ = os.path.splitext(path)
       index = [int(i) for i in numName.split('-')[4].split('_')]
       first_index = index[0]
       second_index = index[1]
       last5_index = index[2:]
       s = ''
       for i in [ads[i] for i in last5_index]: s += i
       return provinces[first_index]+alphabets[second_index]+s

green_dir = './CCPD2020/ccpd_green/green'
green_imgPaths = glob.glob(green_dir+'/*.jpg')
print('图片数量:',len(green_imgPaths))

chepai = set()
for imgPath in green_imgPaths:
    chepai.add(get_chepai(imgPath))
print('车牌数量:', len(chepai))

打印如下

图片数量: 11776
车牌数量: 3298

同一车牌采集了多次

批量裁剪车牌
import glob
import os
import cv2
       
provinces = ["皖", "沪", "津", "渝", "冀", "晋", "蒙", "辽", "吉", "黑", "苏", "浙", "京", "闽", "赣", "鲁", "豫", "鄂", "湘", "粤", 
             "桂", "琼", "川", "贵", "云", "藏", "陕", "甘", "青", "宁", "新", "警", "学", "O"]
alphabets = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
             'X', 'Y', 'Z', 'O']
ads = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
       'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'O']

def get_chepai(path):
    numName, _ = os.path.splitext(path)
    index = [int(i) for i in numName.split('-')[4].split('_')]
    first_index = index[0]
    second_index = index[1]
    last5_index = index[2:]
    s = ''
    for i in [ads[i] for i in last5_index]: s += i
    return provinces[first_index]+alphabets[second_index]+s

def get_box(path):
    numName, _ = os.path.splitext(path)
    x1_y1,x2_y2 = numName.split('-')[2].split('_')
    x1,y1 = x1_y1.split('&')
    x2,y2 = x2_y2.split('&')
    return [int(x1),int(y1),int(x2),int(y2)]

green_dir = './CCPD2020/ccpd_green/green'
green_imgPaths = glob.glob(green_dir+'/*.jpg')
print('图片数量:',len(green_imgPaths))

name2num = dict()
for imgPath in green_imgPaths:
    chepai = get_chepai(imgPath)
    if chepai in name2num: name2num[chepai] += 1
    else: name2num[chepai] = 0

crop_dir = './CCPD2020/ccpd_green/green_crop/'
for index,imgPath in enumerate(green_imgPaths):
    chepai = get_chepai(imgPath)
    img = cv2.imread(imgPath)
    x1,y1,x2,y2 = get_box(imgPath)
    img_crop = img[y1:y2,x1:x2]
    cv2.imwrite(crop_dir+'{}_{}.jpg'.format(chepai,name2num[chepai]),img_crop)
    name2num[chepai] -= 1
    if index % 2000==0: print(index)
图片数量: 11776
0
2000
4000
6000
8000
10000
import glob

crop_dir = './CCPD2020/ccpd_green/green_crop'
crop_imgPaths = glob.glob(crop_dir+'/*.jpg')
print('裁剪的车牌图片数量:',len(crop_imgPaths))
裁剪的车牌图片数量: 11776

批量裁剪成94x24大小
import glob
import os
import cv2
       
provinces = ["皖", "沪", "津", "渝", "冀", "晋", "蒙", "辽", "吉", "黑", "苏", "浙", "京", "闽", "赣", "鲁", "豫", "鄂", "湘", "粤", 
             "桂", "琼", "川", "贵", "云", "藏", "陕", "甘", "青", "宁", "新", "警", "学", "O"]
alphabets = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
             'X', 'Y', 'Z', 'O']
ads = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
       'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'O']

def get_chepai(path):
    numName, _ = os.path.splitext(path)
    index = [int(i) for i in numName.split('-')[4].split('_')]
    first_index = index[0]
    second_index = index[1]
    last5_index = index[2:]
    s = ''
    for i in [ads[i] for i in last5_index]: s += i
    return provinces[first_index]+alphabets[second_index]+s

def get_box(path):
    numName, _ = os.path.splitext(path)
    x1_y1,x2_y2 = numName.split('-')[2].split('_')
    x1,y1 = x1_y1.split('&')
    x2,y2 = x2_y2.split('&')
    return [int(x1),int(y1),int(x2),int(y2)]

green_dir = './CCPD2020/ccpd_green/green'
green_imgPaths = glob.glob(green_dir+'/*.jpg')
print('图片数量:',len(green_imgPaths))

name2num = dict()
for imgPath in green_imgPaths:
    chepai = get_chepai(imgPath)
    if chepai in name2num: name2num[chepai] += 1
    else: name2num[chepai] = 0

crop_dir = './CCPD2020/ccpd_green/green_crop_94x24/'
for index,imgPath in enumerate(green_imgPaths):
    chepai = get_chepai(imgPath)
    img = cv2.imread(imgPath)
    x1,y1,x2,y2 = get_box(imgPath)
    img_crop = img[y1:y2,x1:x2]
    img_crop = cv2.resize(img_crop,(94,24))
    cv2.imwrite(crop_dir+'{}_{}.jpg'.format(chepai,name2num[chepai]),img_crop)
    name2num[chepai] -= 1
    if index % 2000==0: print(index)

crop_imgPaths = glob.glob(crop_dir+'/*.jpg')
print('裁剪的车牌图片数量:',len(crop_imgPaths))

打印结果

图片数量: 11776
0
2000
4000
6000
8000
10000
裁剪的车牌图片数量: 11776

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值