Research on license plate A recognition and detection in complex and harsh environment based on Matlab

         The rapid development of science and technology makes automobiles an important means of transportation in modern society, and promotes a new generation of intelligent transportation systems. As the cornerstone of intelligent transportation, license plate recognition technology provides technical support for traffic management and makes people's driving more convenient and faster. . Combining license plate recognition with computer software, under the MATLAB platform, digital image processing technology is used to perform related operations on the collected vehicle images, and complete the positioning and character segmentation of the license plate. At the same time, the improved template matching recognition method is applied to character recognition, so that the system can correctly recognize the characters of the license plate, and realize the purpose of automatically recognizing the license plate. Aiming at the inconvenience caused by license plate tilt to character segmentation and recognition, a license plate tilt correction algorithm based on Sobel operator and Radon transform is proposed. First, edge detection is performed on the license plate image, and then Radon transformation is performed on it to determine the inclination angle of the license plate in the horizontal and vertical directions, and the bilinear interpolation rotation correction is performed on the license plate with horizontal inclination and vertical inclination according to the inclination angle in different directions. and misalignment offset correction. Finally, this algorithm is compared with the license plate tilt correction algorithm proposed in the literature, and the results show that the license plate tilt correction using this algorithm is better, the calculation efficiency is high, and it is not sensitive to stains, light, etc., and has a broad application prospect.

1. Algorithm Analysis

Overall System Design The license plate recognition system designed in this paper uses MATLAB software for programming design and simulation experiments. MATLAB software has the functions of numerical analysis, calculation, design control system, etc., and has powerful library functions in digital image processing, which can complete image processing excellently and realize the visual operation of image processing. The specific steps to recognize the license plate mainly include image reading, preprocessing, license plate image positioning, tilt correction, character segmentation, and character recognition.

1.1 Image reading and preprocessing

        Firstly, the imread function is used to read the collected vehicle image with the license plate, and secondly, the image is preprocessed. Preprocessing operations include resetting of image pixels and image enhancement. In practical applications, in order to ensure the clarity of the image, high-resolution cameras, mobile phones and other acquisition devices are often used, and the captured image pixels are too large, which will slow down the speed of the recognition system and even cause freezes. . Therefore, in order to make the system run smoothly and improve the processing speed, the pixels of the read image are reset, and the imresize function is used to unify the image size to 520×390. At the same time, due to the influence of the external environment, the collected vehicle images may be too dark. Therefore, it is necessary to carry out image enhancement processing to ensure that the license plate is bright and clear, and prepare for the follow-up work.

1.2 License plate image positioning

        The collected vehicle images often have complex backgrounds, so it is necessary to accurately locate the license plate, which is crucial for subsequent operations. If the positioning is wrong or not accurate enough, it will directly lead to license plate recognition errors. In China, license plates come in a variety of background colors, including yellow, blue, white, black and green. At the same time, the license plate has a fixed outline size, and the color and size of the license plate of different models are all different. The state stipulates that the size of a small car license plate is 440mm×140mm, and the color is white on a blue background. Morphological processing is performed on the color-filtered image. The morphological operations of binary images mainly include erosion, dilation, opening and closing operations, which are used to extract image target components. It is used here to simplify the data information of the license plate image. First, call the sterl function in MATLAB to construct the corrosion operator, and use the imerode function to corrode the information in the non-license plate area. Then use the closing operation function imclose to remove the noise area, bridge the narrow gap, fill the hole, and make the target blend into one and become smooth. Edge detection is performed on the image through the Canny operator, and the aspect ratio of the connected domain is calculated, and the target is intercepted according to the preset threshold. In the actual operation process, the intercepted target license plate is tilted. In order to facilitate the follow-up work, it is necessary to use the projection method to correct it here. Then scan the target in the row and column direction, use the projection method to divide the specific position of the license plate, complete the precise positioning, and avoid the interference of redundant background.

 1.3 License plate correction

        The license plate tilt correction algorithm is as follows: firstly, the license plate image is converted into a grayscale image, and then the upper edge detection is performed in the horizontal and vertical directions, and then the license plate is calculated using the Radon transformation in the horizontal and vertical directions. Interpolation rotation correction and misalignment offset correction. The calculation of license plate inclination angle is divided into horizontal inclination angle and vertical inclination angle. After the original license plate image is converted, Radon transformation is performed on it to obtain the vehicle inclination angle respectively.

2. Code implementation

%=====================读入图片================================
[fn,pn,fi]=uigetfile('*.jpg','选择图片');
if isequal(fn,0)||isequal(pn,0)||isequal(fi,0)
    errordlg('您还没有选取图片!!','温馨提示');%如果没有输入,则创建错误对话框
    return;
