License Plate positioning is the first and most important step in License Plate Recognition.
Due to the diversity and different colors of Chinese license plates, coupled with frequent damage to license plates, and too many interference factors around license plates, these are all difficulties in license plate locating.
Here, we first use the simplest algorithm to describe License Plate positioning, as well as its defects and improvements.
I. Projection Method
1. Vehicle Image Information Acquisition
2. HSV Color Conversion
Convert RGB data to HSV space image data
Hsv zation (image, hsv, width, height );
3,HSV Color Filtering
Set the background color threshold of a blue license plate for color filtering.
Blue license plate
H value range: 190 ~ 245
S value range: 0.35 ~ 1
V value range: 0.3 ~ 1
The filtered image is as follows:
4. Noise Processing
After filtering, it is generally necessary to perform de-noise processing. Here it is not obvious early. If there are blue objects around the license plate, the noise will be very obvious.
Here we use average noise removal. Some isolated White points are removed. The effect is as follows:
5. Edge Detection
After Noise Removal, edge detection is performed. The purpose of edge detection is to highlight sudden changes in license plate information, because the license plate background and font color are separated;
This is also designed to prevent interference from objects with the same color as the license plate background, especially the vehicle color, because after edge detection, the color of the car body does not have so many jump interference or is different from that of the license plate, the color of the car body can be filtered to remove interference.
6. Determine the license plate location
Determine the license plate position through horizontal projection and vertical projection.
(Here, the projection method has a lot of defects, especially when there are other background information in addition to the vehicle around the license plate, which is improved in the following method)
7. image capturing of license plates
II,Example of defect locating Using Projection Method
1. Read license plate images with complex backgrounds
2. HSV Filtering
After HSV filtering, You can see obvious interference information, the railing behind the vehicle, the same color as the vehicle
3. Mean Value Denoising
After Noise Removal, although most of the noise is removed, the railing is still clear
4. Edge Detection
The image after edge detection and the shape features of the license plate area give us some inspiration for solving projection defects.
5. mispositioning after projection
6. Incorrect License Plate Extraction
The half body does not match the license plate features.
From this we can see that in License Plate Recognition with complex backgrounds, global projection cannot suppress interference, which is more obvious in the following yellow license plate examples;
The projection method is simple, but it can be used only when the overall vehicle information is not complex background information.
Iii. Method for Determining candidate regions
This method gives up projection, directly traverses the entire image information, and checks the length and width of each Unicom domain. When the width and height ratio of the license plate is met, it is selected as the candidate region, the subsequent processing process is used to determine whether normal characters can be extracted.
The first two steps are the same as above.
1. HSV space conversion
2. Mean Value Denoising
3. horizontal expansion
Objective: To form a connection domain as much as possible
4. Edge Detection
Edge detection is also not needed. Here we mainly consider minimizing the number of operations in the white point traversal of the image.
5. screening candidate regions
Filtering candidate regions, which is the main part of the difference projection method,
It can be seen that there are several candidate regions, about four, and the plate in the middle has obvious rectangular characteristics, which meets a certain length-width ratio. The other three regions do not have such features, in the screening process, discard it.
The filtering method uses depth-first traversal. When a connection domain is connected, the length and height of the domain are recorded, and the threshold value is set. When the aspect ratio is met, the candidate region is selected, otherwise, we will discard it. Of course, we can also add other algorithms, such as detection hops. After all, the license plate area does not necessarily match this ratio.
The porn box is the filtered area:
The connection domain filtering function is as follows:
int find_connected_region_location(struct BMP_img *img, unsigned char *src, int xthreashold, int ythreashold, float rateLow, float rateHigh){int i,j;int x1, y1, x2, y2;int width;int height;unsigned char *temp;//int queue_count;int head, rear;struct XY_Queue *queue;static int direction[4][2]={{1, 0}, {-1, 0}, {0, 1}, {0, -1}};width = img->width;height = img->height;queue = (struct XY_Queue *)malloc(sizeof(struct XY_Queue) * width * height);temp = (unsigned char *)malloc(width * height * sizeof(unsigned char));if(temp == NULL){printf("find_connected_region_location mem alloc fail\n");return -1;}memcpy(temp, src, width * height);head = rear = 0;img->region_num = 0;for(i = 0; i < height; i++)for(j = 0; j < width; j++){if(temp[i * width + j] == 255){queue[rear].x = j;queue[rear].y = i;rear ++;temp[i * width + j] = 0;img->pre_region[img->region_num].x1 = j;img->pre_region[img->region_num].x2 = j;img->pre_region[img->region_num].y1 = i;img->pre_region[img->region_num].y2 = i;if(img->region_num > CAN_REGION_NUM){printf("over the CAN_REGION_NUM\n");return -1;}while(head < rear){x1 = queue[head].x;y1 = queue[head].y;head ++;if(x1 < img->pre_region[img->region_num].x1)img->pre_region[img->region_num].x1 = x1;else if(x1 > img->pre_region[img->region_num].x2)img->pre_region[img->region_num].x2 = x1;if(y1 < img->pre_region[img->region_num].y1)img->pre_region[img->region_num].y1 = y1;else if(y1 > img->pre_region[img->region_num].y2)img->pre_region[img->region_num].y2 = y1;for(i = 0; i < 4; i++){x2 = x1 + direction[i][0];y2 = y1 + direction[i][1];if(x2 > 0 && x2 < width && y2 > 0 && y2 < height && temp[y2 * width + x2]){temp[y2 * width + x2] = 0;queue[rear].x = x2;queue[rear].y = y2;rear ++;}}}if((img->pre_region[img->region_num].x2 - img->pre_region[img->region_num].x1 > xthreashold) && (img->pre_region[img->region_num].y2 - img->pre_region[img->region_num].y1 > ythreashold)){img->pre_region[img->region_num].width = img->pre_region[img->region_num].x2 - img->pre_region[img->region_num].x1 + 1;img->pre_region[img->region_num].height = img->pre_region[img->region_num].y2 - img->pre_region[img->region_num].y1 + 1;img->pre_region[img->region_num].rate = (float)img->pre_region[img->region_num].width/img->pre_region[img->region_num].height;if((img->pre_region[img->region_num].width < img->width / 2) && (img->pre_region[img->region_num].height < img->height / 2))if((img->pre_region[img->region_num].rate > rateLow) && (img->pre_region[img->region_num].rate < rateHigh)){if(img->pre_region[img->region_num].x2 + PRE_LOCATION_BIAS > img->width)img->pre_region[img->region_num].x2 = img->width;elseimg->pre_region[img->region_num].x2 += PRE_LOCATION_BIAS;if(img->pre_region[img->region_num].x1 - PRE_LOCATION_BIAS < 0)img->pre_region[img->region_num].x1 = 0;elseimg->pre_region[img->region_num].x1 -= PRE_LOCATION_BIAS;if(img->pre_region[img->region_num].y2 + PRE_LOCATION_BIAS > img->height)img->pre_region[img->region_num].y2 = img->height;elseimg->pre_region[img->region_num].y2 += PRE_LOCATION_BIAS;if(img->pre_region[img->region_num].y1 - PRE_LOCATION_BIAS < 0)img->pre_region[img->region_num].y1 = 0;elseimg->pre_region[img->region_num].y1 -= PRE_LOCATION_BIAS;img->pre_region[img->region_num].width = img->pre_region[img->region_num].x2 - img->pre_region[img->region_num].x1 + 1;img->pre_region[img->region_num].height = img->pre_region[img->region_num].y2 - img->pre_region[img->region_num].y1 + 1;img->region_num++;}}}}free(temp);temp = NULL;return 0;}
6. image capturing of the license plate area
Iv. Yellow license plate Detection
1. vehicle image information
2. HSV filtering and Segmentation
Because the license plate color and the vehicle color are consistent and there is a large amount of noise information, it is no longer possible to separate the license plate information from the global projection,
Here, we only use the aspect ratio of candidate regions for rectangular segmentation. Some areas that match the ratio but are not license plates will certainly appear. We must distinguish them in the subsequent processing or add a function to determine the hop variation pattern.
3. Noise Reduction
4. Expansion
6. Edge Detection
7. Screening of connected domains in candidate regions
As you can see, the yellow box is where the candidate area is located.
8. Intercept candidate regions
This candidate region only complies with the aspect ratio and needs to be processed separately to remove areas not license plates.
V. Summary
License Plate positioning is complicated, but it is the most important factor for License Plate Recognition. I think it is the most influential factor in License Plate Recognition. Although complicated, there are various methods.
This is only my personal hobby and research. I hope all of you will continue to make criticism and suggestions. Your encouragement gives me the courage to stick to it.
I hope I can discuss it together:
QQ: 105060236105060236