Python handles license plate character data

Source: Internet
Author: User

In order to use depth learning to train a character recognition model for license plate recognition, the first problem to be solved is to deal with the data problem, in order to be able to pass the data into the network for training, I use the One_hot code, the specific details are as follows:

First prepare the DataSet: part of your own dataset, part of the EASYPR dataset (the latter 500 images as test sets, others as the training set) 67617
Category: 65 class
0-9 a total of 10 classes, A-Z a total of 24 classes (except O,i),

Chinese characters have a total of 31 categories (' e ', ' gan ', ' gan ', ' gui ', ' laurel ', ' black ', ' Shanghai ', ' ji ', ' ji ', ' Jin ', ' Jin ', ' Jing ', ' Liao ', ' Lu ', ' Meng ', ' min ', ' ning ', ' Qing ', ' June ', ' Shan ', ' su ', ' Wan ', ' Xiang ', ' new ', ' Yu ' , ' Yu ', ' Yue ', ' Yun ', ' hide ', ' zhe '

Normalized:
The image size of each input character is normalized to 20x20 and converted to grayscale;
Name format for pictures:
Name the picture in the dataset as Label.num.jpg (for example: 0.0.jpg) to make it easier to get the label and picture of the picture;
The province uses phonetic string storage:
Chuan.0.jpg
tags use one-hot encoding:
After the image category label is obtained, it is converted into one-hot encoding;
Data format to be processed into. NPY:
Use the NumPy function to form a data file using the image data and labels that were previously processed. Npy.

Shows some of the processed data:

Figure 1 Picture of the license plate character

Figure 2 The label that corresponds to the license plate character picture is category

The core code is as follows:

def label_img (IMG):

Label = Np.eye (Dtype=int)
word_lable = img

Label = Np.eye (Dtype=int)
word_lable = img

Def create_train_data ():
Training_data = []
For Fpathe, dirs, FS in TQDM (Os.walk (Train_dir)):
For f in FS:
img = Cv2.imread (Os.path.join (Fpathe, F), Cv2. Imread_grayscale)
Image_name = Os.path.join (Fpathe, F). Split (' \ ') [2]
Image=image_name.split ('. ') [0]
Label = label_img (image)
img = Cv2.resize (IMG, (img_size, img_size))
Training_data.append ([Np.array (IMG), Np.array (label)])
Shuffle (Training_data)
Np.save (' Path, Training_data ')
Return Training_data



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.