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

        The rapid development of science and technology has made automobiles an important means of transportation in modern society, and has promoted a new generation of intelligent transportation systems. License plate recognition technology, as the cornerstone of intelligent transportation, provides technical support for traffic management and makes people’s driving more convenient and fast. . Combining license plate recognition with computer software, and using digital image processing technology on the MATLAB platform, the collected vehicle images are operated on, and the license plate location and character segmentation are completed. 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 brought by the license plate tilt to character segmentation and recognition, a license plate tilt correction algorithm based on Sobel operator and Radon transform is proposed. First perform edge detection on the license plate graphic, and then perform Radon transformation on it to determine the inclination angle of the license plate in the horizontal and vertical directions. Combined with the inclination angles in different directions, bilinear interpolation and rotation correction are performed on the horizontally inclined and vertically inclined license plates respectively. and misalignment offset correction. Finally, the algorithm is compared with the license plate tilt correction algorithm proposed in the literature. The results show that the algorithm has a better effect on license plate tilt correction, high computing efficiency and insensitivity to stains, light, etc., and has a wide 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 perfectly complete image processing and realize the visualization of processed images. The specific steps of car license plate recognition mainly include image reading, preprocessing, license plate image positioning, tilt correction, character segmentation, and character recognition.

1.1 Image reading and preprocessing

        First, the imread function is applied to read the collected vehicle image with the license plate, and secondly, the image is preprocessed. Preprocessing operations include rearranging 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 acquired image pixels are too large, which will reduce the speed of the recognition system, or even freeze. . Therefore, in order to make the system run smoothly, improve the processing speed, and reset the pixels of the read image, 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 image may be too dark. Therefore, it is necessary to perform image enhancement processing on it to ensure that the license plate is bright and clear, so as to 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 the wrong license plate recognition. In China, license plates come in a variety of base 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 different. The state stipulates that the size of the small car license plate is 440mm × 140mm, and the color is white on a blue background. Morphological processing was performed on the color-screened images. 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 erosion operator, and use the imerode function to erode 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 merge into one and become smooth. The Canny operator is used to detect the edge of the image, and the aspect ratio of the connected domain is calculated, and the target is cut out according to the preset threshold. In the actual operation process, the intercepted target license plate is inclined. 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 directions, 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: first, convert the license plate image into a grayscale image, then perform edge detection in the horizontal and vertical directions, and then use the Radon transform to calculate the license plate tilt angle in the horizontal and vertical directions, and perform bilinear according to the tilt angle. Interpolated rotation correction and misalignment offset correction. The license plate inclination angle is divided into horizontal inclination angle and vertical inclination angle. After the original license plate image is converted, Radon transform is performed on it to obtain the vehicle inclination angle respectively.

Second, the 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. Forklift Steering Mechanism Modeling and Motion Simulation [J]. Automotive Practical Technology, 2019.

[2] Li Heng, Zheng Meng. Kinematics analysis of synchronous moving steering mechanism of dodging robot [J]. Mechanical Transmission, 2020.


For details, please click : 1341703358. The inclination angle of this paper is to perform bilinear interpolation rotation correction and dislocation offset correction for horizontally inclined and vertically inclined license plates respectively. Finally, the algorithm is compared with the license plate tilt correction algorithm proposed in the literature. The results show that the algorithm has a better effect on license plate tilt correction, high computing efficiency and insensitivity to stains, light, etc., and has a wide application prospect.

Guess you like

Origin blog.csdn.net/Jiangtagong/article/details/124131900