end
I=imread([pn fn]);figure,imshow(I);title('原始图像');%显示原始图像
chepailujing=[pn fn];
I_bai=I;
[PY2,PY1,PX2,PX1]=caitu_fenge(I);

% I=rgb2hsv(I);
% [PY2,PY1,PX2,PX1]=caitu_tiqu(I,I_bai);%用HSI模型识别蓝色,用rgb模型识别白色
%================分割车牌区域=================================

%===============车牌区域根据面积二次修正======================
[PY2,PY1,PX2,PX1,threshold]=SEC_xiuzheng(PY2,PY1,PX2,PX1);
%==============更新图片=============================
Plate=I_bai(PY1:PY2,PX1:PX2,:);%使用caitu_tiqu
%==============考虑用腐蚀解决蓝色车问题=============
bw=Plate;figure,imshow(bw);title('车牌图像');%hsv彩图提取图像
%==============这里要根据图像的倾斜度进行选择这里选择的图片20090425686.jpg
bw=rgb2gray(bw);figure,imshow(bw);title('灰度图像');
%================倾斜校正======================
qingxiejiao=rando_bianhuan(bw);
bw=imrotate(bw,qingxiejiao,'bilinear','crop');figure,imshow(bw);
title('倾斜校正');%取值为负值向右旋转
%==============================================
bw=im2bw(bw,graythresh(bw));%figure,imshow(bw);
bw=bwmorph(bw,'hbreak',inf);%figure,imshow(bw);
bw=bwmorph(bw,'spur',inf);%figure,imshow(bw);title('擦除之前');
bw=bwmorph(bw,'open',5);%figure,imshow(bw);title('闭合运算');
bw = bwareaopen(bw, threshold);figure,imshow(bw);title('擦除');
%==========================================================
bw=~bw;figure,imshow(bw);title('擦除反色'); 
%=============对图像进一步裁剪,保证边框贴近字体===========
bw=touying(bw);figure;imshow(bw);title('Y方向处理');
bw=~bw;
bw = bwareaopen(bw, threshold);
bw=~bw;%figure,imshow(bw);title('二次擦除');
[y,x]=size(bw);%对长宽重新赋值
%=================文字分割=================================
fenge=shuzifenge(bw,qingxiejiao);
[m,k]=size(fenge);
%=================显示分割图像结果========================= 
figure;
for s=1:2:k-1
    subplot(1,k/2,(s+1)/2);imshow(bw( 1:y,fenge(s):fenge(s+1)));
end
%================ 给七张图片定位===============桂AV6388
han_zi  =bw( 1:y,fenge(1):fenge(2));
zi_mu   =bw( 1:y,fenge(3):fenge(4));
zm_sz_1 =bw( 1:y,fenge(5):fenge(6));
zm_sz_2 =bw( 1:y,fenge(7):fenge(8));  
shuzi_1 =bw( 1:y,fenge(9):fenge(10)); 
shuzi_2 =bw( 1:y,fenge(11):fenge(12)); 
shuzi_3 =bw( 1:y,fenge(13):fenge(14)); 
%==========================识别====================================
%======================把修正数据读入==============================
xiuzhenghanzi =   imresize(han_zi, [110 55],'bilinear');
xiuzhengzimu  =   imresize(zi_mu,  [110 55],'bilinear');
xiuzhengzm_sz_1=  imresize(zm_sz_1,[110 55],'bilinear');
xiuzhengzm_sz_2 = imresize(zm_sz_2,[110 55],'bilinear');
xiuzhengshuzi_1 = imresize(shuzi_1,[110 55],'bilinear');
xiuzhengshuzi_2 = imresize(shuzi_2,[110 55],'bilinear');
xiuzhengshuzi_3 = imresize(shuzi_3,[110 55],'bilinear');

references

【1】Guan Liangliang, Fan Xu. Modeling and Motion Simulation of Forklift Steering Mechanism [J]. Automotive Practical Technology, 2019.

【2】Li Heng, Zheng Meng. Kinematics Analysis of Synchronously Moving Steering Mechanism of Dodge Robot[J]. Mechanical Transmission, 2020.


, this paper performs bilinear interpolation rotation correction and dislocation offset correction on the horizontally inclined and vertically inclined license plates respectively. Finally, this algorithm is compared with the license plate tilt correction algorithm proposed in the literature, and the results show that the license plate tilt correction using this algorithm is better, the calculation efficiency is high, and it is not sensitive to stains, light, etc., and has a broad application prospect.

 

Guess you like

Origin blog.csdn.net/Mawithvision/article/details/129602371