Certificate anti-counterfeiting detection method and device based on stroke comparison, equipment and medium
By identifying the text area of the ID image, generating standardized single-word images and extracting stroke feature vectors, the problem of manual review and easy missed inspection in the anti-counterfeiting detection of existing ID documents is solved, and efficient and accurate tampering detection is achieved.
Patent Information
- Application Number
- CN202510974641.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-15
- Publication Date
- 2025-09-02
AI Technical Summary
The existing anti-counterfeiting detection methods rely on manual review, which are time-consuming and easy to miss the inspection of subtle tampering traces, especially difficult to effectively detect differences in font inconsistent.
By identifying the text area in the document image, determining the four-angle coordinates, performing projection transformation to generate a single-word image with a standardized facing angle, extracting stroke features, comparing stroke feature vectors with font library, and quantifying the difference degree to judge tampering.
It improves the sensitivity of tamper detection, reduces manual interference, improves detection efficiency and accuracy, and is suitable for large-scale document batch inspection.
Smart Images

Figure CN120580701A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of security detection technology, and in particular to a document anti-counterfeiting detection method, device, equipment and medium based on stroke comparison. Background Art
[0002] With the development of society, the application of electronic identity authentication is very extensive. As a key link in identity authentication, document anti-counterfeiting has been widely used in many fields. For example, in the field of medical health, the hospital's self-service registration machine reads the ID card chip information and compares it with the Ministry of Public Security's database, combined with facial recognition to confirm the patient's identity, avoiding "inconsistency between person and document" and causing confusion in medical records or medical insurance fraud; in the field of financial technology, banks, securities and other institutions use the anti-counterfeiting features of documents such as ID cards and passports combined with OCR recognition and liveness detection to prevent the use of forged documents to open fake accounts.
[0003] Currently, most document anti-counterfeiting detection methods use traditional auditing, which is highly dependent on manual labor. The authenticity identification of documents depends on the auditor's experience. However, this method is time-consuming and prone to missing traces of tampering. It is also very easy to miss subtle differences such as inconsistent fonts and trigger risks. Summary of the Invention
[0004] The present invention provides a document anti-counterfeiting detection method, device, equipment and medium based on stroke comparison, which improves the sensitivity of tampering detection by extracting stroke features to quantify subtle differences.
[0005] In a first aspect, a document anti-counterfeiting detection method based on stroke comparison is provided, comprising: Identify the text area in the document image and determine the four corner coordinates of each character based on the text area; Performing a projection transformation on the text area according to the four-corner coordinates to generate a single-word image with a standardized front view angle; Extracting stroke features of the single-character image to obtain a single-character stroke feature vector; Converting the single word image into text characters, matching the text characters with a preset font library to obtain a standard font image, and converting the standard font image into a standard feature vector; A quantized value of the difference between the single-character stroke feature vector and the standard feature vector is measured, and a result of the document tampering detection is determined according to the quantized value of the difference.
[0006] In a second aspect, a document anti-counterfeiting detection device based on stroke comparison is provided, comprising: An identification and determination module, configured to identify a text area in a document image and determine the four corner coordinates of each character based on the text area; A transformation module is used to perform a projection transformation on the text area according to the four-corner coordinates to generate a single-word image with a standardized front view angle; An extraction module is used to extract stroke features from the single-word image to obtain a single-word stroke feature vector; A conversion module, configured to convert the single word image into text characters; A matching and conversion module, configured to match the text characters with a preset font library to obtain a standard font image, and convert the standard font image into a standard feature vector; The measuring and judging module is used to measure the difference quantization value between the single-character stroke feature vector and the standard feature vector, and judge the document tampering detection result according to the difference quantization value.
[0007] In a third aspect, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the above-mentioned method for document anti-counterfeiting detection based on stroke comparison are implemented.
[0008] In a fourth aspect, a computer-readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, the steps of the above-mentioned document anti-counterfeiting detection method based on stroke comparison are implemented.
[0009] In the solution implemented by the above-mentioned document anti-counterfeiting detection method, device, computer equipment and storage medium based on stroke comparison, the detection focus is focused on the high-incidence areas of tampering by identifying the text area, avoiding interference from irrelevant information such as background patterns and shading, and improving detection efficiency; the four-corner coordinates provide precise geometric positioning for subsequent processing, ensuring that the text areas of different document images can be uniformly mapped and compared, eliminating interference from non-text areas such as document shading and borders, and reducing noise data during feature extraction; projection transformation can correct text from any perspective to a normal viewing angle, so that the single word image maintains a standard rectangle, which is convenient for unified feature extraction, and converts single words of different sizes and tilt angles into a fixed size, avoiding feature deviations caused by text scaling and rotation, and ensuring consistency in feature comparison; strokes are Chinese characters / The basic building blocks of letters, extracting stroke features (such as stroke direction, intersections, and inflection point positions) can accurately describe the morphological nature of text and are more resistant to interference than pixel-level features; tampering with text can easily lead to changes in stroke continuity and intersection relationships, and stroke feature vectors can quantify such subtle differences, improving the sensitivity of tampering detection; matching text characters with font libraries, if the matching result of a single word is significantly different from the fonts of other fields, it can be determined that the word may have been tampered with; the subjectivity of manual judgment is avoided by quantifying the difference, and the detection results can be automatically output after setting the threshold, which is suitable for large-scale batch detection of documents. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0011] Figure 1 This is a schematic diagram of an application environment of a document anti-counterfeiting detection method based on stroke comparison in one embodiment of the present invention; Figure 2 This is a flow chart of a document anti-counterfeiting detection method based on stroke comparison in one embodiment of the present invention; Figure 3 This is a structural diagram of a document anti-counterfeiting detection device based on stroke comparison in one embodiment of the present invention; Figure 4 is a structural diagram of a computer device according to an embodiment of the present invention; Figure 5 It is another structural schematic diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION
[0012] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0013] The embodiment of the present invention provides a document anti-counterfeiting detection method based on stroke comparison, which can be applied in the following situations: Figure 1In an application environment, the client communicates with the server through a network. The server can identify the text area in the document image and determine the four corner coordinates of each character based on the text area; perform a projection transformation on the text area based on the four corner coordinates to generate a single word image with a standardized front view angle; perform stroke feature extraction on the single word image to obtain a single word stroke feature vector; convert the single word image into text characters, and match the text characters with a preset font library to obtain a standard font image, and convert the standard font image into a standard feature vector; measure the difference quantization value between the single word stroke feature vector and the standard feature vector, judge the document tampering detection result based on the difference quantization value, and feed back the document tampering detection result to the client. The present invention provides a document anti-counterfeiting detection device based on stroke comparison. For the document tampering detection result business, it quantifies subtle differences by extracting stroke features to improve the sensitivity of tampering detection. The client can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers and portable wearable devices. The server can be implemented as an independent server or a server cluster consisting of multiple servers. The present invention is described in detail below through specific examples.
[0014] See also Figure 2 As shown, Figure 2 A flowchart of a document anti-counterfeiting detection method based on stroke comparison provided by an embodiment of the present invention includes the following steps: S1. Identify a text area in a document image, and determine the four corner coordinates of each character based on the text area.
[0015] In an embodiment of the present invention, the recognition refers to finding the portion containing text from the document image using computer vision and image processing technology, and the determination refers to further accurately determining the position of each character in the image based on the identified text area, that is, obtaining the four corner coordinates of each character.
[0016] Specifically, the document image is processed through technical means. First, the area containing text in the image (such as the name and number columns on the ID card) is located, and then the coordinates of the four corner points of each independent text (upper left, upper right, lower right, and lower left pixel positions) are further determined to achieve precise spatial positioning of the document text.
[0017] In specific medical and health scenarios, by identifying the text areas and individual word coordinates of medical documents (such as medical insurance cards and medical records), the patient's name, ID number and other information can be accurately extracted. Combined with the four-corner coordinates, the standardization of the text layout (such as whether the font spacing and position are abnormal) can be verified to prevent tampering with medical records or theft of medical insurance accounts.
[0018] In financial technology scenarios, by identifying the text areas and individual word coordinates of ID cards and bank cards, on the one hand, key information such as account number and name can be extracted; on the other hand, the printing features of the text (such as font spacing and tilt angle) can be analyzed through coordinates to determine whether they meet the standards, thereby preventing the use of forged documents to open fake accounts.
[0019] In the embodiment of the present invention, determining the four corner coordinates of each character according to the character area includes: Performing text block detection on the text area to obtain line text blocks; Splitting the line text block into independent characters to obtain independent characters; The bounding box coordinates of the independent characters are converted into four-corner coordinates to obtain the four-corner coordinates of each character.
[0020] In an embodiment of the present invention, the text block detection refers to identifying and dividing line text blocks with relatively independent semantics or layout from an image area containing text, the independent character splitting refers to further dividing each line text block into individual independent characters on the basis of the line text blocks, and the four-corner coordinate conversion refers to converting the bounding box coordinates of the independent character from one coordinate representation form to another, and finally obtaining the coordinates of the upper left corner, upper right corner, lower left corner and lower right corner of each text in the image.
[0021] Specifically, the document image is scanned using a text detection algorithm, and a convolutional neural network is used to extract texture, edge and other features in the image. Combined with the anchor box mechanism or segmentation idea, continuous text line areas (i.e., line text blocks) are located. For example, the EAST algorithm directly predicts the quadrilateral area of the text line, while the CTPN combines vertical anchor boxes into horizontal text lines.
[0022] Furthermore, based on pixel connectivity, the foreground pixels (text) in the line text block are grouped into connected areas. Each connected area corresponds to an independent character. It should be noted that noise needs to be filtered in combination with prior knowledge such as font size and spacing.
[0023] Furthermore, the bounding box of an independent character is usually expressed as (x, y, width, height), where (x, y) is the coordinate of the upper left corner. After the four-corner coordinate conversion, the upper left corner is: (x, y), the upper right corner is: (x + width, y), the lower right corner is: (x + width, y + height), and the lower left corner is: (x, y + height).
[0024] In an embodiment of the present invention, a complex image is segmented into independent line blocks to reduce the computational complexity of global processing and focus on line-level text structure analysis; the line blocks are decomposed into the smallest units to facilitate subsequent independent feature extraction of each character; the four-corner coordinates can be used to verify the layout standardization of the document text or assist in the visual calibration of OCR results.
[0025] In the embodiment of the present invention, the coordinates of each character are clearly defined to provide precise position guidance for subsequent optical character recognition, thereby reducing the recognition error rate; it also provides a structured data foundation for information storage and management, facilitating storage and retrieval by field.
[0026] S2. Performing a projection transformation on the text area according to the four-corner coordinates to generate a single-word image with a standardized front view angle.
[0027] In the embodiment of the present invention, the projection transformation refers to mapping a text area with specific four-corner coordinates in an image to a new, ideal plane through a mathematical method, so that the text area presents a standard front view angle and eliminates the original deformation.
[0028] Specifically, the four corner coordinates of the text area (such as the coordinates of the quadrilateral vertices of tilted text) are used to map it into a rectangular image with a standard upright angle using projection transformation, eliminating the tilt and distortion of the text caused by the shooting angle or perspective deformation, and making the single word image appear in a unified upright and regular form.
[0029] In healthcare scenarios, medical documents (such as test reports, prescriptions, and imaging diagnostics) often have text deformation due to handwriting, printing layout, or shooting angles. Standardization can improve OCR (optical character recognition) accuracy and reduce manual input errors.
[0030] In the financial field, identity cards, bank cards, business licenses and other documents used in bank account opening and loan applications often have text deformation due to tilted photography. Standardization can enhance the OCR recognition accuracy of fields such as "name", "ID number" and "validity period".
[0031] In an embodiment of the present invention, performing a projection transformation on the text area according to the four-corner coordinates to generate a single-word image at a standardized elevation angle includes: Determining the actual shape of a single-word region in the text region and setting a target front-view shape; Performing a projection mapping transformation on the actual shape and the target orthographic shape according to the four-corner coordinates to obtain a transformed single word image; The transformed single-word image is subjected to resolution normalization to obtain a single-word image with a standardized frontal viewing angle.
[0032] In an embodiment of the present invention, the determination refers to accurately depicting the specific outline of each word in the image through image processing and computer vision technology, the setting refers to pre-defining an ideal, standard word shape as a target for subsequent shape correction, the projection mapping transformation refers to the process of mapping the actual shape of the word to the target orthographic shape based on the four corner coordinates of the word area, and the resolution normalization refers to adjusting the transformed word image to a uniform resolution so that it has the same size and pixel density.
[0033] Specifically, the outline of a single word is extracted from the text area through edge detection, and the closed area is determined by combining connected domain analysis. The outline is then approximated by polygons (such as the Douglas-Peucker algorithm) to obtain the coordinates of the approximate quadrilateral vertices, that is, the coordinates of the four corners of the actual shape; then a standard rectangle is defined as the target shape (such as a rectangle with a fixed aspect ratio), and its four corner coordinates are the ideal positions under the normal viewing angle.
[0034] Furthermore, the coordinates of the four corners of the actual shape (source point) and the coordinates of the four corners of the target orthographic shape (target point) are input, and the homography matrix is calculated through the function of the perspective transformation matrix. The matrix solution is based on the least squares method to satisfy the mapping relationship between the source point and the target point; the single-word area image is perspective transformed, the deformed actual shape is mapped to the target orthographic shape, and the corrected image is output.
[0035] Furthermore, a fixed size (such as 28×28, 64×64 pixels) is set as the standardized output, the resolution is determined according to subsequent application requirements (such as CNN input, feature vector dimension), and an interpolation algorithm (such as bilinear interpolation, bicubic interpolation) is used to scale the transformed image to the target size, finally obtaining a single-word image with a standardized frontal view angle.
[0036] In an embodiment of the present invention, the target front view shape is used as a standardized template to provide a unified target form for subsequent geometric correction, which is convenient for feature comparison across images; the projective mapping transformation obtains the transformed single word image so that the single word images taken at different angles are converted to the same perspective, which is convenient for subsequent feature extraction; the fixed resolution can avoid parameter adjustment caused by size changes during feature extraction, and at the same time reduce the amount of calculation during neural network training or inference.
[0037] In an embodiment of the present invention, the text area is projected and transformed according to the four-corner coordinates to avoid character adhesion and stroke distortion caused by deformation, thereby providing a distortion-free image basis for tasks such as OCR (optical character recognition) and feature extraction.
[0038] S3. Extract stroke features from the single-word image to obtain a single-word stroke feature vector.
[0039] In the embodiments of the present invention, the stroke feature extraction refers to extracting features from a single-character image that can reflect key information such as its stroke structure, morphology, and distribution, and representing these features in the form of vectors.
[0040] Specifically, geometric features such as the stroke direction, inflection point position, number of intersection points, and line curvature of a single character are extracted through algorithms such as edge detection and skeletonization processing, and then these features are encoded into multi-dimensional vectors. For example, 0-1 is used to represent the existence of a stroke, an angle value is used to represent the inclination direction of a stroke, and a coordinate difference is used to represent the length of a stroke, etc.
[0041] In a specific scenario of medical and health, the stroke features of handwritten herbal medicine names such as Astragalus membranaceus and Codonopsis pilosula in a traditional Chinese medicine prescription are extracted. For example, the intersection point position of the grass head of the character "芪" and the curvature of the vertical hook are compared with the standard font library after being converted into feature vectors to correct the misrecognition caused by scribbled fonts in OCR.
[0042] In the financial scenario, the stroke features of handwritten amount numbers on checks and drafts are extracted. For example, the change in the strength of the horizontal hook and the starting angle of the left-falling stroke of the character "伍" in "伍万元整" are compared with the bank's reserved signature template after generating feature vectors.
[0043] In the embodiments of the present invention, the extraction of the stroke features of the single-character image to obtain a single-character stroke feature vector includes: Construct a binary stroke template for the single-character image to obtain a binary stroke template image; Simulate interference in the real scene for the binary stroke template image to obtain an interference sample image; Calculate the difference value between the interference sample image and the binary stroke template image, and train a preset neural network model according to the difference value to obtain a trained neural network model; Extract the stroke features of the single-character image according to the trained neural network model to obtain a single-character stroke feature vector.
[0044] In the embodiments of the present invention, the binary stroke template construction refers to the process of converting a single-character image into a stroke template image with only two colors, black and white. The real-scene interference refers to adding various interference factors simulating the real scene to the binary stroke template image. The calculation usually refers to using a certain distance metric or similarity metric method to calculate the degree of difference between the interference sample image and the binary stroke template image.
[0045] Specifically, first convert the color single-character image into a grayscale image to eliminate color interference. Through the global threshold or adaptive threshold method, pixels with a grayscale value higher than the threshold are set to white (background), and those lower than the threshold are set to black (stroke) to generate a binary image. Operations such as erosion and dilation are used to remove isolated noise points and connect broken strokes to ensure the continuity and integrity of the strokes in the template.
[0046] Furthermore, when the binary stroke template image is subjected to real-scene simulation interference, it can be divided into the steps of noise addition, geometric deformation, and degradation simulation. Noise addition is divided into Gaussian noise: simulating the electronic noise of the scanning equipment, salt and pepper noise: simulating the spots caused by aging paper, geometric deformation is divided into affine transformation: rotation (±15°), tilt (perspective transformation), scaling (±20%), elastic transformation: simulating handwriting jitter through bilinear interpolation (such as distorting the image with a random displacement field), degradation simulation is divided into motion blur: simulating the movement of the document during scanning (setting a blur kernel of 15 pixels in length and 45° in angle), low resolution: downsampling to 16×16 pixels and then enlarging to simulate low-definition camera shooting.
[0047] In addition, when simulating interference in real scenes, you can also add background interference, superimpose common background patterns of certificates (such as grid patterns and anti-counterfeiting patterns) on the template image to simulate the actual printed background of the certificate; at the same time, simulate lighting changes, adjust image brightness and contrast, add shadows or light spots, and simulate imaging effects under different lighting conditions.
[0048] Furthermore, the pixel-level difference method is used to calculate the mean square error between the interference sample and the template. The specific formula is as follows:
[0049] in, is the interference image, For the template, Indicates the total number of pixels involved in the calculation.
[0050] Furthermore, a CNN architecture is adopted to extract local features through convolutional layers, dimensionality reduction through pooling layers, and abstract features through feature fusion in fully connected layers. Then, a loss function combination is performed, using pixel-level MSE + perceptual loss (based on the pre-trained VGG network to extract high-level feature differences) to balance details and semantics. The network weights are updated according to the difference values (such as the Adam optimizer with a learning rate of 0.001), and training is repeated until the loss converges.
[0051] Furthermore, the single-word image is input into the trained CNN, and through multi-layer convolution calculations, a high-dimensional feature vector is output in the penultimate layer. The vector is L2 normalized to eliminate the feature amplitude difference to facilitate subsequent similarity calculation. The final vector obtained is the single-word stroke feature vector.
[0052] In an embodiment of the present invention, 256-level grayscale information is compressed into 0 / 1 binary information to reduce the amount of data and facilitate subsequent calculations; irrelevant features such as font color and thickness are stripped away, and only the spatial distribution of strokes is retained, laying the foundation for standardized feature extraction; and interference is simulated by real scenes, so that the model can still accurately recognize even when facing scanning blur and handwriting deformation in real scenes.
[0053] In the embodiments of the present invention, a single - character image contains hundreds of pixel points, and the stroke feature vector can compress it into a numerical vector with dozens to hundreds of dimensions. While retaining the key information of the text structure, it significantly reduces the amount of data, and reduces the storage, transmission, and calculation costs.
[0054] S4. Convert the single - character image into a text character, match the text character with a preset font library to obtain a standard font image, and convert the standard font image into a standard feature vector.
[0055] In the embodiments of the present invention, the conversion refers to the process of recognizing and converting a single - character image into a corresponding text character, and the matching refers to the process of comparing the recognized text character with a preset font library to find the standard image corresponding to the text character in a specified font.
[0056] Specifically, first, the single - character image is converted into an editable text character through OCR (Optical Character Recognition) technology. For example, the character "田" in the image is recognized as the character "田", and then the text character is matched with a preset font library, such as a database containing standard fonts like Song typeface and Bold typeface, to extract the image of the character in the standard font, such as the image of the standard Song typeface "田" character. Finally, feature extraction is performed on the standard font image, such as analyzing the stroke direction, intersection point position, etc., to convert it into a numerical standard feature vector.
[0057] In the embodiments of the present invention, the matching of the text character with a preset font library to obtain a standard font image includes: Perform font - matching retrieval on the text character according to the preset font library to obtain a matching target font; Perform high - definition rendering on the matching target font to obtain a rendered font image; Adjust the rendered font image to a standard font image according to a preset size.
[0058] In the embodiments of the present invention, the font - matching retrieval refers to the process of searching and determining the most suitable target font in a preset font library according to a given text character according to certain rules and algorithms. The high - definition rendering refers to the process of generating a high - quality and high - resolution font image according to certain rules and parameters for the matched target font. The adjustment refers to the process of adjusting and converting the high - definition rendered font image according to the preset size requirements to obtain a font image that meets the standard size.
[0059] Specifically, the text characters recognized by OCR are converted into standard character encoding to determine the target characters that need to be matched; the preset font library stores character outline data of different fonts (such as Songti, Heiti, Kaiti, etc.), and the system traverses the font library according to the character encoding to find all fonts that contain the character; if the user specifies the font type (such as "need to match Heiti"), the corresponding font is directly called. If not specified, the best matching font may be selected according to the default rules or through feature matching.
[0060] Furthermore, the vector outline data of the characters is read from the target font file, such as the stroke edges described by the Bezier curve; when the vector outline is converted into a pixel image through the rasterization algorithm, the edge pixels are grayscale interpolated (such as Gaussian blur, MSAA multi-sampling) to eliminate jagged edges; the rendering resolution is set according to requirements, and details such as stroke thickness and font weight (such as boldness) are adjusted to generate a high-definition bitmap image.
[0061] Furthermore, when converting the rendered font image into a standard font image according to a preset size, the preset size (such as 28×28 pixels, 64×64 pixels) is first determined according to the subsequent application scenario, and an interpolation algorithm (such as bilinear interpolation, bicubic interpolation) is used to adjust the high-definition rendered image to the specified size while keeping the stroke ratio unchanged; finally, normalization processing, including grayscale normalization and center alignment, is performed to eliminate interference caused by size differences.
[0062] In the embodiment of the present invention, converting the standard font image into a standard feature vector includes: Performing contour analysis on the standard font image to obtain an image contour; Extracting structured stroke features from the image contour to obtain a structured stroke feature set; The structured stroke feature set is encoded, and the encoded features are vector-concatenated to obtain a standard feature vector.
[0063] In an embodiment of the present invention, the contour analysis refers to the process of performing edge detection and contour extraction on a standard font image to obtain the external contour and internal contour information of the characters in the font image; the structured stroke feature extraction refers to the process of analyzing and processing the contour on the basis of obtaining the image contour, extracting information that can reflect the structural characteristics of the character strokes, and organizing this information into a structured stroke feature set; the encoding refers to the process of converting various features in the structured stroke feature set into a numerical form that can be processed by a computer.
[0064] Specifically, the standard font image (such as a grayscale image of 64×64 pixels) is binarized. By setting a threshold, for example, a pixel value > 128 is white and vice versa is black, to highlight the contrast between the strokes and the background. Morphological operations (such as erosion and dilation) are performed to eliminate noise and smooth the stroke edges. The Canny, Sobel or Laplacian operator is used to scan the image to identify the positions of pixel gradient mutations, generating continuous contour lines. The contours are traced and closed, such as filling hollow strokes, to ensure the integrity of the stroke edges. The Douglas-Peucker algorithm is used to simplify the contour points, removing redundant details and retaining key inflection points (such as stroke turning points) to reduce the data complexity.
[0065] Specifically, when extracting the structured stroke features of the image contour, first, the continuous contour is segmented into basic stroke segments according to the contour inflection points (such as slope mutation points). For example, the character "木" can be disassembled into four independent strokes: horizontal, vertical, left-falling, and right-falling. Combining prior knowledge (such as Chinese character stroke norms), the stroke segments are classified and the types (horizontal, vertical, left-falling, right-falling, fold, etc.) are labeled.
[0066] Furthermore, the spatial parameters of each stroke segment are extracted, such as the starting coordinate, ending coordinate, length, inclination angle (for example, the slope of the left-falling stroke is negative), and curvature (for example, the arc of the right-falling stroke). The topological relationships are calculated, specifically the intersection coordinates between strokes, the crossing order (such as the position of the intersection of the horizontal and vertical strokes in the character "十"), and the inclusion relationship (such as the position relationship between the small horizontal stroke inside the character "日" and the outer frame). Finally, the above features are organized into structured data to form a feature set.
[0067] Furthermore, continuous values such as length and angle are normalized to the [0,1] interval (for example, a length of 40 pixels is normalized to 0.4, assuming the maximum length is 100 pixels). One-hot encoding is performed on the stroke types (such as "horizontal" → [1,0,0,0...], "vertical" → [0,1,0,0...]). Subsequently, topological relationship embedding is carried out, specifically using a graph neural network or spatial coordinate encoding (such as converting the intersection coordinates into relative position vectors) to represent the connection relationships between strokes. Finally, the encoded features of all strokes are concatenated into a one-dimensional vector in sequence. For example, each stroke generates 10-dimensional features, and 10 strokes form a 100-dimensional vector. In the embodiments of the present invention, the contour is the basic carrier of the font geometric attributes, providing accurate edge data for subsequent structured analysis; converting the pixel-level contour into a semantic-level stroke concept conforms to the human's cognition of the text structure and facilitates subsequent logical processing; the standard feature vector can be directly input into a machine learning model for classification or comparison, replacing the traditional pixel-level matching.
[0068] In an embodiment of the present invention, the conversion of single-word images into text characters can use OCR technology to extract character semantic information and solve interference problems such as image noise and deformation; the standard font image obtained by matching with the font library can unify original characters of different styles and sizes into the standard style of a preset font, avoiding feature deviations caused by font differences; and the accuracy of subsequent comparison, retrieval or machine learning tasks can be improved through unified feature dimensions.
[0069] S5. Measure a quantized difference value between the single-character stroke feature vector and the standard feature vector, and determine a document tampering detection result according to the quantized difference value.
[0070] In an embodiment of the present invention, the measurement refers to the process of calculating the difference quantization value between the single-character stroke feature vector and the standard feature vector, and the judgment refers to the process of judging whether the document has been tampered with based on the difference quantization value obtained by the measurement and combined with a preset threshold or rule.
[0071] Specifically, by calculating the quantified value of the difference between the stroke feature vector of a single word and the standard feature vector (such as numerical indicators such as Euclidean distance and cosine similarity), the degree of difference is converted into a measurable value; if the quantified value of the difference exceeds the preset threshold, it means that the stroke features of the single word deviate significantly from the standard features, and there may be tampering such as human modification, forgery or replacement of characters; otherwise, it is considered that the character features meet the standards and the content of the certificate is relatively credible.
[0072] In the embodiment of the present invention, the quantified value of measuring the difference between the single-character stroke feature vector and the standard feature vector includes: Performing orthogonal spatial projection alignment on the single-character stroke feature vector and the standard feature vector to obtain a single-character projection vector and a standard projection vector; Calculating the difference between the single word projection vector and the standard projection vector dimension by dimension to obtain the difference value of each dimension; Performing a text complexity analysis on the single-word projection vector, and assigning weights to the difference values of each dimension according to the complexity analysis result to obtain the weights of the difference values of each dimension; The weights of the difference values of the dimensions are weighted and integrated to obtain a quantified value of the difference.
[0073] In the embodiments of the present invention, the orthogonal space projection alignment refers to the process of mapping the single - character stroke feature vector and the standard feature vector into a specific orthogonal space to achieve a certain alignment state within this space. The per - dimension difference degree calculation refers to the process of calculating the difference degree for each dimension between the single - character projection vector and the standard projection vector. The text complexity analysis refers to the process of analyzing the text corresponding to the single - character projection vector to evaluate its structural complexity. The weight assignment refers to the process of assigning different weights to the difference values of each dimension according to the results of the text complexity analysis. The weighted synthesis refers to the process of multiplying the difference values of each dimension by their corresponding weights and then adding all the products to obtain a comprehensive difference degree quantization value.
[0074] Specifically, by using orthogonal transformations in linear algebra (such as PCA principal component analysis, SVD singular value decomposition, etc.), an orthogonal basis space is constructed, and the single - character stroke feature vector and the standard feature vector are respectively projected into this orthogonal space to obtain the single - character projection vector and the standard projection vector. This process makes the vector dimensions more independent by eliminating the correlation between feature dimensions, such as the redundant association between stroke thickness and tilt angle.
[0075] Further, for the projected single - character projection vector and the standard projection vector, the difference value is calculated for each dimension. The Euclidean distance is used to measure the absolute value of the numerical difference of the corresponding dimension, such as the difference value of a certain stroke angle dimension. The cosine similarity is used to calculate the deviation of the dimension vector direction (applicable to the angular difference of shape features).
[0076] Further, the complexity of the single - character structure is evaluated through an algorithm. The indicators include the number of strokes, the number of intersection points, the proportion of curve segments, etc. For example, the structure of the character "口" is simple, and the stroke differences may be caused by scanning noise. The structure of the character "警" is complex. If the difference in a certain dimension is large, it is more likely to be caused by tampering. According to the results of the complexity analysis, weights are assigned to the difference values of each dimension: dimensions with higher complexity (such as multi - stroke intersection areas) have higher weights, and vice versa.
[0077] Further, the difference values of each dimension are multiplied by their corresponding weights and then accumulated to obtain the final difference degree quantization value. The specific formula is as follows:
[0078] Among them, the difference degree quantization value can be converted into a binary judgment of "whether it is tampered with" through a preset threshold. For example, if the difference degree quantization value > threshold, it is determined to be tampered with; if the difference degree quantization value < threshold, it is determined not to be tampered with.
[0079] In an embodiment of the present invention, the original feature vector may have correlation between dimensions, and each dimension is independent after projection, avoiding errors caused by repeated calculations; dimension-by-dimensional analysis can accurately identify which feature dimensions have abnormalities, providing a basis for tampering positioning; complex stroke areas are difficult to tamper with and are more likely to leave traces, and high weights can increase sensitivity to differences in key areas.
[0080] In the embodiment of the present invention, by quantifying the difference between the single-word stroke feature vector and the standard feature vector and judging the document tampering based on it, the core advantage lies in converting subjective visual judgment into objective numerical analysis, thereby improving the accuracy and reliability of detection through data-driven means.
[0081] It can be seen that in the above scheme, for the document tampering detection result business, the text area in the document image is identified, and the four corner coordinates of each character are determined based on the text area; the text area is projected according to the four corner coordinates to generate a single-character image with a standardized front view angle; the stroke features of the single-character image are extracted to obtain a single-character stroke feature vector; the single-character image is converted into text characters, and the text characters are matched with a preset font library to obtain a standard font image, and the standard font image is converted into a standard feature vector; the difference quantization value between the single-character stroke feature vector and the standard feature vector is measured, and the document tampering detection result is judged based on the difference quantization value, and the sensitivity of tampering detection is improved by quantifying subtle differences through extracting stroke features.
[0082] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0083] In one embodiment, a document anti-counterfeiting detection device based on stroke comparison is provided. The document anti-counterfeiting detection device based on stroke comparison corresponds to the document anti-counterfeiting detection method based on stroke comparison in the above embodiment. Figure 3 As shown, the document anti-counterfeiting detection device based on stroke comparison includes an identification and determination module 101, a transformation module 102, an extraction module 103, a conversion module 104, a matching and conversion module 105, and a measurement and judgment module 106. The functional modules are described in detail as follows: Identification and determination module 101, for identifying a text area in a document image and determining the four corner coordinates of each character based on the text area; A transformation module 102 is used to perform a projection transformation on the text area according to the four-corner coordinates to generate a single-word image with a standardized front view angle; An extraction module 103 is used to extract stroke features from the single-character image to obtain a single-character stroke feature vector; A conversion module 104 is used to convert the single word image into text characters; The matching and conversion module 105 is used to match the text characters with a preset font library to obtain a standard font image, and convert the standard font image into a standard feature vector; The measurement and judgment module 106 is configured to measure a difference quantization value between the single-character stroke feature vector and the standard feature vector, and judge a document tampering detection result according to the difference quantization value.
[0084] In one embodiment, the recognition and determination module 101, when determining the four corner coordinates of each character according to the character area, is configured to: Performing text block detection on the text area to obtain line text blocks; Splitting the line text block into independent characters to obtain independent characters; The bounding box coordinates of the independent characters are converted into four-corner coordinates to obtain the four-corner coordinates of each character.
[0085] In one embodiment, when the transformation module 102 performs a projection transformation on the text area according to the four corner coordinates to generate a single-character image at a standardized elevation angle, it is configured to: Determining the actual shape of a single-word region in the text region and setting a target front-view shape; Performing a projection mapping transformation on the actual shape and the target orthographic shape according to the four-corner coordinates to obtain a transformed single word image; The transformed single-word image is subjected to resolution normalization to obtain a single-word image with a standardized frontal viewing angle.
[0086] In one embodiment, when the extraction module 103 extracts stroke features from the single-word image to obtain a single-word stroke feature vector, it is configured to: Binarizing the single-character image to construct a stroke template to obtain a binary stroke template image; Performing real scene simulation interference on the binary stroke template image to obtain an interference sample image; Calculating a difference value between the interference sample image and the binary stroke template image, and training a preset neural network model according to the difference value to obtain a trained neural network model; Stroke features of the single-character image are extracted according to the trained neural network model to obtain a single-character stroke feature vector.
[0087] In one embodiment, when matching the text characters with a preset font library to obtain a standard font image, the matching conversion module 105 is configured to: Performing font matching search on the text characters according to a preset font library to obtain a matching target font; Performing high-definition rendering on the matching target font to obtain a rendered font image; The rendered font image is adjusted to a standard font image according to a preset size.
[0088] In one embodiment, when converting the standard font image into a standard feature vector, it is used to: Performing contour analysis on the standard font image to obtain an image contour; Extracting structured stroke features from the image contour to obtain a structured stroke feature set; The structured stroke feature set is encoded, and the encoded features are vector-concatenated to obtain a standard feature vector.
[0089] In one embodiment, when measuring the difference quantization value between the single-character stroke feature vector and the standard feature vector, the measurement and judgment module 106 is configured to: Performing orthogonal spatial projection alignment on the single-character stroke feature vector and the standard feature vector to obtain a single-character projection vector and a standard projection vector; Calculating the difference between the single word projection vector and the standard projection vector dimension by dimension to obtain the difference value of each dimension; Performing a text complexity analysis on the single-word projection vector, and assigning weights to the difference values of each dimension according to the complexity analysis result to obtain the weights of the difference values of each dimension; The weights of the difference values of the dimensions are weighted and integrated to obtain a quantified value of the difference.
[0090] The present invention provides a document anti-counterfeiting detection device based on stroke comparison. For document tampering detection results, the device identifies text areas in a document image and determines the four-corner coordinates of each character based on the text area; performs a projection transformation on the text area based on the four-corner coordinates to generate a single-character image with a standardized frontal angle; extracts stroke features from the single-character image to obtain a single-character stroke feature vector; converts the single-character image into text characters, matches the text characters with a preset font library to obtain a standard font image, and converts the standard font image into a standard feature vector; measures the difference between the single-character stroke feature vector and the standard feature vector, and determines the document tampering detection result based on the difference quantification value. By extracting stroke features to quantify subtle differences, the sensitivity of tampering detection is improved.
[0091] The specific definition of a document anti-counterfeiting detection device based on stroke comparison can be found in the definition of a document anti-counterfeiting detection method based on stroke comparison above and will not be repeated here. Each module in the aforementioned document anti-counterfeiting detection device based on stroke comparison can be implemented in whole or in part through software, hardware, or a combination thereof. Each of these modules can be embedded in or independent of a processor in a computer device in hardware form, or can be stored in a computer device memory in software form, so that the processor can call and execute the corresponding operations of each module.
[0092] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 4 As shown. The computer device includes a processor, memory, network interface and database connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes non-volatile and / or volatile storage media and internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external client via a network connection. When the computer program is executed by the processor, it implements the functions or steps on the server side of a document anti-counterfeiting detection method based on stroke comparison.
[0093] In one embodiment, a computer device is provided. The computer device may be a client, and its internal structure diagram may be as follows: Figure 5 As shown. The computer device includes a processor, memory, a network interface, a display screen, and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server via a network connection. When executed by the processor, the computer program implements the client-side functions or steps of a document anti-counterfeiting detection method based on stroke comparison.
[0094] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are performed: Identify the text area in the document image and determine the four corner coordinates of each character based on the text area; Performing a projection transformation on the text area according to the four-corner coordinates to generate a single-word image with a standardized front view angle; Extracting stroke features of the single-character image to obtain a single-character stroke feature vector; Converting the single word image into text characters, matching the text characters with a preset font library to obtain a standard font image, and converting the standard font image into a standard feature vector; A quantized value of the difference between the single-character stroke feature vector and the standard feature vector is measured, and a result of the document tampering detection is determined according to the quantized value of the difference.
[0095] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: Identify the text area in the document image and determine the four corner coordinates of each character based on the text area; Performing a projection transformation on the text area according to the four-corner coordinates to generate a single-word image with a standardized front view angle; Extracting stroke features of the single-character image to obtain a single-character stroke feature vector; Converting the single word image into text characters, matching the text characters with a preset font library to obtain a standard font image, and converting the standard font image into a standard feature vector; A quantized value of the difference between the single-character stroke feature vector and the standard feature vector is measured, and a result of the document tampering detection is determined according to the quantized value of the difference.
[0096] It should be noted that the above functions or steps that can be implemented by the computer-readable storage medium or computer device can be found in the relevant descriptions of the server side and the client side in the aforementioned method embodiment. To avoid repetition, they will not be described one by one here.
[0097] Those skilled in the art will understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0098] Those skilled in the art will clearly understand that for the sake of convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0099] The above-described embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. If software tools or components other than those of the company appear in the application embodiments, they are merely used for illustration and do not represent actual use. Although the present invention has been described in detail with reference to the above-mentioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above-mentioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the scope of protection of the present invention.
Claims
1. A document anti-counterfeiting detection method based on stroke comparison, characterized in that: include: Identify the text area in the document image and determine the four corner coordinates of each character based on the text area; Performing a projection transformation on the text area according to the four-corner coordinates to generate a single-word image with a standardized front view angle; Extracting stroke features of the single-character image to obtain a single-character stroke feature vector; Converting the single word image into text characters, matching the text characters with a preset font library to obtain a standard font image, and converting the standard font image into a standard feature vector; A quantized value of the difference between the single-character stroke feature vector and the standard feature vector is measured, and a result of the document tampering detection is determined according to the quantized value of the difference.
2. The document anti-counterfeiting detection method based on stroke comparison according to claim 1, characterized in that: The determining the four corner coordinates of each character according to the character area includes: Performing text block detection on the text area to obtain line text blocks; Splitting the line text block into independent characters to obtain independent characters; The bounding box coordinates of the independent characters are converted into four-corner coordinates to obtain the four-corner coordinates of each character.
3. The document anti-counterfeiting detection method based on stroke comparison according to claim 1, characterized in that: The method of performing a projection transformation on the text area according to the four-corner coordinates to generate a single-word image at a standardized elevation angle includes: Determining the actual shape of a single-word region in the text region and setting a target front-view shape; Performing a projection mapping transformation on the actual shape and the target orthographic shape according to the four-corner coordinates to obtain a transformed single word image; The transformed single-word image is subjected to resolution normalization to obtain a single-word image with a standardized frontal viewing angle.
4. The document anti-counterfeiting detection method based on stroke comparison according to claim 1, characterized in that: The step of extracting stroke features from the single-word image to obtain a single-word stroke feature vector comprises: Binarizing the single-character image to construct a stroke template to obtain a binary stroke template image; Performing real scene simulation interference on the binary stroke template image to obtain an interference sample image; Calculating a difference value between the interference sample image and the binary stroke template image, and training a preset neural network model according to the difference value to obtain a trained neural network model; Stroke features of the single-character image are extracted according to the trained neural network model to obtain a single-character stroke feature vector.
5. The document anti-counterfeiting detection method based on stroke comparison according to claim 1, characterized in that: The step of matching the text characters with a preset font library to obtain a standard font image includes: Performing font matching search on the text characters according to a preset font library to obtain a matching target font; Performing high-definition rendering on the matching target font to obtain a rendered font image; The rendered font image is adjusted to a standard font image according to a preset size.
6. The document anti-counterfeiting detection method based on stroke comparison according to claim 1, characterized in that: The converting the standard font image into a standard feature vector comprises: Performing contour analysis on the standard font image to obtain an image contour; Extracting structured stroke features from the image contour to obtain a structured stroke feature set; The structured stroke feature set is encoded, and the encoded features are vector-concatenated to obtain a standard feature vector.
7. The document anti-counterfeiting detection method based on stroke comparison according to claim 1, characterized in that: The quantified value for measuring the difference between the single-character stroke feature vector and the standard feature vector includes: Performing orthogonal spatial projection alignment on the single-character stroke feature vector and the standard feature vector to obtain a single-character projection vector and a standard projection vector; Calculating the difference between the single word projection vector and the standard projection vector dimension by dimension to obtain the difference value of each dimension; Performing a text complexity analysis on the single-word projection vector, and assigning weights to the difference values of each dimension according to the complexity analysis result to obtain the weights of the difference values of each dimension; The weights of the difference values of the dimensions are weighted and integrated to obtain a quantified value of the difference.
8. A document anti-counterfeiting detection device based on stroke comparison, characterized in that: include: An identification and determination module, configured to identify a text area in a document image and determine the four corner coordinates of each character based on the text area; A transformation module is used to perform a projection transformation on the text area according to the four-corner coordinates to generate a single-word image with a standardized front view angle; An extraction module is used to extract stroke features from the single-word image to obtain a single-word stroke feature vector; A conversion module, configured to convert the single word image into text characters; A matching and conversion module, configured to match the text characters with a preset font library to obtain a standard font image, and convert the standard font image into a standard feature vector; The measuring and judging module is used to measure the difference quantization value between the single-character stroke feature vector and the standard feature vector, and judge the document tampering detection result according to the difference quantization value.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the document anti-counterfeiting detection method based on stroke comparison as described in any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the document anti-counterfeiting detection method based on stroke comparison as described in any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Vector image steganography method, authentication method, device and equipment
CN120935311A