License image font comparison method based on lightweight neural network

By using a lightweight neural network-based font comparison method for ID card images, the problems of subjectivity and light interference in traditional font comparison methods are solved, achieving high-precision font recognition and comparison for ID card images, which is suitable for low-power embedded devices.

CN119274185APending Publication Date: 2025-01-07TRAFFIC MANAGEMENT RES INST OF THE MIN OF PUBLIC SECURITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411303806.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-19
Publication Date
2025-01-07

AI Technical Summary

Technical Problem

Traditional methods for comparing fonts in ID card images are limited by the subjectivity of manual comparison and interference from changes in lighting. The algorithms have low accuracy, insufficient generalization performance, and lack a complete process.

Method used

A lightweight neural network-based font comparison method for certificate images is adopted. Key regions are extracted through a digital character recognition model, and a neural network model based on feature cosine similarity comparison is used for certificate character comparison. The method includes an image compression module, convolutional layers, and nonlinear activation layers to achieve high-precision font recognition and comparison.

Benefits of technology

It enables rapid comparison of certificate images under different backgrounds, improves recognition efficiency, reduces hardware requirements, and is suitable for low-power embedded devices, desktop applications, and embedded devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119274185A_ABST
    Figure CN119274185A_ABST
Patent Text Reader

Abstract

The invention relates to a license image font comparison method based on a lightweight neural network, and relates to the technical field of image processing. The method comprises the following steps: inputting a target license picture into a numeric character recognition model, and outputting to obtain a numeric character image set corresponding to the target license picture; the digital character image set is input into a license character comparison model, a font recognition result corresponding to the target license picture is output, and the license character comparison model is a neural network model based on feature cosine similarity comparison. In an application scene of identification of the certificate photo, character fonts in a certificate image are identified through character identification of a target certificate picture and a certificate character comparison process. In the process, rapid comparison of the license pictures under different backgrounds is realized in combination with a high-precision comparison process of feature cosine similarity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to a method for comparing fonts in certificate images based on a lightweight neural network. Background Art

[0002] As an important carrier of information transmission, the uniqueness and accuracy of fonts are crucial to ensure the effective dissemination of information. Traditional font comparison methods are limited by the subjectivity of manual comparison and can no longer meet the needs of modern society. Traditional methods generally use template matching technology to calculate the similarity between images. This type of method is easily affected by shooting angles and changes in light and dark, and often requires manual setting of different thresholds. The algorithm has low accuracy and insufficient generalization performance. In recent years, the rise of deep learning technology has brought new solutions to the field of font comparison. Font comparison technology based on deep learning has gradually become a hot spot for research and application due to its high efficiency and accuracy. Deep learning technology has a strong representation learning ability and can learn complex and abstract feature representations from massive data, providing strong technical support for font comparison.

[0003] Among the related technologies, the font comparison method in the certificate image is usually combined with image recognition technology. Through data preprocessing, font feature extraction and font comparison analysis, the computer equipment recognizes the font of the certificate image to judge the authenticity of the certificate.

[0004] However, in the related art, there is still a lack of a complete process for comparing fonts in certificate images. Summary of the invention

[0005] The present invention relates to a method for comparing fonts in certificate images based on a lightweight neural network, which can improve the recognition efficiency of image font comparison in certificate photos. The method is applied in a computer device, and the method includes:

[0006] Input the target certificate image into the digital character recognition model, and output a set of digital character images corresponding to the target certificate image;

[0007] The digital character image set is input into the certificate character comparison model, and the font recognition result corresponding to the target certificate image is output. The certificate character comparison model is a neural network model based on feature cosine similarity comparison.

[0008] In an optional embodiment, the target certificate image is input into a digital character recognition model, and a digital character image set corresponding to the target certificate image is output, including:

[0009] Input the target certificate image into the digital character recognition model;

[0010] Extract key areas from the target certificate image using a digital character recognition model to obtain at least one key area;

[0011] Perform character recognition on the key areas and output a set of digital character images corresponding to the target certificate image.

[0012] In an optional embodiment, the key area includes at least one area corresponding to a date field on the target certificate image.

[0013] In an optional embodiment, character recognition is performed on the key area, and a set of digital character images corresponding to the key area is output, including:

[0014] Combined with OCR text recognition technology, character recognition is performed on the key area, and a set of digital character images corresponding to the key area is output.

[0015] In an optional embodiment, a digital character image set is input into a certificate character comparison model, and a font recognition result corresponding to a target certificate image is output, including:

[0016] Acquire at least one sample image from the digital character image set;

[0017] Determining character content corresponding to the sample image;

[0018] Based on the character content, a standard character image and a non-standard character image corresponding to the character content are obtained;

[0019] Generate a first sample pair based on the sample image and the standard character image;

[0020] Generate a second sample pair based on the sample image and the non-standard character image;

[0021] The first sample pair and the second sample pair are input into the certificate character comparison model, and a font recognition result corresponding to the target certificate image is output.

[0022] In an optional embodiment, the method further comprises:

[0023] Grayscale and de-grayscale the sample image.

[0024] In an optional embodiment, the font recognition result is implemented as a character font recognition result and a character content recognition result;

