Seal anti-counterfeiting inspection method, device and computer-readable storage medium
By establishing a seal feature point database and using the SIFT algorithm to extract and match feature points, the accuracy and speed problems of seal authenticity detection in the existing technology are solved, and rapid and accurate authenticity identification of seals is achieved.
Patent Information
- Application Number
- CN201811256366.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-10-26
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2038-10-26
AI Technical Summary
It is difficult to detect the authenticity of a seal accurately and quickly with existing technology, and there is a lack of effective anti-counterfeiting identification methods.
By establishing a feature point database of the reference seal image, the feature points of the seal image to be inspected are extracted and matched with the feature points in the database, and the number of matching feature points is counted to determine the authenticity of the seal. Specific steps include obtaining a real seal image, using the SIFT algorithm to extract feature points, performing color separation and contour detection, and using Euclidean distance or feature matrix matching methods to determine the correspondence between feature points.
It achieves accurate and rapid authenticity detection of seals, can effectively identify the authenticity of seals, and improves the security of seal anti-counterfeiting.
Smart Images

Figure CN109635818B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image recognition, and in particular to a seal anti-counterfeiting inspection method, device and computer-readable storage medium based on key feature point detection and comparison. Background Art
[0002] Seals play an extremely important role in social and economic life. Therefore, it is urgent to improve the research on seal anti-counterfeiting recognition technology. Summary of the invention
[0003] The invention provides a seal anti-counterfeiting inspection method, device and computer-readable storage medium, the main purpose of which is to accurately and quickly detect the authenticity of the seal.
[0004] To achieve the above object, the present invention provides a seal anti-counterfeiting inspection method, comprising:
[0005] Establishing a feature point reference database of reference seal images;
[0006] Extracting a seal image to be inspected from a document;
[0007] Extracting feature points of the seal image to be inspected;
[0008] Matching the feature points of the seal image to be inspected with the feature points of the reference seal images in the reference database to obtain matching feature points; and
[0009] The number of feature points that match the feature points of the seal image to be checked and the feature points of the reference seal image is counted, and the authenticity of the seal image to be checked is checked according to the number of the matching feature points.
[0010] Optionally, the step of establishing a feature point reference database of a reference seal image includes:
[0011] Acquire a seal image of a real seal as a reference seal image through an image acquisition device, and assign a fixed ID to each reference seal image, the ID corresponding to a specific real seal;
[0012] The feature points in the reference seal image are extracted by using a feature point extraction method, and the position information and descriptor information of the feature points contained in the reference seal image are stored in a reference database.
[0013] Optionally, extracting the seal image to be checked from the document includes:
[0014] Separating characteristic data of a preset color from the document;
[0015] Separating the seal image using a double threshold color separation method according to the characteristic data of the preset color; and
[0016] The seal image is detected by contour detection, and the seal image is cut out according to the detected contour.
[0017] Optionally, the preset color includes red, and the method for separating the characteristic data of the preset color from the document includes one or a combination of the following:
[0018] Calculate the difference between RG and RB in the RGB space of the pixel point, and if the difference between RG and RB is greater than the corresponding preset threshold, determine that the pixel point is red;
[0019] Calculate the H value of the pixel in the HSV space, and if the H value of the pixel is less than the corresponding preset threshold, determine that the pixel is red; and
[0020] The deflection angle θ=a tan 2(Cb, Cr) of the pixel point in the YCbCr space is calculated. If the calculated θ is less than the corresponding preset threshold, the pixel point is determined to be red.
[0021] Optionally, the step of matching the feature points of the seal image to be inspected with the feature points of the reference seal images in the reference database to obtain matching feature points adopts one of the following methods:
[0022] Get the feature vector V of feature point i of the reference seal image i recg =[x1, x2…x n ] and the feature vector V of the feature point j of the seal image to be tested j recg =[x1′, x2′…x n ′], where n represents the dimension of the feature vector, and the Euclidean distance between two feature vectors is calculated:
[0023]
[0024] The two corresponding feature vectors with the smallest Euclidean distance are the matching feature vectors, and the corresponding feature points of the reference seal image and the feature points of the seal image to be verified are the matching feature points; or
[0025] Get the feature matrix of feature point i of the reference seal image The feature matrix of feature point j of the seal image to be inspected Where n represents the number of rows and columns of the feature matrix, and the ρ distance between two feature matrices is:
[0026]
[0027] λ k (V i ref , Vj ref ) k V i ref x k -V j ref x k =0 k=1...n , x k ≠0,
[0028] Among them, ρ(V i ref , V j ref ) The two corresponding feature vectors with the smallest distance are the matching feature vectors, and the corresponding reference seal image feature points and the feature points of the seal image to be verified are the matching feature points.
[0029] In addition, to achieve the above-mentioned purpose, the present invention also provides a seal anti-counterfeiting inspection device, which includes a memory and a processor, wherein the memory stores a seal anti-counterfeiting inspection program that can be run on the processor, and when the seal anti-counterfeiting inspection program is executed by the processor, the following steps are implemented:
[0030] Establishing a feature point reference database of reference seal images;
[0031] Extracting a seal image to be inspected from a document;
[0032] Extracting feature points of the seal image to be inspected;
[0033] Matching the feature points of the seal image to be inspected with the feature points of the reference seal images in the reference database to obtain matching feature points; and
[0034] The number of feature points that match the feature points of the seal image to be checked and the feature points of the reference seal image is counted, and the authenticity of the seal image to be checked is checked according to the number of the matching feature points.
[0035] Optionally, the step of establishing a feature point reference database of a reference seal image includes:
[0036] Acquire a seal image of a real seal as a reference seal image through an image acquisition device, and assign a fixed ID to each reference seal image, the ID corresponding to a specific real seal;
[0037] The feature points in the reference seal image are extracted by using a feature point extraction method, and the position information and descriptor information of the feature points contained in the reference seal image are stored in a reference database.
[0038] Optionally, extracting the seal image to be checked from the document includes:
[0039] Separating characteristic data of a preset color from the document;
[0040] Separating the seal image using a double threshold color separation method according to the characteristic data of the preset color; and
[0041] The seal image is detected by contour detection, and the seal image is cut out according to the detected contour.
[0042] Optionally, the preset color includes red, and the method for separating characteristic data of the preset color from the document includes one or a combination of the following:
[0043] Calculate the difference between RG and RB in the RGB space of the pixel point, and if the difference between RG and RB is greater than the corresponding preset threshold, determine that the pixel point is red;
[0044] Calculate the H value of the pixel in the HSV space, and if the H value of the pixel is less than the corresponding preset threshold, determine that the pixel is red; and
[0045] The deflection angle θ=a tan 2(Cb, Cr) of the pixel point in the YCbCr space is calculated. If the calculated θ is less than the corresponding preset threshold, the pixel point is determined to be red.
[0046] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, on which a seal anti-counterfeiting inspection program is stored. The seal anti-counterfeiting inspection program can be executed by one or more processors to implement the steps of the seal anti-counterfeiting inspection method as described above.
[0047] The seal anti-counterfeiting inspection method, device and computer-readable storage medium proposed by the present invention establish a reference database of feature points of reference seal images; extract the seal image to be inspected from the document; extract the feature points of the seal image to be inspected; match the feature points of the seal image to be inspected with the feature points of the reference seal image in the reference database to obtain matching feature points; and count the number of matching feature points between the feature points of the seal image to be inspected and the feature points of the reference seal image, and inspect the authenticity of the seal image to be inspected according to the number of matching feature points. The present invention can accurately and quickly detect the authenticity of seals. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 A schematic diagram of a flow chart of a seal anti-counterfeiting inspection method provided by an embodiment of the present invention;
[0049] Figure 2 A schematic diagram of the internal structure of a seal anti-counterfeiting inspection device provided by an embodiment of the present invention;
[0050] Figure 3 A schematic diagram of a module of a seal anti-counterfeiting inspection program in a seal anti-counterfeiting inspection device provided in an embodiment of the present invention.
[0051] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0052] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0053] The present invention provides a seal anti-counterfeiting inspection method. Figure 1 FIG. 1 is a flow chart of a seal anti-counterfeiting inspection method provided by an embodiment of the present invention. The method can be executed by a device, and the device can be implemented by software and / or hardware.
[0054] In this embodiment, the seal anti-counterfeiting inspection method includes:
[0055] S10, establishing a feature point reference database of the reference seal image.
[0056] A preferred embodiment of the present invention obtains a seal image of a real seal as a reference seal image through an image acquisition device such as a camera, a scanner, or a CCD camera, and assigns each reference seal image a fixed ID corresponding to a specific real seal.
[0057] The feature points in the reference seal image are extracted by using a feature point extraction method, and data such as position information and descriptor information of the feature points contained in the reference seal image are stored in a reference database.
[0058] The feature point extraction method used in this proposal is the SIFT (Scale Invariant Feature Transform) algorithm.
[0059] The SIFT operator is an operator with good performance in the image matching algorithm. The feature image registration based on the SIFT algorithm can be roughly divided into feature detection, description and matching. Feature detection is performed in the scale space. First, the image scale space is generated, and then the local extreme point values in the scale space are detected. Then, the local extreme point is accurately located by eliminating low-contrast points and edge response points. When describing the features, the main direction of each extreme point is first calculated, and the main direction of the extreme point and the area centered on the extreme point are histogram gradient direction statistics to generate feature point descriptors. The feature point descriptors can be used to find matching features and establish connections between images.
[0060] SIFT feature detection mainly includes the following four basic steps: 1. Scale space extreme value detection: Search for image positions at all scales. Potential candidate points that are invariant to scale and rotation are identified through Gaussian differential functions. 2. Feature point location: At each candidate position, the position and scale are determined by a finely fitted model. The selection of feature points is based on their stability. 3. Direction determination: Based on the local gradient direction of the image, one or more directions are assigned to each feature point position. All subsequent operations on the image data are transformed relative to the direction, scale and position of the feature point, thereby providing invariance to these transformations. 4. Feature point description: In the neighborhood around each feature point, the local gradient of the image is measured at a selected scale. These gradients are transformed into a representation that allows relatively large local shape deformations and illumination changes. In the feature point description, a 16×16 neighborhood centered on the feature point is taken as a sampling window, and the relative directions of the sampling point and the feature point are weighted by Gaussian and classified into a direction histogram containing 8 bins, and finally a 4×4×8 128-dimensional feature point descriptor is obtained.
[0061] S20, extracting the seal image to be inspected from the document.
[0062] In a preferred embodiment of the present invention, the step of extracting the seal image to be inspected includes:
[0063] Sub-step 1: Separate characteristic data of a preset color from the document.
[0064] It should be understood that most seals are red, so this embodiment takes red as an example.
[0065] In order to highlight the difference between red and other colors in value, this scheme proposes three ways to describe color according to the characteristics of different color spaces in expressing colors. They are:
[0066] (1) RG and RB differences in RGB space.
[0067] The three components of the RGB space, R, G, and B, represent the mixing amount of red, green, and blue, respectively. Intuitively speaking, the R value of red, that is, the red component, must be relatively large. In fact, the RGB value of standard red in the RGB space is (255,0,0), but a large R value does not mean that the color is close to red. The size of the G and B values will have a significant impact on the color. For example, (255,255,0) represents yellow, while (255,0,255) represents purple. From this, it can be seen that when the R value is larger and the G and B values are smaller, the corresponding color is closer to red.
[0068] Accordingly, this solution calculates the difference RG between the R component and the G component, and the difference RB between the R component and the B component of a pixel point. When the difference RG and the difference RB are both greater than the corresponding preset thresholds, the pixel point is determined to be red.
[0069] (2)H value in HSV space.
[0070] H, S, and V in the HSV space represent hue, saturation, and intensity, respectively. The description of color in the HSV space is closer to human understanding of color: H stands for hue, and the phase of the color is expressed in the form of an angle value, from 0° to 360°, representing the gradual process from red to green to blue and back to red. S represents the fill ratio of the color under the corresponding hue, which is 0-100%, and V represents brightness, or light intensity, which is 0-100%. For a seal, the change in its red color is mainly affected by the image acquisition light (corresponding to brightness V) and the wear of the paper itself (corresponding to saturation S), so the value of H can better describe the "color" difference in the general sense.
[0071] Therefore, this solution calculates the H value of a pixel point, and when the H value of the pixel point is less than the corresponding preset threshold value, the pixel point is determined to be red.
[0072] (3)YCbC r The deflection angle θ in space.
[0073] YCbCr space is not an absolute color space, but an encoding of RGB space. Its encoding rules are as follows:
[0074]
[0075] In fact, the components of the YCbCr space are still meaningful. Y represents the grayscale of the pixel, and Cb and Cr represent the concentration offset components of the blue and red colors of the pixel, respectively. r The angle θ between the vector on the plane and the Cr axis is used to describe the color of the pixel, which has a similar effect to H in HSV, but the distribution of H is different.
[0076] θ = a tan 2 (Cb, Cr);
[0077] When the calculated θ is less than the corresponding preset threshold, the pixel is determined to be red.
[0078] Sub-step 2: Separating the seal image using a double threshold color separation method according to the characteristic data of the preset color.
[0079] In order to solve the problem that the color of the noise is close to that of the seal itself, this scheme adopts the k-means clustering method. Assuming that the θ value in the YCbCr space is used as the color description method, the image is divided into clusters according to the θ value of each pixel, and the upper and lower bounds [a, b] of the θ value of the cluster to which the seal color belongs are obtained. The color of the seal edge tends to be close to the background color, which means that the color of this part may be very close to the color of part of the noise and is therefore considered as noise and removed. Therefore, this scheme adopts the double threshold method. Based on the threshold [a, b] obtained based on k-means clustering, the value range is first narrowed, and a strict threshold is used to obtain pixels that absolutely belong to the seal and form a seal pixel point set. Then, the value range is expanded, and a looser threshold range is used to determine whether the adjacent points of each point in the seal pixel point set belong to the seal, so as to supplement the seal pixel point set and ensure the integrity of the seal image.
[0080] Sub-step 3: performing contour detection on the seal image, and cutting out the seal image according to the detected contour.
[0081] In a preferred embodiment of the present invention, the seal contour detection includes any one of the following methods or a combination of several methods:
[0082] (1) Edge detection: This scheme adopts the Canny edge detection algorithm based on the Sobel operator. This method can well detect the edge of the seal and obtain the gradient value of the edge point through the Sobel operator.
[0083] (2) Random Hough Transform Detection of Ellipses. Random Hough Transform can effectively detect ellipses, find the location of ellipses and draw a relatively accurate ellipse outline. However, its random point selection mechanism makes it easily interfered by noise, and it is easy to find no ellipse after reaching the maximum number of cycles. In addition, its ellipse parameter calculation method also makes it impossible to calculate a very accurate ellipse equation.
[0084] (3) Direct least squares fitting of ellipse: Direct least squares fitting of ellipse is an optimized ellipse detection method. It uses a set of sampling point data to fit and solve the unknown parameters in the ellipse equation through algebraic methods. The key problem of using the least squares method to solve the problem lies in the selection of sample points, so it is necessary to combine other methods to obtain better samples.
[0085] (4) Combine random Hough transform with direct least squares fitting of ellipse to detect ellipse. Since the steps of using these two methods are relatively complicated, they will not be elaborated here. In short, using this method to detect ellipse of seal image, the result often contains two ellipses with the same centroid but different sizes, corresponding to the inner and outer edges of the seal frame respectively. Take the larger one and you will get the precise edge of the ellipse. Set the color of pixels outside the edge to white, and cut the image according to the position of the edge to get the ellipse image within the outline.
[0086] S30, extracting feature points of the seal image to be inspected.
[0087] This step can also use the SIFT (Scale Invariant Feature Transform) algorithm as a method for extracting feature points.
[0088] S40, matching the feature points of the seal image to be inspected with the reference seal image feature point reference database to obtain matching feature points.
[0089] Feature points have two forms of descriptors: feature vectors and feature matrices.
[0090] Using the feature vector of the feature point as the feature descriptor of the feature point, this solution uses the Euclidean distance evaluation method to match the feature points:
[0091] Get the feature vector V of feature point i of the reference seal image i recg =[x1, x2…x n ], the feature vector V of the feature point j of the seal image to be tested j recg =[x1′, x2′…x n ′], where n represents the dimension of the feature vector, and the Euclidean distance between two feature vectors is:
[0092]
[0093] The two corresponding feature vectors with the smallest Euclidean distance are the matching feature vectors, and the corresponding reference seal image feature points are the matching feature points.
[0094] The feature matrix of the feature point is used as the feature point feature descriptor. Since this type of feature matrix is generally a positive definite matrix, this solution uses the following method to match the feature points:
[0095] Get the feature matrix of feature point i of the reference seal image The feature matrix of feature point j of the seal image to be inspected Where n represents the number of rows and columns of the feature matrix, and the ρ distance between two feature matrices is:
[0096]
[0097] λ k (V i ref , V j ref ) k V i ref x k -V j ref x k =0 k=1...n , x k ≠0,
[0098] Where V i ref and V j ref are two covariance matrices, ρ(V i ref , V j ref ) represents their evaluation distance. k (V i ref , V j ref ) indicates V i ref and V j ref The generalized eigenvalue of is calculated by: k V i ref x k -V j ref x k =0 k=1...n Among them, x k ≠0, V i ref and V j ref is the generalized eigenvector of , and n is the dimension of the generalized eigenvector.
[0099] ρ(V i ref , V j ref ) The two corresponding feature vectors with the smallest distance are the matching feature vectors, and the corresponding reference seal image feature points and the feature points of the seal image to be verified are the matching feature points.
[0100] After the feature points of the stamp image to be inspected are matched with the feature points of the reference stamp image, the feature points of the reference stamp image [P1P2…P n] and the feature points [P1′P2′…P n ′], where n represents the number of matching feature points. The above formula indicates that the reference image feature point P1 corresponds to the whole point P1′ of the image to be tested, P2 corresponds to P2′, and so on.
[0101] S50, counting the number of feature points that match between the feature points of the seal image to be checked and the feature points of the reference seal image, and checking the authenticity of the seal image to be checked according to the number of matching feature points.
[0102] If the percentage of the number of feature points of the seal image to be checked that matches the feature points of the reference seal image exceeds a preset value, such as 85%, the seal image to be checked is considered to be authentic.
[0103] The present invention also provides a seal anti-counterfeiting inspection device. Figure 2 , which is a schematic diagram of the internal structure of a seal anti-counterfeiting inspection device provided by an embodiment of the present invention.
[0104] In this embodiment, the seal anti-counterfeiting inspection device 1 can be a PC (Personal Computer), or a terminal device such as a smart phone, a tablet computer, a portable computer, or a server or a server cluster, etc. The seal anti-counterfeiting inspection device 1 at least includes a memory 11, a processor 12, a communication bus 13, and a network interface 14.
[0105] Among them, the memory 11 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), magnetic memory, disk, CD, etc. The memory 11 can be an internal storage unit of the seal anti-counterfeiting inspection device 1 in some embodiments, such as the hard disk of the seal anti-counterfeiting inspection device 1. The memory 11 can also be an external storage device of the seal anti-counterfeiting inspection device 1 in other embodiments, such as a plug-in hard disk equipped on the seal anti-counterfeiting inspection device 1, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Further, the memory 11 can also include both the internal storage unit of the seal anti-counterfeiting inspection device 1 and an external storage device. The memory 11 can not only be used to store application software and various types of data installed in the seal anti-counterfeiting inspection device 1, such as the code of the seal anti-counterfeiting inspection program 01, but also can be used to temporarily store data that has been output or is to be output.
[0106] In some embodiments, the processor 12 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor or other data processing chip, and is used to run program codes or process data stored in the memory 11, such as executing the seal anti-counterfeiting inspection program 01.
[0107] The communication bus 13 is used to realize the connection and communication between these components.
[0108] The network interface 14 may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), and is generally used to establish a communication connection between the device 1 and other electronic devices.
[0109] Optionally, the device 1 may also include a user interface, which may include a display (Display), an input unit such as a keyboard (Keyboard), and the optional user interface may also include a standard wired interface and a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch device, etc. Among them, the display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the seal anti-counterfeiting inspection device 1 and to display a visual user interface.
[0110] Figure 2 Only the seal anti-counterfeiting inspection device 1 having components 11-14 and the seal anti-counterfeiting inspection program 01 is shown. It can be understood by those skilled in the art that Figure 1 The structure shown does not constitute a limitation on the seal anti-counterfeiting inspection device 1, and may include fewer or more components than shown in the figure, or a combination of certain components, or a different arrangement of components.
[0111] exist Figure 2 In the embodiment of the device 1 shown, the memory 11 stores a seal anti-counterfeiting inspection program 01; when the processor 12 executes the seal anti-counterfeiting inspection program 01 stored in the memory 11, the following steps are implemented:
[0112] Step 1: Establish a feature point reference database of the reference seal image.
[0113] A preferred embodiment of the present invention obtains a seal image of a real seal as a reference seal image through an image acquisition device such as a camera, a scanner, or a CCD camera, and assigns each reference seal image a fixed ID corresponding to a specific real seal.
[0114] The feature points in the reference seal image are extracted by using a feature point extraction method, and data such as position information and descriptor information of the feature points contained in the reference seal image are stored in a reference database.
[0115] The feature point extraction method used in this proposal is the SIFT (Scale Invariant Feature Transform) algorithm.
[0116] The SIFT operator is an operator with good performance in the image matching algorithm. The feature image registration based on the SIFT algorithm can be roughly divided into feature detection, description and matching. Feature detection is performed in the scale space. First, the image scale space is generated, and then the local extreme point values in the scale space are detected. Then, the local extreme point is accurately located by eliminating low-contrast points and edge response points. When describing the features, the main direction of each extreme point is first calculated, and the main direction of the extreme point and the area centered on the extreme point are histogram gradient direction statistics to generate feature point descriptors. The feature point descriptors can be used to find matching features and establish connections between images.
[0117] SIFT feature detection mainly includes the following four basic steps: 1. Scale space extreme value detection: Search for image positions at all scales. Potential candidate points that are invariant to scale and rotation are identified through Gaussian differential functions. 2. Feature point location: At each candidate position, the position and scale are determined by a finely fitted model. The selection of feature points is based on their stability. 3. Direction determination: Based on the local gradient direction of the image, one or more directions are assigned to each feature point position. All subsequent operations on the image data are transformed relative to the direction, scale and position of the feature point, thereby providing invariance to these transformations. 4. Feature point description: In the neighborhood around each feature point, the local gradient of the image is measured at a selected scale. These gradients are transformed into a representation that allows relatively large local shape deformations and illumination changes. In the feature point description, a 16×16 neighborhood centered on the feature point is taken as a sampling window, and the relative directions of the sampling point and the feature point are weighted by Gaussian and classified into a direction histogram containing 8 bins, and finally a 4×4×8 128-dimensional feature point descriptor is obtained.
[0118] Step 2: Extract the seal image to be inspected from the document.
[0119] In a preferred embodiment of the present invention, the process of extracting the seal image to be inspected includes:
[0120] 1. Separate characteristic data of a preset color from the document.
[0121] It should be understood that most seals are red, so this embodiment takes red as an example.
[0122] In order to highlight the difference between red and other colors in value, this scheme proposes three ways to describe color according to the characteristics of different color spaces in expressing colors. They are:
[0123] (1) RGB space——RG, RB.
[0124] The three components of the RGB space, R, G, and B, represent the mixing amount of red, green, and blue, respectively. Intuitively speaking, the R value of red, that is, the red component, must be relatively large. In fact, the RGB value of standard red in the RGB space is (255,0,0), but a large R value does not mean that the color is close to red. The size of the G and B values will have a significant impact on the color. For example, (255,255,0) represents yellow, while (255,0,255) represents purple. From this, it can be seen that when the R value is larger and the G and B values are smaller, the corresponding color is closer to red.
[0125] Accordingly, this solution calculates the difference RG between the R component and the G component, and the difference RB between the R component and the B component of a pixel point. When the difference RG and the difference RB are both greater than the corresponding preset thresholds, the pixel point is determined to be red.
[0126] (2) HSV space——H.
[0127] H, S, and V in the HSV space represent hue, saturation, and intensity, respectively. The description of color in the HSV space is closer to human understanding of color: H stands for hue, and the phase of the color is expressed in the form of an angle value, from 0° to 360°, representing the gradual process from red to green to blue and back to red. S represents the fill ratio of the color under the corresponding hue, which is 0-100%, and V represents brightness, or light intensity, which is 0-100%. For a seal, the change in its red color is mainly affected by the image acquisition light (corresponding to brightness V) and the wear of the paper itself (corresponding to saturation S), so the value of H can better describe the "color" difference in the general sense.
[0128] Therefore, this solution calculates the H value of a pixel point, and when the H value of the pixel point is less than the corresponding preset threshold value, the pixel point is determined to be red. (3) YCbCr space - deflection angle θ.
[0129] YCbCr space is not an absolute color space, but an encoding of RGB space. Its encoding rules are as follows:
[0130]
[0131] In fact, the components of the YCbCr space are still meaningful. Y represents the grayscale of the pixel, and Cb and Cr represent the concentration offset components of the blue and red of the pixel, respectively. This solution can select the angle θ between a vector mapped to the CbCr plane and the Cr axis to describe the color of the pixel. Its effect is similar to H in HSV, but the distribution of H is different. Among them:
[0132] θ = a tan 2 (Cb, Cr);
[0133] When the calculated θ is less than the corresponding preset threshold, the pixel is determined to be red.
[0134] 2. Separate the seal image using a double threshold color separation method based on the characteristic data of the preset color.
[0135] In order to solve the problem that the color of the noise is close to that of the seal itself, this scheme adopts the k-means clustering method. Assuming that the θ value in the YCbCr space is used as the color description method, the image is divided into clusters according to the θ value of each pixel, and the upper and lower bounds [a, b] of the θ value of the cluster to which the seal color belongs are obtained. The color of the seal edge tends to be close to the background color, which means that the color of this part may be very close to the color of part of the noise and is therefore considered as noise and removed. Therefore, this scheme adopts the double threshold method. Based on the threshold [a, b] obtained based on k-means clustering, the value range is first narrowed, and a strict threshold is used to obtain pixels that absolutely belong to the seal and form a seal pixel point set. Then, the value range is expanded, and a looser threshold range is used to determine whether the adjacent points of each point in the seal pixel point set belong to the seal, so as to supplement the seal pixel point set and ensure the integrity of the seal image.
[0136] 3. Perform contour detection on the seal image and cut out the seal image according to the detected contour.
[0137] In a preferred embodiment of the present invention, the seal contour detection includes any one of the following methods or a combination of several methods:
[0138] (1) Edge detection. This scheme adopts the Canny edge detection algorithm based on the Sobel operator. This method can detect the edge of the seal well and obtain the gradient value of the edge point through the Sobel operator.
[0139] (2) Random Hough Transform Detection of Ellipses. Random Hough Transform can effectively detect ellipses, find the location of ellipses and draw a relatively accurate ellipse outline. However, its random point selection mechanism makes it easily affected by noise, and it is easy to find no ellipse after reaching the maximum number of cycles. In addition, its ellipse parameter calculation method also makes it impossible to calculate a very accurate ellipse equation.
[0140] (3) Direct least squares fitting of ellipse: Direct least squares fitting of ellipse is an optimized ellipse detection method. It uses a set of sampling point data to fit and solve the unknown parameters in the ellipse equation through algebraic methods. The key problem of using the least squares method to solve the problem lies in the selection of sample points, so it is necessary to combine other methods to obtain better samples.
[0141] (4) Combine random Hough transform with direct least squares fitting of ellipse to detect ellipse. Since the steps of using these two methods are relatively complicated, they will not be elaborated here. In short, using this method to detect ellipse of seal image, the result often contains two ellipses with the same centroid but different sizes, corresponding to the inner and outer edges of the seal frame respectively. Take the larger one and you will get the precise edge of the ellipse. Set the color of pixels outside the edge to white, and cut the image according to the position of the edge to get the ellipse image within the outline.
[0142] Step 3: Extract feature points of the seal image to be inspected.
[0143] This step can also use the SIFT (Scale Invariant Feature Transform) algorithm as a method for extracting feature points.
[0144] Step 4: Match the feature points of the seal image to be inspected with the reference seal image feature point reference database to obtain matching feature points.
[0145] Feature points have two forms of descriptors: feature vectors and feature matrices.
[0146] Using the feature vector of the feature point as the feature descriptor of the feature point, this solution uses the Euclidean distance evaluation method to match the feature points:
[0147] Get the feature vector V of feature point i of the reference seal image i recg =[x1, x2…x n ], the feature vector V of the feature point j of the seal image to be tested j recg =[x1′, x2′…x n′], where n represents the dimension of the feature vector, and the Euclidean distance between two feature vectors is:
[0148]
[0149] Among them, the two corresponding feature vectors with the smallest Euclidean distance are matching feature vectors, and the corresponding reference seal image feature points are matching feature points.
[0150] The feature matrix of the feature point is used as the feature point feature descriptor. Since this type of feature matrix is generally a positive definite matrix, this solution uses the following method to match the feature points:
[0151] Get the feature matrix of feature point i of the reference seal image The feature matrix of feature point j of the seal image to be inspected Where n represents the number of rows and columns of the feature matrix, and the ρ distance between two feature matrices is:
[0152]
[0153] λ k (V i ref , V j ref ) k V i ref x k -V j ref x k =0 k=1...n , x k ≠0,
[0154] Where V i ref and V j ref are two covariance matrices, ρ(V i ref , V j ref ) represents their evaluation distance. k (V i ref , V j ref ) indicates V i ref and V j ref The generalized eigenvalue of is calculated by: k V i ref x k -V j ref x k =0k=1...n , where x k ≠0 is V i ref and V j ref is the generalized eigenvector of , and n is the dimension of the generalized eigenvector.
[0155] Among them, ρ(V i ref , V j ref ) The two corresponding feature vectors with the smallest distance are the matching feature vectors, and the corresponding reference seal image feature points and the feature points of the seal image to be verified are the matching feature points.
[0156] After the feature points of the stamp image to be inspected are matched with the feature points of the reference stamp image, the feature points of the reference stamp image [P1P2…P n ] and the feature points [P1′P2′…P n ′], where n represents the number of matching feature points. The above formula indicates that the reference image feature point P1 corresponds to the whole point P1′ of the image to be tested, P2 corresponds to P2′, and so on.
[0157] Step 5: Count the number of feature points that match between the feature points of the seal image to be checked and the feature points of the reference seal image, and check the authenticity of the seal image to be checked based on the number of matching feature points.
[0158] Optionally, in other embodiments, the seal anti-counterfeiting inspection program can also be divided into one or more modules, one or more modules are stored in the memory 11, and executed by one or more processors (processor 12 in this embodiment) to complete the present invention. The module referred to in the present invention refers to a series of computer program instruction segments that can perform specific functions, which is used to describe the execution process of the seal anti-counterfeiting inspection program in the seal anti-counterfeiting inspection device.
[0159] For example, refer to Figure 3 FIG. 1 is a schematic diagram of a program module of a seal anti-counterfeiting inspection program in an embodiment of a seal anti-counterfeiting inspection device of the present invention. In this embodiment, the seal anti-counterfeiting inspection program can be divided into a reference database establishment module 10, a seal image extraction module 20, a feature point extraction module 30, a feature point matching module 40 and a seal inspection module 50. For example:
[0160] The reference database establishment 10 is used to: establish a feature point reference database of the reference seal image;
[0161] The seal image extraction module 20 is used to: extract the seal image to be checked from the document;
[0162] The feature point extraction module 30 is used to: extract feature points of the seal image to be inspected;
[0163] The feature point matching module 40 is used to: match the feature points of the seal image to be inspected with the reference seal image feature point reference database to obtain matching feature points; and
[0164] The seal inspection module 50 is used to count the number of feature points of the seal image to be inspected that match the feature points of the reference seal image, and inspect the authenticity of the seal image to be inspected based on the number of matching feature points.
[0165] The functions or operation steps implemented when the program modules such as the reference database establishment 10, seal image extraction module 20, feature point extraction module 30, feature point matching module 40 and seal inspection module 50 are executed are substantially the same as those in the above-mentioned embodiment and will not be repeated here.
[0166] In addition, an embodiment of the present invention further provides a computer-readable storage medium, on which a seal anti-counterfeiting inspection program is stored. The seal anti-counterfeiting inspection program can be executed by one or more processors to implement the following operations:
[0167] Establishing a feature point reference database of reference seal images;
[0168] Extracting a seal image to be inspected from a document;
[0169] Extracting feature points of the seal image to be inspected;
[0170] Matching the feature points of the seal image to be inspected with the reference seal image feature point reference database to obtain matching feature points; and
[0171] The number of feature points that match the feature points of the seal image to be checked and the feature points of the reference seal image is counted, and the authenticity of the seal image to be checked is checked according to the number of the matching feature points.
[0172] The specific implementation of the computer-readable storage medium of the present invention is basically the same as the above-mentioned seal anti-counterfeiting inspection device and method embodiments, and will not be repeated here.
[0173] It should be noted that the serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages and disadvantages of the embodiments. And the terms "including", "comprising" or any other variants thereof in this article are intended to cover non-exclusive inclusion, so that a process, device, article or method including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, device, article or method. In the absence of further restrictions, an element defined by the sentence "including a ..." does not exclude the presence of other identical elements in the process, device, article or method including the element.
[0174] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0175] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A seal anti-counterfeiting inspection method, characterized in that: The method comprises: A seal image of a real seal is obtained as a reference seal image, feature points in the reference seal image are extracted using a feature point extraction method, and position information and descriptor information of the feature points contained in the reference seal image are stored in a reference database, wherein the feature point extraction method comprises: generating an image scale space based on the reference seal image, detecting local extreme point values in the image scale space, removing low contrast points and edge response points in the local extreme point values to obtain feature points, determining the position and scale of the feature points in the image scale space as position information, calculating the main direction of each feature point based on the local gradient direction of the image, and performing histogram gradient direction statistics on an area centered on the feature point to generate a feature point descriptor as descriptor information; Separating characteristic data of a preset color from the document, separating the seal image using a double threshold color separation method according to the characteristic data of the preset color, performing contour detection on the seal image, and cutting out the seal image to be inspected according to the detected contour; Extracting feature points of the seal image to be inspected; Obtaining descriptor information including feature vectors and feature matrices corresponding to feature points of the seal image to be inspected, obtaining descriptor information including feature vectors and feature matrices corresponding to feature points of the reference seal image from a reference database, and matching feature points of the seal image to be inspected with feature points of the reference seal image in the reference database according to the feature vectors or the feature matrix to obtain matching feature points; and The number of feature points that match the feature points of the seal image to be checked and the feature points of the reference seal image is counted, and the authenticity of the seal image to be checked is checked according to the number of the matching feature points.
2. The seal anti-counterfeiting inspection method according to claim 1, characterized in that: The preset color includes red, and the method for separating characteristic data of the preset color from the document includes one or a combination of the following: Calculate the difference between RG and RB in the RGB space of the pixel point, and if the difference between RG and RB is greater than the corresponding preset threshold, determine that the pixel point is red; Calculate the H value of the pixel in the HSV space, and if the H value of the pixel is less than the corresponding preset threshold, determine that the pixel is red; and The deflection angle θ=a tan2(Cb,Cr) of the YCbCr space of the pixel is calculated. If the calculated θ is less than the corresponding preset threshold, the pixel is determined to be red.
3. The seal anti-counterfeiting inspection method according to claim 1, characterized in that: The step of matching the feature points of the seal image to be inspected with the feature points of the reference seal image in the reference database according to the feature vector or the feature matrix to obtain matching feature points adopts one of the following methods: Get the feature vector V of feature point i of the reference seal image i recg =[x1,x2…x n ] and the feature vector V of the feature point j of the seal image to be tested j recg =[x1′,x2′…x n ′], where n represents the dimension of the feature vector, and the Euclidean distance between two feature vectors is calculated: Among them, the two corresponding feature vectors with the smallest Euclidean distance are matching feature vectors, and the corresponding reference seal image feature points and the feature points of the seal image to be verified are matching feature points; or Get the feature matrix of feature point i of the reference seal image The feature matrix of feature point j of the seal image to be inspected Where n represents the number of rows and columns of the feature matrix, and the ρ distance between two feature matrices is: λ k (V i ref ,V k ref )λ k V i ref x k -V j ref x k =0 k=1…n ,x k ≠0, Among them, V i ref and V j ref are two covariance matrices, ρ(V i ref ,V j ref ) indicates V i ref and V j ref The evaluation distance, λ k (V i ref ,V j ref ) indicates V i ref and V j ref The generalized eigenvalue of is calculated by: k V i ref x k -V j ref x k =0 k=1...n , x k ≠0, V i ref and V j ref The generalized eigenvector of , n is the dimension of the generalized eigenvector, ρ(V i ref ,V j ref ) The two corresponding feature vectors with the smallest distance are the matching feature vectors, and the corresponding reference seal image feature points and the feature points of the seal image to be verified are the matching feature points.
4. A seal anti-counterfeiting inspection device, characterized in that: The device comprises a memory and a processor, wherein the memory stores a seal anti-counterfeiting inspection program that can be run on the processor, and when the seal anti-counterfeiting inspection program is executed by the processor, the following steps are implemented: A seal image of a real seal is obtained as a reference seal image, feature points in the reference seal image are extracted using a feature point extraction method, and position information and descriptor information of the feature points contained in the reference seal image are stored in a reference database, wherein the feature point extraction method comprises: generating an image scale space based on the reference seal image, detecting local extreme point values in the image scale space, removing low contrast points and edge response points in the local extreme point values to obtain feature points, determining the position and scale of the feature points in the image scale space as position information, calculating the main direction of each feature point based on the local gradient direction of the image, and performing histogram gradient direction statistics on an area centered on the feature point to generate a feature point descriptor as descriptor information; Separating characteristic data of a preset color from the document, separating the seal image using a double threshold color separation method according to the characteristic data of the preset color, performing contour detection on the seal image, and cutting out the seal image to be inspected according to the detected contour; Extracting feature points of the seal image to be inspected; Obtaining descriptor information including feature vectors and feature matrices corresponding to feature points of the seal image to be inspected, obtaining descriptor information including feature vectors and feature matrices corresponding to feature points of the reference seal image from a reference database, and matching feature points of the seal image to be inspected with feature points of the reference seal image in the reference database according to the feature vectors or the feature matrix to obtain matching feature points; and The number of feature points that match the feature points of the seal image to be checked and the feature points of the reference seal image is counted, and the authenticity of the seal image to be checked is checked according to the number of the matching feature points.
5. The seal anti-counterfeiting inspection device according to claim 4, characterized in that: The preset color includes red, and the method for separating characteristic data of the preset color from the document includes one or a combination of the following: Calculate the difference between RG and RB in the RGB space of the pixel point, and if the difference between RG and RB is greater than the corresponding preset threshold, determine that the pixel point is red; Calculate the H value of the pixel in the HSV space, and if the H value of the pixel is less than the corresponding preset threshold, determine that the pixel is red; and The deflection angle θ=a tan2(Cb,Cr) of the YCbCr space of the pixel is calculated. If the calculated θ is less than the corresponding preset threshold, the pixel is determined to be red.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a seal anti-counterfeiting verification program, which can be executed by one or more processors to implement the steps of the seal anti-counterfeiting verification method according to any one of claims 1 to 3.
