Certificate authenticity inspection method and device and storage medium
The deep convolutional neural network model is used to extract the depth and texture features of the document, fuse and calculate the anti-counterfeiting features of the document, and use cosine similarity to determine the authenticity of the document. This solves the problems of low efficiency and poor accuracy of document inspection in the existing technology, and achieves a better Efficient and more accurate identification of document authenticity.
Patent Information
- Application Number
- CN202410512930.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-26
- Publication Date
- 2024-09-17
AI Technical Summary
Existing document authenticity inspection methods have low efficiency, poor accuracy, are susceptible to human factors and environmental influences, and lack robustness and applicability to complex situations.
The pre-trained deep convolutional neural network model is used to extract the depth features and texture features of the document image, the anti-counterfeiting features of the document are calculated by fusing the depth features and concrete features, and the authenticity of the document is judged using cosine similarity.
It improves the efficiency, accuracy and robustness of document inspection, reduces the influence of human factors, and can more accurately identify the authenticity of documents in complex situations.
Smart Images

Figure CN118657960A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a method, device and storage medium for verifying the authenticity of a certificate. Background Art
[0002] As an important official document that proves identity, qualifications, experience, etc., the anti-counterfeiting and identification technology of certificates has always attracted much attention. Traditional certificate anti-counterfeiting methods mainly rely on physical features, such as special paper, watermarks, security threads, etc., but these features are extremely easy to forge, and it is difficult to distinguish their authenticity by relying solely on traditional image recognition technology. Therefore, the authenticity identification of certificates is still mainly achieved by manual inspection, that is, the staff conducts visual inspection and comparison of the physical features and security information of the certificate based on their own professional knowledge and experience, and makes judgments accordingly.
[0003] In the process of research and practice of the prior art, the inventors of the present application found that manual inspection is not only time-consuming and labor-intensive, but also inefficient and difficult to meet the needs of large-scale document inspection. Moreover, since it is easily affected by human factors and external factors such as light, it is also more prone to misjudgment or missed judgment, greatly reducing the accuracy of the inspection. In addition, since better inspection results can only be achieved under specific conditions, the inspection effect is not good for some complex situations such as hidden anti-counterfeiting measures, worn and stained documents, etc. Therefore, from this point of view, the robustness and applicability of the prior art are also poor. Summary of the invention
[0004] The embodiments of the present invention provide a document authenticity verification method, device and storage medium, which can not only improve the efficiency of the verification, but also improve the accuracy, robustness and applicability of the verification.
[0005] The embodiment of the present invention provides a method for verifying the authenticity of a certificate, comprising:
[0006] Acquire a verification document image to be inspected and a template image corresponding to the verification document image to be inspected;
[0007] The deep features of the to-be-inspected document image and the deep features of the template image are respectively extracted by a preset trained deep convolutional neural network model;
[0008] Extracting texture and shape features of the to-be-tested document image and the template image respectively, to obtain concrete features of the to-be-tested document image and the template image;
[0009] Fusing the depth features of the image of the verification document to be inspected with the concrete features of the image of the verification document to be inspected to obtain the anti-counterfeiting features of the image of the verification document to be inspected;
[0010] Fusing the depth features of the template image with the concrete features of the template image to obtain the anti-counterfeiting features of the template image;
[0011] The cosine similarity between the anti-counterfeiting feature of the to-be-checked verification document image and the anti-counterfeiting feature of the template image is calculated, and when the cosine similarity is greater than a preset threshold, it is determined that the certificate corresponding to the to-be-checked verification document image is authentic.
[0012] Optionally, in some embodiments of the present application, respectively extracting the depth features of the to-be-tested document image and the depth features of the template image by using a preset trained deep convolutional neural network model includes:
[0013] Obtaining a preset trained deep convolutional neural network model, wherein the trained deep convolutional neural network model includes a plurality of feature extraction layers with different receptive fields;
[0014] Using the feature extraction layer to extract features from the to-be-tested document image and the template image respectively, to obtain feature information of multiple different scales corresponding to the to-be-tested document image and feature information of multiple different scales corresponding to the template image;
[0015] Fusing feature information of multiple different scales corresponding to the image of the document to be inspected to obtain a depth feature of the image of the document to be inspected;
[0016] The feature information of multiple different scales corresponding to the template image is fused to obtain the depth feature of the template image.
[0017] Optionally, in some embodiments of the present application, the fusing of feature information of multiple different scales corresponding to the image of the document to be inspected to obtain the depth feature of the image of the document to be inspected is specifically: performing a global average pooling operation on the feature information of multiple different scales corresponding to the image of the document to be inspected to obtain a one-dimensional feature vector corresponding to the image of the document to be inspected, and performing vector concatenation on the one-dimensional feature vector corresponding to the image of the document to be inspected to obtain the depth feature of the image of the document to be inspected;
[0018] The fusing of feature information of multiple scales corresponding to the template image to obtain the deep features of the template image is specifically as follows: performing a global average pooling operation on feature information of multiple scales corresponding to the template image to obtain a one-dimensional feature vector corresponding to the template image, and performing vector concatenation on the one-dimensional feature vectors corresponding to the template image to obtain the deep features of the template image.
[0019] Optionally, in some embodiments of the present application, respectively extracting texture and shape features of the to-be-tested document image and the template image to obtain concrete features of the to-be-tested document image and the template image includes:
[0020] Calculating the directional gradient histogram feature vector of the to-be-tested document image to obtain the concrete features of the to-be-tested document image;
[0021] The directional gradient histogram feature vector of the template image is calculated to obtain the concrete features of the template image.
[0022] Optionally, in some embodiments of the present application, the step of calculating the directional gradient histogram feature vector of the to-be-inspected verification document image to obtain the concrete features of the to-be-inspected verification document image is specifically as follows: preprocessing the to-be-inspected verification document image to obtain a preprocessed document image, wherein the preprocessed document image includes a plurality of blocks, calculating the gradient amplitude and gradient direction of each pixel point in the preprocessed document image, calculating the normalized histogram of each block in the preprocessed document image according to the gradient amplitude and gradient direction of each pixel point in the preprocessed document image, and performing vector splicing on the normalized histograms of all blocks in the preprocessed document image to obtain the concrete features of the to-be-inspected verification document image;
[0023] The step of calculating the directional gradient histogram feature vector of the template image to obtain the concrete features of the template image is specifically as follows: preprocessing the template image to obtain a preprocessed template image, wherein the preprocessed template image includes a plurality of blocks, calculating the gradient amplitude and gradient direction of each pixel in the preprocessed template image, calculating the normalized histogram of each block in the preprocessed template image according to the gradient amplitude and gradient direction of each pixel in the preprocessed template image, and performing vector splicing on the normalized histograms of all blocks in the preprocessed template image to obtain the concrete features of the template image.
[0024] Optionally, in some embodiments of the present application, the normalized histogram of each block in the preprocessed document image is calculated according to the gradient amplitude and gradient direction of each pixel in the preprocessed document image, specifically: the preprocessed document image is divided into a plurality of cells, in each cell, the gradient amplitudes of pixels located in the same gradient direction interval are superimposed based on the gradient direction of each pixel to obtain the histogram of each cell, adjacent cells within a preset range are taken as a block, the histograms of the cells in each block are normalized to obtain the normalized histogram of each block in the preprocessed document image;
[0025] The method of calculating the normalized histogram of each block in the preprocessed template image according to the gradient amplitude and gradient direction of each pixel in the preprocessed template image is specifically as follows: the preprocessed template image is divided into a plurality of cells, and in each cell, the gradient amplitudes of pixels located in the same gradient direction interval are superimposed based on the gradient direction of each pixel to obtain the histogram of each cell, and adjacent cells within a preset range are taken as a block, and the histograms of the cells in each block are normalized to obtain the normalized histogram of each block in the preprocessed template image.
[0026] Optionally, in some embodiments of the present application, before acquiring the image of the document to be inspected and the template image corresponding to the image of the document to be inspected, the process further includes:
[0027] Capture multiple images of known authentic documents;
[0028] Preprocessing and normalizing the images of the plurality of known authentic certificates to obtain a plurality of processed images;
[0029] Saving the multiple processed images as template images in a base library;
[0030] The obtaining of the image of the document to be inspected and the template image corresponding to the image of the document to be inspected specifically includes: obtaining the image of the document to be inspected and obtaining the template image corresponding to the image of the document to be inspected from a base database.
[0031] Optionally, in some embodiments of the present application, the acquiring of the image of the document to be inspected and the template image corresponding to the image of the document to be inspected includes:
[0032] Obtaining a document image to be inspected, and determining the document type, version information, and issuance information of the document image to be inspected;
[0033] A template image corresponding to the to-be-tested document image is obtained according to the document type, version information and issuance information.
[0034] Accordingly, the embodiment of the present application also provides a document authenticity verification device, including:
[0035] An acquisition unit, used to acquire an image of a document to be inspected and a template image corresponding to the image of the document to be inspected;
[0036] A first extraction unit is used to extract the depth features of the to-be-inspected document image and the depth features of the template image respectively through a preset trained deep convolutional neural network model;
[0037] A second extraction unit is used to extract texture and shape features of the to-be-inspected document image and the template image respectively, so as to obtain concrete features of the to-be-inspected document image and the template image;
[0038] A fusion unit, configured to fuse the depth features of the to-be-tested document image with the concrete features of the to-be-tested document image to obtain the anti-counterfeiting features of the to-be-tested document image; and to fuse the depth features of the template image with the concrete features of the template image to obtain the anti-counterfeiting features of the template image;
[0039] The verification unit is used to calculate the cosine similarity between the anti-counterfeiting feature of the verification document image to be verified and the anti-counterfeiting feature of the template image, and when the cosine similarity is greater than a preset threshold, determine that the certificate corresponding to the verification document image to be verified is authentic.
[0040] In addition, an embodiment of the present application further provides a storage medium, which stores a plurality of instructions, and the instructions are suitable for loading by a processor to execute operations in any one of the document authenticity verification methods provided in the embodiment of the present application.
[0041] After obtaining the image of the document to be inspected, the embodiment of the present application can obtain the template image corresponding to the image of the document to be inspected, and then, on the one hand, through the preset trained deep convolutional neural network model, respectively extract the depth features of the image of the document to be inspected and the template image, and on the other hand, respectively extract the texture and shape features of the image of the document to be inspected and the template image to obtain the concrete features of the image of the document to be inspected and the template image, and then, respectively fuse their respective depth features and concrete features to obtain the anti-counterfeiting features of the image of the document to be inspected and the anti-counterfeiting features of the template image, and finally, by calculating the cosine similarity of the two anti-counterfeiting features and judging whether the cosine similarity is greater than a preset threshold, the authenticity of the image of the document to be inspected can be determined, for example, if the cosine similarity is greater than the preset threshold, it is determined that the document corresponding to the image of the document to be inspected is authentic, and so on. Since the scheme can realize automatic extraction and comparison of anti-counterfeiting features of certificates without too much manual intervention, it can not only improve the inspection efficiency and meet the needs of large-scale certificate inspection, but also reduce the influence of human factors, avoid misoperation, and improve the accuracy and consistency of inspection; in addition, since the anti-counterfeiting features based on which the authenticity is judged by this scheme are a fusion of deep features and concrete features, when making authenticity judgments, it can fully utilize the abstractness of deep features while taking into account the details of concrete features, thus achieving feature complementarity and enhancement. This feature complementarity and enhancement enables it to more comprehensively describe the anti-counterfeiting features of certificates, and can be inspected even in complex situations such as some relatively concealed anti-counterfeiting means, wear and stains on certificates, etc., greatly improving the accuracy, robustness and applicability of authenticity judgments. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] 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 those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0043] Figure 1 is a flow chart of a method for verifying the authenticity of a certificate provided in an embodiment of the present application;
[0044] Figure 2 Schematic diagram of the receptive field in the document authenticity verification method provided in the embodiment of the present application;
[0045] Figure 3 is a schematic diagram of a framework for extracting anti-counterfeiting features in an embodiment of the present application;
[0046] Figure 4 It is a schematic diagram of a framework of a method for verifying the authenticity of a certificate provided in an embodiment of the present application;
[0047] Figure 5 is another flow chart of the method for verifying the authenticity of a certificate provided in an embodiment of the present application;
[0048] Figure 6 is another framework example diagram of the document authenticity verification method provided in the embodiment of the present application;
[0049] Figure 7 is an example diagram of various anti-counterfeiting features in the embodiments of the present application;
[0050] Figure 8 is a schematic diagram of a framework for deep feature extraction in an embodiment of the present application;
[0051] Fig. 9 It is a structural schematic diagram of a certificate authenticity verification device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0052] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0053] The embodiments of the present application provide a method, device and storage medium for verifying the authenticity of a certificate. The following are detailed descriptions of each. It should be noted that the order of description of the following embodiments is not intended to limit the preferred order of the embodiments.
[0054] This embodiment will be described from the perspective of a certificate authenticity verification device. In specific implementation, the certificate authenticity verification device can be integrated into an electronic device, such as a server or a terminal. The terminal can include a mobile phone, a tablet computer, a laptop computer and / or a personal computer (PC, Personal Computer), etc.
[0055] A method for verifying the authenticity of a certificate comprises: obtaining a certificate image to be verified and a template image corresponding to the certificate image to be verified; respectively extracting the depth features of the certificate image to be verified and the depth features of the template image through a preset trained deep convolutional neural network model; respectively extracting texture and shape features of the certificate image to be verified and the template image to obtain the concrete features of the certificate image to be verified and the concrete features of the template image; fusing the depth features of the certificate image to be verified and the concrete features of the certificate image to be verified to obtain the anti-counterfeiting features of the certificate image to be verified; fusing the depth features of the template image and the concrete features of the template image to obtain the anti-counterfeiting features of the template image; calculating the cosine similarity between the anti-counterfeiting features of the certificate image to be verified and the anti-counterfeiting features of the template image, and determining that the certificate corresponding to the certificate image to be verified is authentic when the cosine similarity is greater than a preset threshold.
[0056] For example, Figure 1 As shown, the specific process of the certificate authenticity verification method can be as follows:
[0057] 101. Obtain a document image to be inspected and a template image corresponding to the document image to be inspected; for example, the specific steps may be as follows:
[0058] The image of the verification document to be inspected is obtained, and the attribute information of the image of the verification document to be inspected is determined, and then the template image corresponding to the image of the verification document to be inspected is obtained according to the attribute information.
[0059] There are many ways to obtain the image of the document to be inspected. For example, the image of the document to be inspected can be acquired by photographing or scanning, and the like.
[0060] The attribute information of the image of the document to be inspected may include information such as document type, version information and issuance information. The document type refers to the purpose and nature of the document, for example, it may include resident identity card, passport, Hong Kong and Macao pass, birth certificate, lawyer's license, non-commissioned officer's license, student ID card, graduation certificate, driver's license, marriage certificate and other documents; version information refers to the version of the document, and the production technology and document style used in different versions may be different; and issuance information may include information such as the issuance structure, issuance location and issuance time of the document.
[0061] That is to say, after obtaining the image of the document to be inspected, the document type, version information, and issuance information of the document image to be inspected can be determined first, and then the template image corresponding to the document image to be inspected can be obtained according to the document type, version information, and issuance information. For example, if the document to be inspected is the first edition of the passport issued by China, then at this time, the template image corresponding to the "first edition of the passport issued by China" can be obtained, and so on.
[0062] Among them, the template image is a series of pre-stored images, which contain all the feature data of the "known to be authentic document" used for anti-counterfeiting, such as optically variable ink features, micro-printing features, ultraviolet features, infrared features, and secret mark features, etc. These feature data can be obtained from the "known to be authentic" authentic document. Of course, in order to ensure the consistency and comparability of these feature data, after the feature data is extracted from the "known to be authentic" authentic document, these feature data can be preprocessed and normalized. The specific content of the preprocessing can be determined according to the needs of the actual application and will not be elaborated here.
[0063] Optionally, the template image can be stored in a base database, which can be stored in a server or a terminal. In order to ensure its versatility and extensibility, the base database can store template images of different certificate types, version information, and issuance information, and store the corresponding relationship between the template image and attribute information such as certificate type, version information, and issuance information for subsequent calls. That is, before the step of "obtaining the image of the certificate to be inspected, and the template image corresponding to the image of the certificate to be inspected", the certificate authenticity inspection method can also include:
[0064] Collect multiple images of certificates known to be authentic, perform preprocessing and normalization on the multiple images of certificates known to be authentic, obtain multiple processed images, and save the multiple processed images as template images in a base database.
[0065] At this time, the step of "obtaining the image of the document to be inspected and the template image corresponding to the image of the document to be inspected" can specifically be: obtaining the image of the document to be inspected and obtaining the template image corresponding to the image of the document to be inspected from the base database. For example, a template image that is consistent with the document type, version information, and issuance information of the image of the document to be inspected can be obtained from the base database.
[0066] 102. Through the preset trained deep convolutional neural network model, the deep features of the to-be-tested document image and the deep features of the template image are extracted respectively, for example, see Figure 3 .
[0067] There are many ways to respectively extract the depth features of the to-be-tested document image and the depth features of the template image through the preset trained deep convolutional neural network model. For example, the following steps (steps A1 to A4) may be specifically included:
[0068] A1. Obtain a preset trained deep convolutional neural network model, wherein the trained deep convolutional neural network model includes multiple feature extraction layers with different receptive fields.
[0069] The so-called receptive field, also known as the receptive domain, refers to the size of the area where the pixels on the feature map output by each layer of the convolutional neural network are mapped back to the input image. In layman's terms, it is the size of a point on the feature map relative to the original image, and is also the area of the input image that the convolutional neural network feature can see. For example, see Figure 2 Generally, the size of the receptive field of the pixels in the output feature map of the first convolution layer, such as C1, is equal to the size of the convolution kernel (filter size), while the size of the receptive field of the deep convolution layer, such as C4, is related to the size and step size of the convolution kernel of all previous layers. Therefore, different receptive fields can capture information at different levels, thereby achieving the purpose of extracting feature information of different scales.
[0070] A2. Use the feature extraction layer to perform feature extraction on the to-be-tested document image and the template image respectively, to obtain feature information of multiple different scales corresponding to the to-be-tested document image and feature information of multiple different scales corresponding to the template image.
[0071] For example, the verification document image to be inspected and the template image can be respectively input into the trained deep convolutional neural network model, and feature extraction can be performed on them using the multiple feature extraction layers with different receptive fields to obtain feature information of multiple scales corresponding to the verification document image to be inspected and feature information of multiple scales corresponding to the template image.
[0072] Among them, the input order of the document image to be inspected and the template image may not be limited, and may be determined according to the needs of the actual application. For example, taking the input of the document image to be inspected as an example, the multiple feature extraction layers with different receptive fields can be used to perform feature extraction on the document image to be inspected, and the feature maps output by the multiple feature extraction layers are obtained (each feature extraction layer is equivalent to a feature channel, so at this time, the feature maps output by multiple feature channels can be obtained), and different feature maps contain feature information of different scales. Therefore, at this time, it is equivalent to obtaining feature information of multiple scales corresponding to the document image to be inspected; then, the multiple feature extraction layers with different receptive fields are used to extract features from the template image, and the processing of the document image to be inspected is the same. At this time, feature information of multiple scales corresponding to the template image can also be obtained, and so on, which will not be elaborated here.
[0073] A3. Fusing feature information of multiple different scales corresponding to the image of the document to be inspected to obtain a depth feature of the image of the document to be inspected.
[0074] For example, a global average pooling (GAP) operation can be performed on feature information of multiple scales of different scales corresponding to the image of the document to be inspected (i.e., feature maps output by multiple feature channels) to obtain a one-dimensional feature vector corresponding to the image of the document to be inspected. Then, the one-dimensional feature vector corresponding to the image of the document to be inspected is vector-concatenated to obtain the deep features of the image of the document to be inspected.
[0075] A4. Fusing feature information of multiple different scales corresponding to the template image to obtain the depth feature of the template image.
[0076] For example, similar to step A3, a global average pooling (i.e., GAP) operation can be performed on feature information of multiple scales corresponding to the template image (i.e., feature maps output by multiple feature channels) to obtain a one-dimensional feature vector corresponding to the template image. Then, the one-dimensional feature vector corresponding to the template image is vector-concatenated to obtain the deep features of the template image.
[0077] Optionally, in steps A3 and A4, the mathematical expression of the global average pooling operation may be as follows:
[0078]
[0079] Among them, featurei represents the global average pooling result of the i-th feature channel. For example, featureconv1 represents the global average pooling result of the feature map output by the conv1 layer (i.e., a one-dimensional feature vector), and featureconv2_x represents the global average pooling result of the feature map output by the conv2_x layer (i.e., a one-dimensional feature vector), and so on; x i,h,w It represents the value of the i-th feature channel at position (h, w) in the feature map, and H and W represent the height and width of the feature map respectively.
[0080] Optionally, in steps A3 and A4, the mathematical expression for concatenating one-dimensional feature vectors may be as follows:
[0081] [deep_feature
[0082] =[featureconv1, featureconv2_x, featureconv3_x, featureconv4_x, featureconv5_x]]
[0083] Among them, deep_feature represents the fused deep feature vector, and featureconv* represents the feature vector of the corresponding layer (a one-dimensional feature vector in the embodiment of the present application).
[0084] 103. Extract texture and shape features from the to-be-inspected document image and the template image respectively to obtain concrete features of the to-be-inspected document image and the template image.
[0085] For example, Figure 3 As shown, specifically, a traditional image processing module can be utilized (for the convenience of description, in the embodiment of the present application, the module capable of extracting texture and shape features of an image is referred to as a traditional image processing module) to extract texture and shape features of the to-be-inspected document image and the template image, respectively, to obtain the concrete features of the to-be-inspected document image and the concrete features of the template image.
[0086] There are many ways to extract texture and shape features. For example, it can be achieved by extracting the traditional image feature of the Histogram of Oriented Gradient (HOG). That is, the step of "extracting texture and shape features from the to-be-tested document image and the template image, respectively, to obtain the concrete features of the to-be-tested document image and the concrete features of the template image" can be specifically as follows:
[0087] B1. Calculate the HOG feature vector of the image of the document to be inspected to obtain the concrete features of the image of the document to be inspected.
[0088] For example, the image of the document to be inspected can be preprocessed to obtain a preprocessed document image, wherein the preprocessed document image includes multiple blocks, and then the gradient amplitude and gradient direction of each pixel in the preprocessed document image are calculated, and according to the gradient amplitude and gradient direction of each pixel in the preprocessed document image, the normalized histogram of each block in the preprocessed document image is calculated, and then, the normalized histograms of all blocks in the preprocessed document image are vector-concatenated to obtain a long vector, which is the HOG feature vector of the document image to be inspected. For the convenience of description, in the embodiment of the present application, the HOG feature vector of the document image to be inspected is also referred to as the concrete feature of the document image to be inspected.
[0089] Optionally, the step of "calculating the normalized histogram of each block in the preprocessed document image according to the gradient amplitude and gradient direction of each pixel in the preprocessed document image" may be specifically as follows:
[0090] The preprocessed document image is divided into multiple cells. In each cell, the gradient amplitudes of pixels in the same gradient direction interval (bin) are superimposed based on the gradient direction of each pixel to obtain the histogram of each cell (that is, for each pixel point, its gradient amplitude can be superimposed into the corresponding histogram bin according to its gradient direction, which is equivalent to counting the sum of the gradient amplitudes in each bin). Then, the adjacent cells within a preset range are taken as a block (this operation can improve the robustness of the feature), and the histograms of the cells in each block are normalized to obtain the normalized histograms of each block in the preprocessed document image.
[0091] B2. Calculate the HOG feature vector of the template image to obtain the concrete features of the template image.
[0092] For example, the template image can be preprocessed to obtain a preprocessed template image, wherein the preprocessed template image includes multiple blocks, and then the gradient amplitude and gradient direction of each pixel in the preprocessed template image are calculated, and according to the gradient amplitude and gradient direction of each pixel in the preprocessed template image, the normalized histogram of each block in the preprocessed template image is calculated, and then, the normalized histograms of all blocks in the preprocessed template image are vector-concatenated to obtain a long vector, which is the HOG feature vector of the template image. For the convenience of description, in the embodiment of the present application, the HOG feature vector of the template image is also referred to as the concrete feature of the template image.
[0093] Optionally, the step of “calculating the normalized histogram of each block in the preprocessed template image according to the gradient amplitude and gradient direction of each pixel in the preprocessed template image” may specifically include:
[0094] The preprocessed template image is divided into multiple cells. In each cell, the gradient amplitudes of pixels in the same gradient direction interval (bin) are superimposed based on the gradient direction of each pixel to obtain the histogram of each cell (i.e., for each pixel point, its gradient amplitude can be superimposed into the corresponding histogram bin according to its gradient direction, which is equivalent to counting the sum of the gradient amplitudes in each bin). Then, the adjacent cells within a preset range are taken as a block (this operation can improve the robustness of the feature), and the histograms of the cells in each block are normalized to obtain the normalized histograms of each block in the preprocessed template image.
[0095] It should be noted that in steps B1 and B2, when dividing cells, the number of cells can be determined according to the needs of the actual application, and is not limited here. The division of gradient direction intervals and the specific content of preprocessing can also be determined according to the needs of the actual application. For example, the gradient direction can be divided into 9 or 18 intervals (bins). For another example, the preprocessing can include grayscale and normalization processing, which will not be repeated here.
[0096] Optionally, in steps B1 and B2, the following formula may be used to calculate the gradient magnitude and gradient direction of each pixel point, as follows:
[0097]
[0098]
[0099] Among them, M(x,y) is the gradient amplitude, θ(x,y) is the gradient direction, G x (x,y) and G y (x, y) represents the horizontal and vertical gradients of the pixel point (x, y), respectively. x (x,y) and G y The value of (x,y) can be obtained by convolving the original image with the convolution kernels [-1,0,1] and [-1,0,1]^T respectively.
[0100] Optionally, in steps B1 and B2, there may be multiple methods for normalizing the histograms of cells in each block, for example, L2-norm may be used, as follows:
[0101]
[0102] Among them, H normis the result obtained after normalizing the histogram of the cells in the block, H is the histogram in the block, H i is the value of the i-th bin of the histogram, n is the total number of bins, and ∑ is a small constant that can be set according to the needs of the actual application to prevent the divisor from being zero.
[0103] Optionally, steps 102 and 103 may be performed in any order, which will not be described in detail here.
[0104] 104. The depth feature of the to-be-tested document image is fused with the concrete feature of the to-be-tested document image to obtain the anti-counterfeiting feature of the to-be-tested document image, and the depth feature of the template image is fused with the concrete feature of the template image to obtain the anti-counterfeiting feature of the template image, for example, see Figure 3 and Figure 4 .
[0105] There are many fusion methods, for example, it can be implemented by vector concatenation, that is, the depth features of the image of the document to be inspected and the concrete features of the image of the document to be inspected can be concatenated to obtain the anti-counterfeiting features of the image of the document to be inspected, and the depth features of the template image and the concrete features of the template image can be concatenated to obtain the anti-counterfeiting features of the template image.
[0106] For example, take the depth feature (i.e., the depth feature vector) as D and the concrete feature (i.e., the HOG feature vector) as H, where D∈R m , m is the dimension of the deep feature vector, H∈R n , n is the dimension of the HOG feature vector, then the formula for concatenating the two feature vectors D and H can be as follows:
[0107] [F=[D,H]]
[0108] Among them, F is the fused (splicing) feature vector, which is also the anti-counterfeiting feature in the embodiment of the present application; the so-called splicing operation refers to connecting the two feature vectors end to end to form a new feature vector F.
[0109] The spliced feature vector F contains both the abstract features of deep learning and the texture and shape features of traditional image processing technology. Therefore, it can describe the anti-counterfeiting features of the document more comprehensively.
[0110] That is to say, the anti-counterfeiting feature F of the image of the document to be tested A It can be calculated by the following formula:
[0111] [F A =[D A ,HA ]]
[0112] Among them, D A is the depth feature of the image of the document to be inspected (i.e., the depth feature vector), H A is the concrete feature of the image of the document to be tested (i.e., HOG feature vector), where D A ∈R m , m is the dimension of the deep feature, H A ∈R n , n is the dimension of the representational feature.
[0113] Similarly, the anti-counterfeiting feature F of the document image to be tested B It can be calculated by the following formula:
[0114] [F B =[D B ,H B ]]
[0115] Among them, D B is the deep feature of the template image (i.e., the deep feature vector), H B is the concrete feature of the template image (i.e., HOG feature vector), where D B ∈R m , m is the dimension of the deep feature, H B ∈R n , n is the dimension of the representational feature.
[0116] 105. Calculate the cosine similarity between the anti-counterfeiting feature of the verification document image to be checked and the anti-counterfeiting feature of the template image. When the cosine similarity is greater than a preset threshold, determine that the document corresponding to the verification document image to be checked is authentic. Otherwise, when the cosine similarity is less than or equal to the preset threshold, determine that the document corresponding to the verification document image to be checked is fake.
[0117] It should be noted that cosine similarity is a method of evaluating the similarity of two vectors by measuring the cosine value of the angle between them. For two vectors, the closer their cosine similarity values are to 1, the more similar they are; the closer they are to -1, the less similar they are. A , the anti-counterfeiting feature of the template image is F B For example, their cosine similarity (F A ,F B ) can be calculated as follows:
[0118]
[0119] According to the calculated cosine similarity value, a threshold can be set to judge the authenticity of the document to be tested. If the cosine similarity value is greater than the threshold, the document corresponding to the image of the document to be tested (i.e. the document to be tested) is judged to be authentic; otherwise, if the cosine similarity is less than or equal to the threshold, the document corresponding to the image of the document to be tested (i.e. the document to be tested) is judged to be fake.
[0120] The preset threshold value can be set and adjusted according to the needs of actual application, which will not be elaborated here.
[0121] Optionally, in a specific implementation, in order to improve processing efficiency, in steps 102 to 104, in addition to using the same trained deep convolutional neural network model and the traditional image processing module (a module for extracting texture and shape features) to extract features from the document image to be inspected and the template image respectively, two parallel sub-networks may also be used to process the document image to be inspected and the template image in parallel, for example, Figure 4 As shown, the first sub-network can be used to extract and fuse the deep features and figurative features of the image of the document to be inspected, while the second sub-network can be used to extract and fuse the deep features and figurative features of the template image, so that the anti-counterfeiting features of the image of the document to be inspected and the anti-counterfeiting features of the template image can be quickly obtained. The first sub-network and the second sub-network are arranged in parallel, and the structure and parameter settings are the same, that is, the first sub-network and the second sub-network both include a trained deep convolutional neural network model and a traditional image processing module.
[0122] If two parallel sub-networks are used, such as a first sub-network and a second sub-network that process the document image to be inspected and the template image in parallel, then “obtaining a preset trained deep convolutional neural network model” may specifically include:
[0123] A first sub-network and a second sub-network arranged in parallel are obtained, wherein the first sub-network and the second sub-network both include a trained deep convolutional neural network model.
[0124] At this time, the step of "using the feature extraction layer to perform feature extraction on the to-be-inspected verification document image and the template image respectively to obtain feature information of multiple scales corresponding to the to-be-inspected verification document image and feature information of multiple scales corresponding to the template image" may specifically include: using the multiple feature extraction layers of the trained deep convolutional neural network model in the first subnetwork to perform feature extraction on the to-be-inspected verification document image to obtain feature information of multiple scales corresponding to the to-be-inspected verification document image; and using the multiple feature extraction layers of the trained deep convolutional neural network model in the second subnetwork to perform feature extraction on the template image to obtain feature information of multiple scales corresponding to the template image.
[0125] The step of "extracting texture and shape features from the image of the document to be inspected and the template image respectively to obtain concrete features of the image of the document to be inspected and concrete features of the template image" may specifically include: using the traditional image processing module in the first sub-network to extract texture and shape features from the image of the document to be inspected to obtain concrete features of the image of the document to be inspected, and using the traditional image processing module in the second sub-network to extract texture and shape features from the template image to obtain concrete features of the template image.
[0126] The step of "fusing the deep features of the image of the document to be inspected and the concrete features of the image of the document to be inspected to obtain the anti-counterfeiting features of the image of the document to be inspected" may specifically include: utilizing the fusion module in the first subnetwork (for the convenience of description, in the embodiment of the present application, the module for fusing the deep features and the concrete features is referred to as a fusion module) to fuse the deep features of the image of the document to be inspected and the concrete features of the image of the document to be inspected to obtain the anti-counterfeiting features of the image of the document to be inspected.
[0127] The step of "fusing the deep features of the template image and the concrete features of the template image to obtain the anti-counterfeiting features of the template image" may specifically include: using the fusion module in the second sub-network to fuse the deep features of the template image and the concrete features of the template image to obtain the anti-counterfeiting features of the template image.
[0128] Optionally, in a specific implementation, the trained deep convolutional neural network model may adopt models such as ResNet50, ResNet101 or ResNet152. For the convenience of description, in the embodiments of the present application, the trained deep convolutional neural network model will be described using ResNet50 as an example.
[0129] ResNet50 is a 50-layer deep convolutional neural network, which is mainly composed of convolutional layers, batch normalization layers, rectified linear unit (ReLU) activation functions and residual blocks (residual blocks are the core part of the ResNet50 model, which solves the gradient vanishing problem in deep networks by introducing identity mapping). The hierarchical structure of ResNet50 can be roughly divided into 5 stages: conv1, conv2_x, conv3_x, conv4_x and conv5_x. Each stage consists of multiple residual blocks. As the stage goes deeper, the size of the feature map gradually decreases, while the number of channels gradually increases, so that feature information of different scales can be extracted.
[0130] Optionally, the network parameters of the trained deep convolutional neural network model and the selection of the feature extraction layer can also be determined according to the needs of the actual application.
[0131] For example, taking the ResNet50 model as an example, several key layers such as conv1, conv2_x, conv3_x, conv4_x, conv5_x, etc. can be selected as feature extraction layers. The characteristics of these key layers can be as follows:
[0132] conv1: This is the first convolutional layer of the trained deep convolutional neural network model, and its output feature map retains the original detail information of the image.
[0133] conv2_x: This is the first residual block group of the deep convolutional neural network model after training. The feature map it outputs is more abstract than conv1, but still contains certain detailed information.
[0134] conv3_x: This is the second residual block group of the trained deep convolutional neural network model. The feature map it outputs is further abstracted compared to conv2_x, so it is very helpful for identifying mid-level features.
[0135] conv4_x: This is the third residual block group of the trained deep convolutional neural network model, and its output feature map pays more attention to the high-level semantic information of the image.
[0136] conv5_x: This is the last residual block group of the trained deep convolutional neural network model, and its output feature map is a highly abstract representation of the global structure of the image.
[0137] Since the feature maps output by these key layers can contain feature information of different scales, using these key layers as feature extraction layers can reflect the characteristics of the input image from multiple angles and degrees, thereby achieving the purpose of describing the input image more comprehensively, in detail and accurately.
[0138] Optionally, the trained deep convolutional neural network model can be directly used as a trained deep convolutional neural network model or pre-set by the operation and maintenance personnel, or it can be obtained by self-training of the document authenticity inspection device. That is, before the step of "extracting the deep features of the document image to be inspected and the deep features of the template image respectively through the preset trained deep convolutional neural network model", the document authenticity inspection method can also include:
[0139] A plurality of images of certificates of known authenticity are collected as training samples, wherein these training samples are marked with true values. The deep features of the training samples are extracted through a preset deep convolutional neural network model, and the authenticity of the training samples is predicted based on the extracted deep features to obtain the predicted values of the training samples. According to the true values and predicted values of the training samples, the deep convolutional neural network model is converged using a preset loss function to obtain a trained deep convolutional neural network model.
[0140] Optionally, in order to improve the accuracy of the model, in addition to training the deep convolutional neural network model alone, the deep convolutional neural network model can also be trained in combination with the operation process of the entire document authenticity inspection device, that is, before the step of "extracting the deep features of the document image to be inspected and the deep features of the template image respectively through the preset trained deep convolutional neural network model", the document authenticity inspection method can also include:
[0141] S1. Collect multiple images of certificates of known authenticity as training samples, wherein these training samples are labeled with true values (for example, labeling the training samples as true or false).
[0142] S2. Obtain a template image corresponding to the training sample.
[0143] S3. Through a preset deep convolutional neural network model, the deep features of the training sample and the deep features of the template image are extracted respectively.
[0144] S4. Extract texture and shape features from the training sample and the template image respectively to obtain the concrete features of the training sample and the concrete features of the template image.
[0145] S5. Fusing the deep features of the training sample with the concrete features of the training sample to obtain the anti-counterfeiting features of the training sample, and fusing the deep features of the template image with the concrete features of the template image to obtain the anti-counterfeiting features of the template image.
[0146] S6. Calculate the cosine similarity between the anti-counterfeiting feature of the training sample and the anti-counterfeiting feature of the template image. When the cosine similarity is greater than a preset threshold, determine that the predicted value of the training sample is true. Otherwise, when the cosine similarity is less than or equal to the preset threshold, determine that the predicted value of the training sample is false.
[0147] S7. According to the true value and predicted value of the training sample, the preset loss function is used to converge the deep convolutional neural network model to obtain the trained deep convolutional neural network model.
[0148] Among them, the loss function can be set according to the needs of actual application and will not be elaborated here.
[0149] As can be seen from the above, after obtaining the image of the verification document to be inspected, the present embodiment can obtain the template image corresponding to the image of the verification document to be inspected, and then, on the one hand, through the preset trained deep convolutional neural network model, respectively extract the depth features of the image of the verification document to be inspected and the template image, and on the other hand, respectively extract the texture and shape features of the image of the verification document to be inspected and the template image to obtain the concrete features of the image of the verification document to be inspected and the template image, and then, respectively fuse their respective depth features and concrete features to obtain the anti-counterfeiting features of the image of the verification document to be inspected and the anti-counterfeiting features of the template image, and finally, by calculating the cosine similarity of the two anti-counterfeiting features and judging whether the cosine similarity is greater than a preset threshold, the authenticity of the image of the verification document to be inspected can be determined, for example, if the cosine similarity is greater than the preset threshold, it is determined that the document corresponding to the image of the verification document to be inspected is authentic, and so on. Since the scheme can realize automatic extraction and comparison of anti-counterfeiting features of certificates without too much manual intervention, it can not only improve the inspection efficiency and meet the needs of large-scale certificate inspection, but also reduce the influence of human factors, avoid misoperation, and improve the accuracy and consistency of inspection; in addition, since the anti-counterfeiting features based on which the authenticity is judged by this scheme are a fusion of deep features and concrete features, when making authenticity judgments, it can fully utilize the abstractness of deep features while taking into account the details of concrete features, thus achieving feature complementarity and enhancement. This feature complementarity and enhancement enables it to more comprehensively describe the anti-counterfeiting features of certificates, and can be inspected even in complex situations such as some relatively concealed anti-counterfeiting means, wear and stains on certificates, etc., greatly improving the accuracy, robustness and applicability of authenticity judgments.
[0150] The method described in the above embodiment is further described in detail below with examples.
[0151] In this embodiment, the document authenticity detection device is specifically integrated into an electronic device, the deep convolutional neural network model adopts the ResNet50 model, and the document is specifically a passport of Country X.
[0152] like Figure 5 and Figure 6 As shown, the specific process of the certificate authenticity detection method can be as follows:
[0153] 201. The electronic device collects an image of the passport of country X to be inspected, obtains an image of the document to be inspected, and obtains a template image corresponding to the passport of country X.
[0154] For example, after obtaining the image of the document to be inspected, the corresponding template image can be obtained according to the document type, version information, and issuance information of the image of the document to be inspected; for example, taking the document type of the passport of country X as "passport of country X", the version information as "second edition", and the issuance information as "issued on September 10, 2000, by region Y of country X" as an example, at this time, a template image with the document type as "passport of country X", the version information as "second edition", and the issuance information belonging to the same issuance interval as "issued on September 10, 2000, by region Y of country X" can be obtained from the base database as the template image corresponding to the image of the document to be inspected.
[0155] Among them, the base database stores template images of various different certificate types, version information and issuance information. These template images contain all the feature data of "known-to-be-authentic certificates" used for anti-counterfeiting, such as optically variable ink features, microprinting features, ultraviolet features, infrared features, and secret mark features.
[0156] For example, taking a passport as an example, Figure 7 As shown, the feature data used for anti-counterfeiting may include optically variable ink features, microtext features, ultraviolet features, and infrared features ( Figure 8 The figure shows the presentation of Figure A under natural light and under infrared light respectively), etc. These feature data can be obtained from a real passport that is "known to be true". Of course, in order to ensure the consistency and comparability of these feature data, after extracting these feature data, these feature data can be preprocessed and normalized. For details, please refer to the previous embodiment, which will not be described here.
[0157] 202. The electronic device obtains a preset trained ResNet50 model, where the ResNet50 model includes multiple feature extraction layers with different receptive fields.
[0158] For example, several key layers such as conv1, conv2_x, conv3_x, conv4_x, conv5_x, etc. can be selected from the ResNet50 model as feature extraction layers.
[0159] Among them, the training method of the trained ResNet50 model can be specifically referred to the previous embodiment, and will not be repeated here.
[0160] 203. The electronic device uses the multiple feature extraction layers of the ResNet50 model to perform feature extraction on the image of the document to be inspected, and obtains feature information of multiple different scales corresponding to the image of the document to be inspected, and uses the multiple feature extraction layers of the ResNet50 model to perform feature extraction on the template image, and obtains feature information of multiple different scales corresponding to the template image.
[0161] For example, see Figure 8 After an image (such as a document image to be inspected or a template image) is input into the ResNet50 model, each feature extraction layer of the ResNet50 model will extract features from the image, and each feature extraction layer will output the corresponding feature map, such as feature Figure 1 ,feature Figure 2 ,...feature map i, where these feature maps record feature information of different scales respectively.
[0162] For example, taking the feature extraction layer including conv1, conv2_x, conv3_x, conv4_x, conv5_x as an example, at this time, conv1 will output the feature Figure 1 , conv2_x will output features Figure 2 , conv3_x will output features Figure 3 , conv4_x will output features Figure 4 , conv5_x will output features Figure 5 ,etc.
[0163] 204. The electronic device fuses the feature information of multiple different scales corresponding to the image of the verification document to be inspected to obtain the depth feature of the image of the verification document to be inspected; and fuses the feature information of multiple different scales corresponding to the template image to obtain the depth feature of the template image.
[0164] For example, Figure 8 As shown, the electronic device can specifically receive feature information of multiple different scales corresponding to the image of the to-be-tested document, such as feature Figure 1 ,feature Figure 2 , ... feature map i is subjected to global average pooling (GAP) operation to obtain the corresponding one-dimensional feature vectors, such as feature vector 1, feature vector 2, ... feature vector i. Then, these one-dimensional feature vectors are fused (such as vector splicing) to obtain the deep features of the image of the document to be inspected.
[0165] Similarly, the electronic device can also generate feature information of multiple scales corresponding to the template image, such as feature Figure 1 ,feature Figure 2 , …feature map i performs a global average pooling (GAP) operation to obtain the corresponding one-dimensional feature vectors, such as feature vector 1, feature vector 2, …feature vector i, and then, these one-dimensional feature vectors are fused (such as vector splicing) to obtain the deep features of the template image.
[0166] The specific method of fusion can be found in the previous embodiments and will not be described in detail here.
[0167] 205. The electronic device calculates the HOG feature vector of the to-be-inspected verification document image to obtain the concrete features of the to-be-inspected verification document image, and calculates the HOG feature vector of the template image to obtain the concrete features of the template image.
[0168] For example, the calculation process of the concrete features of the document image to be inspected can be as follows:
[0169] After the electronic device performs preprocessing such as grayscale conversion and normalization on the document image to be inspected, the gradient amplitude and gradient direction of each pixel in the preprocessed document image are calculated, the gradient direction is divided into 9 or 18 intervals (bins), and the preprocessed document image is divided into multiple cells. Then, in each cell, the gradient amplitudes of pixels located in the same gradient direction interval are superimposed based on the gradient directions of each pixel to obtain the histogram of each cell. Then, adjacent cells within a preset range are combined into a block, and the histograms of the cells in each block are normalized to obtain the normalized histograms of each block in the preprocessed document image. Thereafter, the normalized histograms of all blocks in the preprocessed document image are vector-joined to obtain the HOG feature vector of the document image to be inspected, which is also the concrete feature of the document image to be inspected.
[0170] For another example, the calculation process of the concrete features of the template image can be as follows:
[0171] After the electronic device performs preprocessing such as grayscale and normalization on the template image, it calculates the gradient amplitude and gradient direction of each pixel in the preprocessed template image, divides the gradient direction into 9 or 18 intervals (bins), and divides the preprocessed template image into multiple cells. Then, in each cell, the gradient amplitudes of pixels located in the same gradient direction interval are superimposed based on the gradient directions of each pixel to obtain a histogram of each cell. Then, adjacent cells within a preset range are combined into a block, and the histograms of the cells in each block are normalized to obtain normalized histograms of each block in the preprocessed template image. Thereafter, the normalized histograms of all blocks in the preprocessed template image are vector-joined to obtain the HOG feature vector of the template image, which is also the concrete feature of the template image.
[0172] Among them, the calculation method of the gradient amplitude and the gradient direction, and the method of normalizing the histogram of the cells in each block can be specifically referred to the previous embodiment, and will not be described in detail here.
[0173] It should be noted that step 205 and step 202 may be performed in any order.
[0174] 206. The electronic device fuses the depth feature of the to-be-tested document image with the concrete feature of the to-be-tested document image to obtain the anti-counterfeiting feature of the to-be-tested document image, and fuses the depth feature of the template image with the concrete feature of the template image to obtain the anti-counterfeiting feature of the template image. For example, the following formula may be used for fusion:
[0175] [F A =[D A ,H A ]]
[0176] [F B =[D B ,H B ]]
[0177] Among them, F A is the anti-counterfeiting feature of the document image to be tested, F B is the anti-counterfeiting feature of the template image, D A is the depth feature of the document image to be inspected, H A is the concrete feature of the document image to be inspected, D B is the deep feature of the template image, H B is the concrete feature of the template image, where D A ∈R m , D B ∈R m , m is the dimension of the deep feature, H A ∈R n , H B ∈R n , n is the dimension of the representational feature.
[0178] 207. The electronic device calculates the cosine similarity between the anti-counterfeiting feature of the verification document image to be inspected and the anti-counterfeiting feature of the template image. When the cosine similarity is greater than a preset threshold, it is determined that the passport of Country X to be inspected is authentic. Otherwise, when the cosine similarity is less than or equal to the preset threshold, it is determined that the passport of Country X to be inspected is counterfeit.
[0179] For example, the calculation formula of the cosine similarity can be as follows:
[0180]
[0181] Among them, F A is the anti-counterfeiting feature of the document image to be tested, F B is the anti-counterfeiting feature of the template image, Similarity(F A ,F B ) is F A With F B The cosine similarity of .
[0182] The preset threshold value can be set and adjusted according to the needs of actual application, which will not be elaborated here.
[0183] As can be seen from the above, after the electronic device of this embodiment obtains the image of the document to be inspected, it can obtain the template image corresponding to the image of the document to be inspected, and then, on the one hand, through the preset trained ResNet50 model, respectively extract the depth features of the image of the document to be inspected and the template image, and on the other hand, respectively calculate the HOG feature vectors of the image of the document to be inspected and the template image to obtain the concrete features of the image of the document to be inspected and the template image, and then, respectively fuse their respective deep features and concrete features to obtain the anti-counterfeiting features of the image of the document to be inspected and the anti-counterfeiting features of the template image. Finally, by calculating the cosine similarity of the two anti-counterfeiting features and judging whether the cosine similarity is greater than a preset threshold, the authenticity of the document to be inspected can be determined. For example, if the cosine similarity is greater than the preset threshold, the document to be inspected is determined to be true, otherwise it is false. Since this solution can automatically extract and compare the anti-counterfeiting features of documents without excessive human intervention, it can not only improve the inspection efficiency and meet the needs of large-scale document inspection, but also reduce the impact of human factors, avoid misoperation, and greatly improve the accuracy and consistency of inspection.
[0184] In addition, since the anti-counterfeiting features used by this scheme to judge authenticity are a fusion of deep features and concrete features, when making authenticity judgments, it is possible to fully utilize the abstractness of deep features while taking into account the details of concrete features, thereby achieving feature complementarity and enhancement. This feature complementarity and enhancement enables it to more comprehensively describe the anti-counterfeiting features of the document, which can further improve the accuracy of authenticity judgment while improving its robustness and applicability, so that it can be inspected even in the face of complex situations such as when some anti-counterfeiting means are relatively concealed, or when the document is worn or stained.
[0185] In order to better implement the above method, an embodiment of the present application also provides a device for verifying the authenticity of a certificate, which can be integrated into an electronic device, such as a server or a terminal. The terminal may include a mobile phone, a tablet computer, a laptop computer and / or a personal computer.
[0186] like Fig. 9 As shown, the document authenticity verification device may include an acquisition unit 301, a first extraction unit 302, a second extraction unit 303, a fusion unit 304 and a verification unit 305, as follows:
[0187] (1) Acquisition unit 301;
[0188] The acquisition unit 301 is used to acquire the image of the document to be inspected and the template image corresponding to the image of the document to be inspected.
[0189] For example, the acquisition unit 301 may be specifically configured to acquire the image of the document to be inspected, determine the attribute information of the image of the document to be inspected, and then acquire the template image corresponding to the image of the document to be inspected according to the attribute information.
[0190] The attribute information of the document image to be inspected may include document type, version information, and issuance information.
[0191] (2) a first extraction unit 302;
[0192] The first extraction unit 302 is used to extract the depth features of the to-be-inspected document image and the depth features of the template image respectively through a preset trained deep convolutional neural network model.
[0193] For example, the first extraction unit 302 can be specifically used to obtain a preset trained deep convolutional neural network model, wherein the trained deep convolutional neural network model includes multiple feature extraction layers with different receptive fields, and then, the feature extraction layers are used to perform feature extraction on the to-be-inspected verification document image and the template image, respectively, to obtain feature information of multiple scales corresponding to the to-be-inspected verification document image and feature information of multiple scales corresponding to the template image, and then, the feature information of multiple scales corresponding to the to-be-inspected verification document image is fused to obtain the depth feature of the to-be-inspected verification document image, and the feature information of multiple scales corresponding to the template image is fused to obtain the depth feature of the template image.
[0194] (3) a second extraction unit 303;
[0195] The second extraction unit 303 is used to extract texture and shape features of the to-be-inspected document image and the template image respectively, to obtain the concrete features of the to-be-inspected document image and the concrete features of the template image.
[0196] For example, the second extraction unit 303 may be specifically used to calculate the HOG feature vector of the to-be-inspected document image to obtain the concrete features of the to-be-inspected document image, and calculate the HOG feature vector of the template image to obtain the concrete features of the template image.
[0197] (4) fusion unit 304;
[0198] The fusion unit 304 is used to fuse the depth features of the verification document image to be inspected with the concrete features of the verification document image to be inspected to obtain the anti-counterfeiting features of the verification document image to be inspected; and to fuse the depth features of the template image with the concrete features of the template image to obtain the anti-counterfeiting features of the template image.
[0199] For example, the fusion unit 304 can be specifically used to splice the depth features of the image of the document to be inspected and the concrete features of the image of the document to be inspected to obtain the anti-counterfeiting features of the image of the document to be inspected, and to splice the depth features of the template image and the concrete features of the template image to obtain the anti-counterfeiting features of the template image.
[0200] (5) Inspection unit 305;
[0201] The verification unit 305 is used to calculate the cosine similarity between the anti-counterfeiting feature of the verification document image to be verified and the anti-counterfeiting feature of the template image, and when the cosine similarity is greater than a preset threshold, determine that the document corresponding to the verification document image to be verified is authentic.
[0202] On the contrary, when the cosine similarity is less than or equal to the preset threshold, the verification unit 305 determines that the certificate corresponding to the to-be-verified certificate image is a fake.
[0203] The preset threshold value can be set and adjusted according to the needs of actual application, which will not be elaborated here.
[0204] Optionally, in a specific implementation, the trained deep convolutional neural network model can adopt a model such as ResNet50. The network parameters of the trained deep convolutional neural network model and the selection of the feature extraction layer can also be determined according to the needs of the actual application. For details, please see the previous embodiment and will not be repeated here.
[0205] Optionally, the trained deep convolutional neural network model can be directly used as a trained deep convolutional neural network model or pre-set by the operation and maintenance personnel, or it can be obtained by self-training of the document authenticity inspection device. That is, the document authenticity inspection device can also include a training unit, as follows:
[0206] The training unit is used to collect images of multiple certificates of known authenticity as training samples, wherein the training samples are marked with true values, extract the deep features of the training samples through a preset deep convolutional neural network model, predict the authenticity of the training samples based on the extracted deep features, and obtain the predicted values of the training samples; according to the true values and predicted values of the training samples, use a preset loss function to converge the deep convolutional neural network model to obtain a trained deep convolutional neural network model.
[0207] Optionally, in order to improve the accuracy of the model, in addition to training the deep convolutional neural network model alone, the deep convolutional neural network model can also be trained in combination with the operation process of the entire document authenticity inspection device, that is:
[0208] The training unit can be used to collect images of multiple certificates of known authenticity as training samples, wherein the training samples are marked with true values; obtain a template image corresponding to the training sample; extract the depth features of the training sample and the depth features of the template image respectively through a preset deep convolutional neural network model; extract texture and shape features of the training sample and the template image respectively to obtain the concrete features of the training sample and the concrete features of the template image; fuse the deep features of the training sample with the concrete features of the training sample to obtain the anti-counterfeiting features of the training sample, and fuse the deep features of the template image with the concrete features of the template image to obtain the anti-counterfeiting features of the template image; calculate the cosine similarity of the anti-counterfeiting features of the training sample and the anti-counterfeiting features of the template image, and when the cosine similarity is greater than a preset threshold, determine that the predicted value of the training sample is true, otherwise, when the cosine similarity is less than or equal to the preset threshold, determine that the predicted value of the training sample is false; according to the true value and the predicted value of the training sample, use a preset loss function to converge the deep convolutional neural network model to obtain a trained deep convolutional neural network model.
[0209] Among them, the loss function can be set according to the needs of actual application and will not be elaborated here.
[0210] In specific implementation, the above units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units can refer to the previous method embodiments, which will not be repeated here.
[0211] From the above, it can be seen that since the certificate authenticity inspection device of this embodiment can realize the automatic extraction and comparison of the anti-counterfeiting features of the certificate without too much manual intervention, it can not only improve the inspection efficiency and meet the needs of large-scale certificate inspection, but also reduce the influence of human factors, avoid misoperation, and improve the accuracy and consistency of inspection; in addition, since the anti-counterfeiting features based on which the authenticity is judged are a fusion of deep features and concrete features, when making authenticity judgments, it is possible to fully utilize the abstractness of deep features and take into account the details of concrete features, thereby achieving feature complementarity and enhancement. This feature complementarity and enhancement enables it to more comprehensively describe the anti-counterfeiting features of the certificate. Therefore, even in complex situations such as some anti-counterfeiting means are relatively concealed, the certificate is worn, stained, etc., the certificate authenticity inspection device can also perform inspections, greatly improving the accuracy, robustness and applicability of authenticity judgments.
[0212] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0213] To this end, an embodiment of the present application provides a storage medium in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any one of the methods for verifying the authenticity of a certificate provided in the embodiment of the present application. For example, the instructions can execute the following steps:
[0214] Acquire a verification document image to be inspected and a template image corresponding to the verification document image to be inspected; extract the depth features of the verification document image to be inspected and the depth features of the template image respectively through a preset trained deep convolutional neural network model; extract texture and shape features of the verification document image to be inspected and the template image respectively to obtain the concrete features of the verification document image to be inspected and the concrete features of the template image; fuse the depth features of the verification document image to be inspected and the concrete features of the verification document image to be inspected to obtain the anti-counterfeiting features of the verification document image to be inspected; fuse the depth features of the template image and the concrete features of the template image to obtain the anti-counterfeiting features of the template image; calculate the cosine similarity of the anti-counterfeiting features of the verification document image to be inspected and the anti-counterfeiting features of the template image, and when the cosine similarity is greater than a preset threshold, determine that the document corresponding to the verification document image to be inspected is authentic.
[0215] Otherwise, when the cosine similarity is less than or equal to the preset threshold, it is determined that the certificate corresponding to the to-be-checked certificate image is fake.
[0216] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0217] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0218] Since the instructions stored in the storage medium can execute the steps in any one of the certificate authenticity verification methods provided in the embodiments of the present application, the beneficial effects that can be achieved by any one of the certificate authenticity verification methods provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0219] The above is a detailed introduction to a method, device and storage medium for verifying the authenticity of a certificate provided in an embodiment of the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A method for verifying the authenticity of a certificate. It is characterized in that include: Acquire a verification document image to be inspected and a template image corresponding to the verification document image to be inspected; The deep features of the to-be-inspected document image and the deep features of the template image are respectively extracted by a preset trained deep convolutional neural network model; Extracting texture and shape features of the to-be-tested document image and the template image respectively, to obtain concrete features of the to-be-tested document image and the template image; Fusing the depth features of the image of the verification document to be inspected with the concrete features of the image of the verification document to be inspected to obtain the anti-counterfeiting features of the image of the verification document to be inspected; Fusing the depth features of the template image with the concrete features of the template image to obtain the anti-counterfeiting features of the template image; The cosine similarity between the anti-counterfeiting feature of the to-be-checked verification document image and the anti-counterfeiting feature of the template image is calculated, and when the cosine similarity is greater than a preset threshold, it is determined that the certificate corresponding to the to-be-checked verification document image is authentic.
2. The method according to claim 1, It is characterized in that The method of extracting the depth features of the to-be-tested document image and the depth features of the template image respectively through a preset trained deep convolutional neural network model includes: Obtaining a preset trained deep convolutional neural network model, wherein the trained deep convolutional neural network model includes a plurality of feature extraction layers with different receptive fields; Using the feature extraction layer to extract features from the to-be-tested document image and the template image respectively, to obtain feature information of multiple different scales corresponding to the to-be-tested document image and feature information of multiple different scales corresponding to the template image; Fusing feature information of multiple different scales corresponding to the image of the document to be inspected to obtain a depth feature of the image of the document to be inspected; The feature information of multiple different scales corresponding to the template image is fused to obtain the depth feature of the template image.
3. The method according to claim 2, It is characterized in that The fusing of the feature information of multiple different scales corresponding to the image of the document to be inspected to obtain the depth feature of the image of the document to be inspected is specifically: performing a global average pooling operation on the feature information of multiple different scales corresponding to the image of the document to be inspected to obtain a one-dimensional feature vector corresponding to the image of the document to be inspected, and performing vector concatenation on the one-dimensional feature vectors corresponding to the image of the document to be inspected to obtain the depth feature of the image of the document to be inspected; The fusing of feature information of multiple scales corresponding to the template image to obtain the deep features of the template image is specifically as follows: performing a global average pooling operation on feature information of multiple scales corresponding to the template image to obtain a one-dimensional feature vector corresponding to the template image, and performing vector concatenation on the one-dimensional feature vectors corresponding to the template image to obtain the deep features of the template image.
4. The method according to claim 1, It is characterized in that The extracting of texture and shape features from the to-be-tested document image and the template image respectively to obtain the concrete features of the to-be-tested document image and the concrete features of the template image includes: Calculating the directional gradient histogram feature vector of the to-be-tested document image to obtain the concrete features of the to-be-tested document image; The directional gradient histogram feature vector of the template image is calculated to obtain the concrete features of the template image.
5. The method according to claim 4, It is characterized in that The step of calculating the directional gradient histogram feature vector of the to-be-inspected verification document image to obtain the concrete features of the to-be-inspected verification document image is specifically as follows: preprocessing the to-be-inspected verification document image to obtain a preprocessed document image, wherein the preprocessed document image includes a plurality of blocks, calculating the gradient amplitude and gradient direction of each pixel point in the preprocessed document image, calculating the normalized histogram of each block in the preprocessed document image according to the gradient amplitude and gradient direction of each pixel point in the preprocessed document image, and performing vector splicing on the normalized histograms of all blocks in the preprocessed document image to obtain the concrete features of the to-be-inspected verification document image; The step of calculating the directional gradient histogram feature vector of the template image to obtain the concrete features of the template image is specifically as follows: preprocessing the template image to obtain a preprocessed template image, wherein the preprocessed template image includes a plurality of blocks, calculating the gradient amplitude and gradient direction of each pixel in the preprocessed template image, calculating the normalized histogram of each block in the preprocessed template image according to the gradient amplitude and gradient direction of each pixel in the preprocessed template image, and performing vector splicing on the normalized histograms of all blocks in the preprocessed template image to obtain the concrete features of the template image.
6. The method according to claim 5, It is characterized in that The step of calculating the normalized histogram of each block in the preprocessed document image according to the gradient amplitude and gradient direction of each pixel in the preprocessed document image is specifically as follows: the preprocessed document image is divided into a plurality of cells, and in each cell, the gradient amplitudes of pixels located in the same gradient direction interval are superimposed based on the gradient directions of each pixel to obtain the histogram of each cell, and the adjacent cells within a preset range are taken as a block, and the histograms of the cells in each block are normalized to obtain the normalized histogram of each block in the preprocessed document image; The method of calculating the normalized histogram of each block in the preprocessed template image according to the gradient amplitude and gradient direction of each pixel in the preprocessed template image is specifically as follows: the preprocessed template image is divided into a plurality of cells, and in each cell, the gradient amplitudes of pixels located in the same gradient direction interval are superimposed based on the gradient direction of each pixel to obtain the histogram of each cell, and adjacent cells within a preset range are taken as a block, and the histograms of the cells in each block are normalized to obtain the normalized histogram of each block in the preprocessed template image.
7. The method according to any one of claims 1 to 6, It is characterized in that Before acquiring the image of the document to be inspected and the template image corresponding to the image of the document to be inspected, the method further includes: Capture multiple images of known authentic documents; Preprocessing and normalizing the images of the plurality of known authentic certificates to obtain a plurality of processed images; Saving the multiple processed images as template images in a base library; The obtaining of the image of the document to be inspected and the template image corresponding to the image of the document to be inspected specifically includes: obtaining the image of the document to be inspected and obtaining the template image corresponding to the image of the document to be inspected from a base database.
8. The method according to any one of claims 1 to 6, It is characterized in that The obtaining of the image of the document to be inspected and the template image corresponding to the image of the document to be inspected includes: Obtaining a document image to be inspected, and determining the document type, version information, and issuance information of the document image to be inspected; A template image corresponding to the to-be-tested document image is obtained according to the document type, version information and issuance information.
9. A device for verifying the authenticity of a certificate, It is characterized in that include: An acquisition unit, used to acquire an image of a document to be inspected and a template image corresponding to the image of the document to be inspected; A first extraction unit is used to extract the depth features of the to-be-inspected document image and the depth features of the template image respectively through a preset trained deep convolutional neural network model; A second extraction unit is used to extract texture and shape features of the to-be-inspected document image and the template image, respectively, to obtain concrete features of the to-be-inspected document image and the template image; A fusion unit, used for fusing the depth feature of the image of the verification document to be inspected with the concrete feature of the image of the verification document to be inspected, so as to obtain the anti-counterfeiting feature of the image of the verification document to be inspected; and fusing the depth features of the template image with the concrete features of the template image to obtain the anti-counterfeiting features of the template image; The verification unit is used to calculate the cosine similarity between the anti-counterfeiting feature of the verification document image to be verified and the anti-counterfeiting feature of the template image, and when the cosine similarity is greater than a preset threshold, determine that the document corresponding to the verification document image to be verified is authentic.
10. A storage medium, It is characterized in that The storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the operations in the document authenticity verification method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Multi-modal currency recognition system, method, storage medium and terminal
WO2023070843A1
Cited By
Method and system for automatically identifying authenticity of entry-exit certificate
CN120599364A