[0025] The character font recognition results include standard font recognition results and non-standard font recognition results.

[0026] In an optional embodiment, the certificate character comparison model includes an image compression module, a convolutional layer module, a nonlinear activation layer module, and an output channel;

[0027] The number of convolutional layer modules is at least two;

[0028] The image compression module is connected to the convolutional layer module;

[0029] The output channels are connected to the non-linear activation layer module.

[0030] The beneficial effects of the technical solution provided by this application include at least:

[0031] In the application scenario of ID photo recognition, the character fonts in the ID image are recognized through the process of character recognition and ID character comparison of the target ID image. In this process, the high-precision comparison process of feature cosine similarity is combined to achieve rapid comparison of ID images under different backgrounds. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0033] Figure 1 A flowchart of a method for comparing fonts in certificate images based on a lightweight neural network provided by an exemplary embodiment of the present application is shown.

[0034] Figure 2 A schematic diagram of a process for generating a digital character image set provided by an exemplary embodiment of the present application is shown.

[0035] Figure 3 A schematic diagram of a process for generating a font recognition result provided by an exemplary embodiment of the present application is shown. DETAILED DESCRIPTION

[0036] In order to make the objectives, technical solutions and advantages of the present application more clear, the embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.

[0037] Figure 1 A flowchart of a method for comparing fonts in a certificate image based on a lightweight neural network provided by an exemplary embodiment of the present application is shown. The method is described by taking the application of the method in a computer device as an example. The method includes:

[0038] Step 101: input a target certificate image into a digital character recognition model, and output a digital character image set corresponding to the target certificate image.

[0039] In the embodiment of the present application, the target certificate image is a certificate image that needs to be authenticated, and the characters in the key area of ​​the target certificate image need to be extracted and determined. The key area is the area where a corresponding date field in the certificate image is located, and the key area includes at least two characters.

[0040] After the target certificate image is input into the digital character recognition model, it is deemed that the key area is input into the digital character recognition model, and a digital character image set can be obtained. The digital character image set includes at least two digital characters. The digital characters are implemented in image form. In the image, the font features corresponding to the digital characters can be reflected.

[0041] In one example, the standard posture of the certificate corresponds to the long edge of the certificate being at a horizontal angle and the short edge being perpendicular to the horizontal line. The final cropped and corrected certificate image resolution is 1920 (width) x 1280 (height) pixels. At this resolution, the text details on the surface of the certificate are clear.

[0042] Step 102, input the digital character image set into the certificate character comparison model, and output the font recognition result corresponding to the target certificate image.

[0043] In the embodiment of the present application, the certificate character comparison model is a neural network model based on feature cosine similarity comparison. The recognition result is realized in a probabilistic form.

[0044] It should be noted that for the sample (x i , x j ), the formula for outputting cosine similarity is shown in Formula 1:

[0045] Formula 1:

[0046] In the formula, y ij Represents the sample feature vector x i and x j The similarity.

[0047] Optionally, in some embodiments of the present application, the construction and training process of the certificate character comparison model is also included. Optionally, after the model is trained, the trained model is quantized using int16 to further reduce the model size.

[0048] Figure 2 A schematic diagram of a process for generating a digital character image set provided by an exemplary embodiment of the present application is shown. The method is applied to a computer device as an example for explanation. The process includes:

[0049] Step 201: input the target certificate image into the digital character recognition model.

[0050] In the embodiment of the present application, the digital character recognition model has character recognition and image processing functions. Optionally, the pre-image processing function is a function of processing the target certificate image.

[0051] Step 202: extract key areas of the target certificate image using a digital character recognition model to obtain at least one key area corresponding to the target certificate image.

[0052] In one example, a digital character recognition model is used to detect four edge corner points of the key area of ​​the certificate, namely the upper left corner, upper right corner, lower right corner, and lower left corner, and the OpenCV library is used to complete the affine transformation of the certificate, so that the image is in a standard posture and the background area is cropped.

[0053] In the embodiment of the present application, as described above, the key area of ​​the target certificate includes at least one area corresponding to the date field in the target certificate image.

[0054] Step 203, character recognition is performed on the key area, and a set of digital character images corresponding to the target certificate image is output.

[0055] In one example, optical character recognition (OCR) text recognition technology is combined to perform character recognition on the key area, and a set of digital character images corresponding to the key area is output. In the embodiment of the present application, a total of 10 character images corresponding to the numbers 0-9 are included.

[0056] Figure 3 A schematic diagram of a process for generating a font recognition result provided by an exemplary embodiment of the present application is shown. The method is described by taking the method applied to a computer device as an example. The method includes:

[0057] Step 301: Acquire at least one sample image in a digital character image set.

[0058] This process is a process of extracting sample images from digital character images. Optionally, there are at least two sample images in the sample images, and the sample images will be subjected to font recognition one by one.

[0059] Step 302: Determine the character content corresponding to the sample image.

[0060] This process is the process of recognizing and extracting characters in the sample image.

[0061] Step 303: based on the character content, obtain a standard character image and a non-standard character image corresponding to the character content.

