- 车牌字符标注的转换:
CCPD标注:0217-0_3-259&496_473&581-469&578_259&581_263&499_473&496-0_0_11_32_19_31_33-122-1.jpg
自己的数据标注:CD238_22A3Y5W9.jpg - 车牌定位标注转换:
CCPD标注:0217-0_3-259&496_473&581-469&578_259&581_263&499_473&496-0_0_11_32_19_31_33-122-1.jpg
自己的标注:单独的Annotation文件txt 存放x1,y1,x2,y2
代码:
import os from os import listdir, getcwd from os.path import join def funForCh(filepath): pathDir = os.listdir(filepath) for allDir in pathDir: # print('-------processing image ---------'+allDir) img_name = os.path.join(filepath, allDir) if os.path.isfile(img_name): temp = img_name.split('/')[-1].split('.')[0].split('_')[1] lbl = temp[0:2] temp = temp[2:] ads = {'A':0, 'B':1, 'C':2, 'D':3, 'E':4, 'F':5, 'G':6, 'H':7, 'J':8, 'K':9, 'L':10, 'M':11, 'N':12, 'P':13, 'Q':14, 'R':15, 'S':16, 'T':17, 'U':18, 'V':19, 'W':20, 'X':21, 'Y':22, 'Z':23, '0':24, '1':25, '2':26, '3':27, '4':28, '5':29, '6':30, '7':31, '8':32, '9':33, 'O':34} for perChar in temp: # if(perChar.isalpha()): lbl += '_'+str(ads[perChar]) print(allDir+"===="+lbl) def funForLoc(filepath): pathDir = os.listdir(filepath) for allDir in pathDir: # print('-------processing image ---------'+allDir) img_name = os.path.join(filepath, allDir) # myiname = img_name.split('/')[-1].rsplit('.', 1)[0] # print(myiname) if os.path.isfile(img_name): (image_id,ext) = os.path.splitext(allDir) in_file = open('/DATACENTER1/zt/data_LP/LP_RPnet/Annotations/%s.txt' % (image_id)) line = in_file.readline().split() # line=[xmin,ymin,xmax,ymax] [leftUp, rightDown] = [[int(line[0]), int(line[1])], [int(line[2]), int(line[3])]] # print(leftUp[0]) # print(leftUp+rightDown) if __name__ == '__main__': filepath = '/DATACENTER1/zt/data_LP/LP_RPnet/Images' # destpath = 'LP2' # funForCh(filepath) funForLoc(filepath)
结果预览:
结果预览:
# tps = [[int(line[0]), int(line[1])], [int(line[2]), int(line[3])]]#[[int(eel) for eel in el.split('&')] for el in iname[2].split('_')] # for dot in tps: # cv2.circle(img, (int(dot[0]), int(dot[1])), 2, (0, 0, 255), 2) # cv2.imwrite("CCPD/test/"+myiname+"_new.jpg", img)