Re-debugging: License Plate Recognition

Source: Internet
Author: User

I have been busy with R & D tasks in the past year and have to move on to Silverlight 3D learning. In R & D, image recognition of license plates, number of heavy vehicles and bridges (mainly used for overload detection), and image recognition of some mining seeds are required. This section describes image recognition for license plates.

In fact, the license plate image recognition technology has been relatively mature, theoretically nothing more than the following steps:

Grayscale: The original license plate image is preprocessed to convert the color image into a black image and a black image. Then, the gray value that does not meet the specified threshold value is filtered.
License Plate positioning: This is one of the technical difficulties. Based on my experience, positioning the license plate location is actually 60% successful for accurate identification of the license plate. Many License Plate Recognition products reserve many configuration parameters for License Plate positioning, such as the position parameter of the original image, the length and width ratio of the license plate, and the size, these are all to improve the accuracy of License Plate positioning.
Character Segmentation: The license plate is located after the character segmentation. the recognition process I use is: noise reduction processing => border blur => finding the first six closed images from right to left => the remaining closed images are integrated into one image for Chinese character recognition.
Character Recognition: Template matching is performed based on the Character template. Therefore, a corresponding character template must be created in advance. Many parameters can be configured for Character Recognition Based on images to greatly improve the character recognition rate. For example, you can specify the characters in the vehicle license plate header and the recognition priority of the characters in the license plate.

The following uses a yellow car number as an example to check the license plate recognition effect.
1. Shows the original image:

2. Define the License Plate Recognition area. In this example, 10% of the upper and lower sides are cut out:

 

Get_image_pointer1 (fullimage, pointer, type, width, height)
Gen_rectangle1 (rectangle, height * 0.1 , Width * 0.1 , Height * 0.9 , Width * 0.9 )
Performance_domain (fullimage, rectangle, image)

 

Check the cropping result:

 

3. grayscale the selected area to facilitate subsequent processing:

Decompose3 (image, red, green, blue)
Trans_from_rgb (red, green, blue, hue, saturation, intensity, ' HSV ' )

 

After grayscale:

4. grayscale threshold filtering. In this example, only the area with a gray value between 100 and 255 is selected. You can set the gray value based on the actual situation and then perform noise reduction:

 

Threshold (saturation, highsaturation, 100 , 255 )
Remove_noise_region (highsaturation, outputregion, ' N_48 ' )

 

The effect of filtering noise reduction is very similar to the actual location!

5. Find the desired region based on the predefined license plate length/width ratio:

 

Code

Connection (outputregion, connectedregions1)
Closing_rectangle1 (connectedregions1, regionclosing1, 10 , 10 )
Select_shape (regionclosing1, aselectedregions, ' Area ' , ' And ' , 3000 , 9000 )
Select_shape (aselectedregions, hselectedregions, ' Height ' , ' And ' , 30 , 90 )
Select_shape (hselectedregions, selectedregions, ' Width ' , ' And ' , 60 , 180 )

 

As follows:

6. grayscale images of the license plate area are displayed:

Performance_domain (hue, selectedregions, huehighsaturation)

The effect is as follows. Is it consistent with the actual location!

 

7. filter the threshold value for the exact area of the above-mentioned license plate to remove the black border around the license plate:

Threshold (huehighsaturation, region, 30 , 50 )

As follows:

8. Fill in characters insteadAlgorithmSelected internal region:

Closing_rectangle1 (Region, regionfillup, 20 , 20 )

After filling, the related information is as follows:

9. Based on the selected area, load the area from the original image:

Performance_domain (image, regionfillup, trucktagimage)

As shown below, the license plate appears again

10. Determine the offset angle of Characters in the recognition area. The angle varies depending on the camera position. (This step can be omitted Based on the segmentation algorithm ):

Connection (regionfillup, connectedreducedregions)
Text_line_orientation (connectedreducedregions, trucktagimage, 30 , - 0.523599 , 0.523599 , Orientationangle)

11. display the real image of the license plate location to facilitate debugging:

Dev_display (trucktagimage)

As follows:

12. Separate characters to filter out non-character areas:

Code

Segment_characters (regionfillup, trucktagimage, imageforeground, regionforeground, ' Local_auto_shape ' , ' False ' , ' False ' , ' Medium ' , 12 , 30 , 2 , 10 , Usedthreshold)
Select_characters (regionforeground, regioncharacters, ' False ' , ' Medium ' , 12 , 30 , ' False ' , ' False ' , ' Variable_width ' , ' False ' , ' Medium ' , ' False ' , 15 , ' Completion ' )
Closing_rectangle1 (regioncharacters, regioncharactersclosing, 1 , 2 )

As shown in the following figure, is it a step away from real identification!

13. sort by the coordinates in the upper left corner of each split area (mainly to facilitate character recognition from the right to the left ):

Connection (regioncharactersclosing, connectedregioncharactersclosing)
Sort_region (connectedregioncharactersclosing, sortedregions, ' First_point ' , ' False ' , ' Column ' )

14. How do I display the separated character areas? The characters are separated successfully! :

15. Load the character template, perform character recognition from the right to the left, and draw the recognition result above the corresponding character position: <./P>

Code

Read_ocr_class_mlp ( ' D:/mvtec/Halcon/OCR/Industrial_0-9.omc. ' , Ocrhandle)
For Index: =   1 To 5 By 1
If (Number > = Index)
Selectedsortedregion: = Sortedregions [Index]
Do_ocr_single_class_mlp (selectedsortedregion, image, ocrhandle, 1 , Class, confidence)
Smallest_rectangle1 (selectedsortedregion, row1, column1, row2, column2)
Set_tposition (windowid, row1 -   30 , (Column2 + Column1) *   0.5   -   5 )
Write_string (windowid, class [ 0 ])
Dev_display (selectedsortedregion)
Endif
Endfor
Clear_ocr_class_mlp (ocrhandle)
If (Number > 5 )
Read_ocr_class_mlp ( ' D:/mvtec/Halcon/OCR/Industrial_0-9A-Z.omc. ' , Ocrhandle)
Selectedsortedregion: = Sortedregions [ 6 ]
Do_ocr_single_class_mlp (selectedsortedregion, image, ocrhandle, 1 , Class, confidence)
Smallest_rectangle1 (selectedsortedregion, row1, column1, row2, column2)
Set_tposition (windowid, row1 -   30 , (Column2 + Column1) *   0.5   -   5 )
Write_string (windowid, class [ 0 ])
Clear_ocr_class_mlp (ocrhandle)
Dev_display (selectedsortedregion)
Endif

The accuracy of Character Recognition is quite high!

In the figure, the Chinese character "Chuan" is not recognized. In fact, it is very easy to recognize it after the corresponding character recognition template is created. This process is skipped for convenience demonstration. In addition, the character recognition accuracy of D, O, and 0 is low (D and O are often identified as 0). However, you can set the recognition priority to improve the recognition success rate in the real environment.

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.