[0062] Optionally, standard font characters are defined as category P, and non-standard characters are defined as category N.

[0063] Step 304: Generate a first sample pair based on the sample image and the standard character image.

[0064] Step 305: Generate a second sample pair based on the sample image and the non-standard character image.

[0065] In the embodiment of the present application, a sample image in a character image library category P is randomly selected. Then randomly select a sample from the character image library P and N (where i≠j) and Form positive and negative sample pairs and as model input.

[0066] In the embodiment of the present application, it also includes a grayscale and de-grayscale process for the input sample pair.

[0067] Step 306: Input the first sample pair and the second sample pair into the certificate character comparison model, and output a font recognition result corresponding to the target certificate image.

[0068] It should be noted that in the embodiment of the present application, the certificate character comparison model includes an image compression module, a convolutional layer module, a non-linear activation layer module and an output channel; the number of convolutional layer modules is at least two; the image compression module is connected to the convolutional layer module; and the output channel is connected to the non-linear activation layer module.

[0069] In one example, the model structure includes: the input image is first uniformly compressed to 64×64 size, and then three convolutional layers are used for feature extraction. Each convolutional layer is followed by a relu nonlinear activation layer. The kernel size of each convolutional layer is 3×3, and the output channels are 32, 64, and 128 respectively. Using such a shallow network can improve the model reasoning speed while maintaining the inherent characteristics of the font image. Finally, a global pooling layer and a linear fully connected layer are used to output a 64-dimensional feature vector to facilitate the subsequent calculation of the similarity between samples.

[0070] In one example, during model training, if x i and x j From P category, let the output of the three sample pairs be 1; if x i and x j If one of them is from the N category, then let the outputs of the three sample pairs all be -1. The above triple sample pair construction method can fully tap the inherent characteristics of the font image, allowing the neural network model to focus more on the font features themselves and ignore background interference. That is, in the embodiment of the present application, the number of similarity values ​​is at least two.

[0071] In summary, the method provided in the embodiment of the present application, in the application scenario of ID photo recognition, recognizes the character font in the ID image through the process of character recognition of the target ID image and ID character comparison. In this process, combined with the high-precision comparison process of feature cosine similarity, rapid comparison of ID images under different backgrounds is achieved.

[0072] The method provided in the embodiment of the present application can adapt to the certificate font comparison tasks in different backgrounds. It has fast algorithm reasoning speed, low hardware requirements, and is independent of GPU. It can be integrated into desktop applications or embedded devices as an independent software module, and has important value and significance in practical applications.

[0073] (1) The method provided in the embodiment of the present application has low requirements for the hardware deployment environment. It can quickly complete the font comparison of the certificate image without relying on graphics acceleration chips such as GPU, NPU, TPU, etc., which is suitable for the deployment environment of low-power and low-computing embedded devices, and is convenient for the development of small certificate recognition devices.

[0074] The above are only optional embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.

Claims

1. A method for comparing fonts in certificate images based on a lightweight neural network, characterized in that: The method is applied in a computer device, and the method comprises: Input the target certificate image into the digital character recognition model, and output a set of digital character images corresponding to the target certificate image; The digital character image set is input into a certificate character comparison model, and a font recognition result corresponding to the target certificate image is output. The certificate character comparison model is a neural network model based on feature cosine similarity comparison.

2. The method according to claim 1, characterized in that The step of inputting the target certificate image into the digital character recognition model and outputting a digital character image set corresponding to the target certificate image includes: Inputting the target certificate image into a digital character recognition model; Extracting key areas of the target certificate image by using the digital character recognition model to obtain at least one key area corresponding to the target certificate image; Character recognition is performed on the key area to output a set of digital character images corresponding to the target certificate image.

3. The method according to claim 2, characterized in that The key area includes at least one area corresponding to a date field in the target certificate image.

4. The method according to claim 2, characterized in that: The performing character recognition on the key area and outputting a set of digital character images corresponding to the key area includes: In combination with OCR text recognition technology, character recognition is performed on the key area, and the digital character image set corresponding to the key area is output.

5. The method according to claim 1, characterized in that The step of inputting the digital character image set into a certificate character comparison model and outputting a font recognition result corresponding to the target certificate image includes: Acquire at least one sample image in the digital character image set; Determining character content corresponding to the sample image; Based on the character content, obtaining a standard character image and a non-standard character image corresponding to the character content; Generate a first sample pair based on the sample image and the standard character image; Generate a second sample pair based on the sample image and the non-standard character image; The first sample pair and the second sample pair are input into the certificate character comparison model, and a font recognition result corresponding to the target certificate image is output.

6. The method according to claim 5, characterized in that The method further comprises: The sample image is grayscaled and de-grayscaled.

7. The method according to claim 5, characterized in that The font recognition result is implemented as a character font recognition result and a character content recognition result; The character font recognition result includes a standard font recognition result and a non-standard font recognition result.

8. The method according to claim 5, characterized in that The certificate character comparison model includes an image compression module, a convolutional layer module, a nonlinear activation layer module and an output channel; The number of the convolutional layer modules is at least two; The image compression module is connected to the convolutional layer module; The output channel is connected to the nonlinear activation layer module.