CN113505841A - Official seal positive and negative sample generation method, official seal authenticity verification method and terminal - Google Patents
Official seal positive and negative sample generation method, official seal authenticity verification method and terminal Download PDFInfo
- Publication number
- CN113505841A CN113505841A CN202110822662.7A CN202110822662A CN113505841A CN 113505841 A CN113505841 A CN 113505841A CN 202110822662 A CN202110822662 A CN 202110822662A CN 113505841 A CN113505841 A CN 113505841A
- Authority
- CN
- China
- Prior art keywords
- official seal
- sample
- positive
- pattern
- official
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/24—Classification techniques
- G06F18/241—Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/21—Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
- G06F18/214—Generating training patterns; Bootstrap methods, e.g. bagging or boosting
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- Life Sciences & Earth Sciences (AREA)
- Artificial Intelligence (AREA)
- General Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Evolutionary Computation (AREA)
- Bioinformatics & Computational Biology (AREA)
- Evolutionary Biology (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Computational Linguistics (AREA)
- Biomedical Technology (AREA)
- Biophysics (AREA)
- Health & Medical Sciences (AREA)
- General Health & Medical Sciences (AREA)
- Molecular Biology (AREA)
- Computing Systems (AREA)
- Mathematical Physics (AREA)
- Software Systems (AREA)
- Image Analysis (AREA)
Abstract
The invention provides a method for generating a positive and negative sample of a official seal, a method for verifying the authenticity of the official seal and a terminal, wherein the method for generating the positive and negative sample of the official seal comprises the steps of obtaining a positive sample file covered with the official seal, and respectively carrying out sample extraction and official seal pattern segmentation on an official seal pattern of the positive sample file to obtain an official seal positive sample and a first false official seal pattern; drawing a official seal pattern to obtain a second pseudo official seal pattern; and respectively pasting a first pseudo official seal pattern and/or a second pseudo official seal pattern on the official seal-free area of the positive sample file, and performing corresponding sample extraction to obtain an official seal negative sample. The official seal authenticity verification method utilizes the official seal positive sample and the official seal negative sample to train the convolutional neural network model and obtain the official seal authenticity classifier, and then the official seal authenticity classifier is adopted to verify authenticity of the official seal on the file to be tested. The invention solves the problem that the training of the convolutional neural network model depends on insufficient official seal positive and negative samples, so that a good verification effect cannot be achieved, and realizes an accurate and rapid official seal verification effect.
Description
Technical Field
The invention relates to the field of computer vision, in particular to a method for generating a positive and negative sample of a official seal, a method for verifying authenticity of the official seal and a terminal.
Background
A official seal is a legal representative of an organization, business, institution, group or school. The private seal is the behavior of a person or other organizations to privately seal other enterprise seals.
For such situations, the existing official seal verification method is mainly divided by banks according to verification main bodies, and the existing official seal verification method mainly includes two types of self-certification and other-certification: self-certification, i.e. the self-approval; he's evidence is verified by an authoritative third party. At present, the main effective authentication mode in China is a qualified authentication mechanism, can technically check the authenticity of official seal, is an effective authentication mode which is acknowledged by a judicial system in China, but is long in time consumption and high in cost in application and authentication, and can not be popularized in common business activities when being mostly used for disputes. For financial staff of common enterprises, the number of documents to be audited every day is not enough, so that the authenticity of the official seal is difficult to be carefully judged one by one through manual work, and the omission of audit is difficult to avoid.
With the popularization of deep learning, examples of replacing manpower with a deep learning method, such as face recognition, license plate recognition, article detection and the like, are increasingly popularized, so that the time consumption of manpower can be greatly saved when the deep learning method is used for official seal verification, but deep learning is a field which extremely depends on data, and sufficient data must be ensured in order to achieve a good effect.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: the official seal positive and negative sample generation method, the official seal authenticity verification method and the terminal are provided, and the accurate and quick official seal authenticity verification effect is achieved.
In order to solve the technical problems, the invention adopts the technical scheme that:
a method for generating a positive and negative sample of a official seal comprises the following steps:
s10, obtaining a positive sample file covered with a official seal, and respectively carrying out sample extraction and official seal pattern segmentation on the official seal pattern in the positive sample file to obtain an official seal positive sample and a first pseudo-official seal pattern, wherein the sample extraction is to segment a graphic area comprising the official seal pattern according to a preset shape;
s20, drawing the official seal pattern by using a graphic library to obtain a second pseudo-official seal pattern;
and S30, respectively pasting the first pseudo official seal pattern and/or the second pseudo official seal pattern on the official seal-free area of the positive sample file, and performing corresponding sample extraction to obtain an official seal negative sample.
In order to solve the technical problem, the invention adopts another technical scheme as follows:
a common seal positive and negative sample generation terminal comprises a first memory, a first processor and a first computer program which is stored on the first memory and can run on the first processor, wherein the first processor realizes the steps in the common seal positive and negative sample generation method according to the technical scheme when executing the first computer program.
In order to solve the technical problem, the invention adopts another technical scheme as follows:
a official seal true checking method adopts the official seal positive sample and the official seal negative sample obtained by the official seal positive and negative sample generating method in the technical scheme, and comprises the following steps:
s40, converting the official seal positive sample and the official seal negative sample into a format required by training the convolutional neural network model;
s50, training the official seal positive and negative samples after format conversion based on the convolutional neural network model to obtain an official seal true and false classifier;
and S60, verifying the authenticity of the official seal on the file to be tested by adopting the official seal authenticity classifier.
In order to solve the technical problem, the invention adopts another technical scheme as follows:
an official seal authenticity verification terminal comprises a second memory, a second processor and a second computer program which is stored on the second memory and can run on the second processor, wherein the second processor realizes the steps in the official seal authenticity verification method according to the technical scheme when executing the second computer program.
The invention has the beneficial effects that: the invention provides a method for generating positive and negative samples of a official seal, a method for verifying the authenticity of the official seal and a terminal, wherein a plurality of positive and negative samples of the official seal are generated by image extraction, segmentation and image drawing, so that a neural network obtained by subsequent training can distinguish the official seal obtained by 'sectional drawing' and a software-drawn official seal, and the problem that the training of a convolutional neural network model in the prior art cannot achieve a good authenticity verifying effect due to insufficient data is solved; and then training a convolutional neural network model by using the generated positive and negative samples of the official seal to obtain an official seal true and false classifier, and performing rapid authenticity verification on the official seal in the file to be tested, so that an accurate and rapid official seal authenticity verification effect is realized.
Drawings
FIG. 1 is a flowchart of a method for generating positive and negative samples of official seal according to an embodiment of the present invention;
FIG. 2 is a schematic structural diagram of a generation terminal for positive and negative samples of a official seal according to an embodiment of the present invention;
FIG. 3 is a flowchart of a official seal verification method according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a official seal verification terminal according to an embodiment of the present invention.
Description of reference numerals:
1. generating a positive and negative sample generating terminal of the official seal; 11. a first memory; 12. a first processor; 2. a official seal authenticity verification terminal; 21. a second memory; 22. a second processor.
Detailed Description
In order to explain technical contents, achieved objects, and effects of the present invention in detail, the following description is made with reference to the accompanying drawings in combination with the embodiments.
Before this, in order to facilitate understanding of the technical solution of the present invention, the following description is made of the acronyms, nouns, and the like related to the present invention:
RGB color space: the mode is commonly called three-primary-color mode, namely, based on three primary colors of RED, GREEN and BLUE, superposition is carried out to different degrees, and abundant and wide colors are generated.
HSV color space: namely, the HSV color model, Hue, Saturation and Value lightness, HSV is a color space created according to the intuitive characteristics of colors, and is also called a hexagonal cone model.
Keras: an open-source artificial neural network library written by Python can be used as a high-level application program interface of Tensorflow, Microsoft-CNTK and Theano to design, debug, evaluate, apply and visualize a deep learning model.
ImageGenerator: a picture generator of Keras.
Imagedata generator: a picture data generator of Keras.
Referring to fig. 1, a method for generating positive and negative samples of official seal includes the steps of:
s10, obtaining a positive sample file covered with a official seal, and respectively carrying out sample extraction and official seal pattern segmentation on the official seal pattern in the positive sample file to obtain an official seal positive sample and a first pseudo-official seal pattern, wherein the sample extraction is to segment a graphic area comprising the official seal pattern according to a preset shape;
s20, drawing the official seal pattern by using a graphic library to obtain a second pseudo-official seal pattern;
and S30, respectively pasting the first pseudo official seal pattern and/or the second pseudo official seal pattern on the official seal-free area of the positive sample file, and performing corresponding sample extraction to obtain an official seal negative sample.
As can be seen from the above description, the beneficial effects of the present invention are: the positive and negative samples of the multiple official seals are generated in the modes of image extraction, segmentation and image drawing, so that the neural network obtained by subsequent training can distinguish the official seal obtained by 'matting' and the official seal drawn by software, and the problem that the training convolutional neural network model in the prior art cannot achieve a good true-checking effect due to insufficient data is solved.
Further, the step S10 specifically includes the following steps:
s11, obtaining a scanned piece of the positive sample file in the folder, traversing each page of the scanned piece, and converting the number of pages covered with common seals into a picture file;
s12, converting the image data of the picture file from an RGB color space to an HSV color space, and segmenting the picture file according to a H, S, V three-channel value to obtain a red region;
s13, acquiring coordinates and radius of the official seal pattern in the red area by adopting a Hough circle detection method;
s14, intercepting a circular area where the official seal pattern is located according to the obtained coordinate and the obtained radius to obtain the first pseudo official seal pattern;
s15, according to the detected coordinates and radius, intercepting a circumscribed rectangular area of the circular area to obtain the official seal positive sample, wherein the expression of the circumscribed rectangular area is as follows:
x=[X-R-a,X+R+a];
y=[Y-R-a,Y+R+a];
wherein, (X, Y) is the center coordinates of the circular area, R is the radius of the circular area, and a is a preset offset and is a positive number.
From the above description, the integrity of the red region where the acquired official seal pattern is located is effectively ensured by the hough circle detection method, so as to obtain the high-quality first pseudo official seal pattern. Meanwhile, a certain offset a value is reserved, so that the cut external rectangular area can be ensured to completely contain a complete official seal pattern, and a high-quality official seal positive sample is ensured to be obtained.
Further, the step S20 specifically includes the following steps:
s21, loading a graph library and drawing a blank canvas;
and S22, drawing a official seal pattern on the blank canvas according to a preset official seal pattern, randomly selecting corresponding official seal characters, and pasting the official seal characters to corresponding positions on the official seal pattern to obtain the second pseudo-official seal pattern.
According to the description, the second pseudo official seal pattern is obtained by drawing and is different from the first pseudo official seal pattern obtained by the 'sectional drawing', so that more various and abundant official seal negative sample materials are provided for the subsequent training of the convolutional neural network model.
Further, the step S30 specifically includes the following steps:
s31, carrying out graphic processing on the official seal positive sample, the first pseudo official seal pattern and the second pseudo official seal pattern to obtain a plurality of official seal positive samples, the first pseudo official seal patterns and the second pseudo official seal patterns;
s32, acquiring the position areas and the radiuses of all official seal patterns in the positive sample file by adopting a Hough circle detection method;
s33, randomly generating a rectangular area in the positive sample file;
s34, judging whether the rectangular area is intersected with the position areas of all the obtained official seal patterns, if the rectangular area is separated from the corresponding circle of all the official seal patterns, taking the rectangular area as an area to be pasted, otherwise, repeating the step S33;
s35, randomly selecting the first or second pseudo official seal pattern after the graphics processing in step S31, and separating the pattern pixel from the background according to the R, G, B color channel value if [ (r)2-g2)+(r2-b2)]If the value of the pattern pixel is larger than a first preset value and R is larger than a second preset value, the pattern pixel is reserved, otherwise the value of the pattern pixel is reset to be white, wherein R is an R channel pixel value, G is a G channel pixel value, B is a B channel pixel value, the first preset value is larger than or equal to 600, and the second preset value is larger than or equal to 120;
s36, covering the first pseudo official seal pattern or the second pseudo official seal pattern obtained after the processing of the step S35 to the region to be pasted, and intercepting the region to be pasted to obtain the official seal negative sample;
and S37, repeating the steps S33-S36 to obtain a plurality of official seal negative samples.
As can be seen from the above description, the first pseudo official seal sample and the second pseudo official seal sample obtained by "matting" and "drawing" are separated from the background to obtain a sample with only the official seal pattern, so as to avoid that the pattern obtained by "matting" or "drawing" also contains the content of other non-official seal patterns, for example, the first pseudo official seal pattern obtained by "matting" may contain black text in the original official sample file; and then pasting the common seal negative samples to the rectangle generated in the non-common seal area in the positive sample file in a pasting mode to generate a plurality of common seal negative samples.
Further, the step S31 is specifically:
and respectively and randomly adding noise points, randomly adjusting the chromaticity and randomly adjusting the contrast ratio to each official seal positive sample, the first pseudo-official seal pattern and the second pseudo-official seal pattern to obtain a plurality of official seal positive samples, the first pseudo-official seal patterns and the second pseudo-official seal patterns.
From the above description, through image processing, the colors, the contrasts and the like of the finally generated positive and negative samples of the official seal are different, the number of the positive and negative samples of the official seal is further increased, and meanwhile, the subsequent training of the convolutional neural network model is more robust to the first degree.
Referring to fig. 2, a common seal positive and negative sample generation terminal includes a first memory, a first processor, and a first computer program stored in the first memory and executable on the first processor, where the first processor implements the steps in the common seal positive and negative sample generation method when executing the first computer program.
As can be seen from the above description, the beneficial effects of the present invention are: based on the same technical concept, the method for generating the positive and negative samples of the official seal is matched, the positive and negative samples of the official seal are generated at the terminal, and a plurality of positive and negative samples of the official seal are generated in the modes of image extraction, segmentation and image drawing, so that the official seal obtained by 'sectional drawing' can be distinguished by a neural network obtained by subsequent training and the official seal is drawn by software, and the problem that the training convolution neural network model in the prior art cannot achieve a good true checking effect due to insufficient data is solved.
Referring to fig. 3, a method for verifying official seal by using the method for generating the positive and negative samples of official seal includes the following steps:
s40, converting the official seal positive sample and the official seal negative sample into a format required by training the convolutional neural network model;
s50, training the official seal positive and negative samples after format conversion based on the convolutional neural network model to obtain an official seal true and false classifier;
and S60, verifying the authenticity of the official seal on the file to be tested by adopting the official seal authenticity classifier.
As can be seen from the above description, the beneficial effects of the present invention are: a plurality of official seal positive and negative samples obtained by the official seal positive and negative sample generation method are used for training a convolutional neural network model, an official seal true and false classifier is obtained, and the official seal in the file to be tested is subjected to rapid true and false verification, so that the accurate and rapid official seal verification effect is realized.
Further, the step S40 specifically includes the following steps:
s41, respectively creating a training set, a verification set and a test set file;
s42, respectively taking a preset number of the official seal positive samples and the official seal negative samples and distributing the samples to the training set and the verification set according to the proportion of 3:1, wherein the number of the official seal positive samples and the number of the official seal negative samples in the training set and the verification set are the same;
s43, distributing the remaining number of official seal positive samples and official seal negative samples to the test set;
s44, respectively reading the images in the training set, the verification set and the test set to obtain a training image, a verification image and a test image;
s45, constructing a training sample generator, a verification sample generator and a test sample generator by using an ImageGenerator function in an image processing auxiliary tool module carried by Keras, and correspondingly inputting the training image, the verification image and the test image into the training sample generator, the verification sample generator and the test sample generator respectively;
s46, the training sample generator, the verification sample generator and the test sample generator normalize the pixel values of the training image, the verification image and the test image from [0,255] to [0,1] and unify the sizes of the training image, the verification image and the test image to be the same preset size;
s47, converting the labels of the official seal positive samples and the official seal negative samples in the training set, the verification set and the test set into binary data which can be input by the convolutional neural network model by using a flow _ from _ direction function of an image data generator in an image processing auxiliary tool module carried by Keras, wherein the number of the official seal positive samples and the number of the official seal negative samples in each batch conversion are 20, and the number of the official seal positive samples and the official seal negative samples in each batch conversion is 1;
and S48, generating a training set sample, a verification set sample and a test set sample according to the training image, the verification image and the test image processed in the step S46, and the corresponding pixel values and the binary data after normalization processing.
According to the above description, by constructing the training sample generator, the verification sample generator and the test sample generator, all the positive and negative samples of the official seal are converted into the images with uniform sizes and the pixel value range of [0,1], the labels of the positive and negative samples are converted into binary data with 0 as the negative sample and 1 as the positive sample, and finally the training set sample, the verification set sample and the test set sample are generated for training the convolutional neural network model.
Further, the step S50 specifically includes the following steps:
s51, calling the convolutional neural network model to be trained;
s52, adding a dense connection classifier on the convolutional neural network model and freezing a convolution base in the convolutional neural network model;
s53, training the convolutional neural network model end to end by utilizing the frozen convolutional bases, wherein the trained data are the training set sample, the verification set sample and the test set sample, and a official seal true and false classifier is obtained;
the step S60 specifically includes the following steps:
s61, acquiring a to-be-detected official seal image on a to-be-detected file, and extracting a feature vector of the to-be-detected official seal image by using the convolutional neural network model;
s62, performing color segmentation and Hough circle detection on the official seal image to be detected, and intercepting a circumscribed rectangle of each official seal image to be detected;
s63, leading each intercepted external rectangle into the test sample generator in sequence to obtain test data;
and S64, testing the accuracy of the test data by using the official seal true and false classifier, and inputting the feature vector into the official seal true and false classifier to obtain a classification result.
According to the description, the sample is generated through the sample generator, the convolutional neural network model is trained based on a deep learning mode, the official seal true and false classifier is finally obtained, the feature vector of the official seal pattern to be tested is extracted through the trained convolutional neural network model and is input into the official seal true and false classifier, the classification result can be rapidly output through the official seal true and false classifier, and effective official seal verification is achieved.
Referring to fig. 4, a official seal authenticity verification terminal includes a second memory, a second processor and a second computer program stored on the second memory and executable on the second processor, where the second processor implements the steps in the official seal authenticity verification method when executing the second computer program.
As can be seen from the above description, the beneficial effects of the present invention are: based on the same technical concept, the official seal authenticity verifying method is matched, the official seal authenticity verifying terminal is provided, the plurality of official seal positive and negative samples obtained by the official seal positive and negative sample generating method are used for training the convolutional neural network model to obtain the official seal authenticity classifier, the official seal in the file to be tested is subjected to rapid authenticity verification, and the accurate and rapid official seal authenticity verifying effect is achieved.
Referring to fig. 1, a first embodiment of the present invention is:
a method for generating a positive and negative sample of a official seal comprises the following steps:
s10, obtaining a positive sample file covered with a official seal, and respectively carrying out sample extraction and official seal pattern segmentation on the official seal pattern in the positive sample file to obtain an official seal positive sample and a first false official seal pattern, wherein the sample extraction is to segment a graphic area comprising the official seal pattern according to a preset shape;
in this embodiment, step S10 specifically includes the following steps:
and S11, acquiring a scanned piece of the positive sample file in the folder, traversing each page of the scanned piece, and converting the number of pages covered with the official seal into a picture file.
S12, converting the image data of the picture file from the RGB color space to the HSV color space, and segmenting the picture file according to the H, S, V three-channel value to obtain a red area.
And S13, acquiring the coordinates and the radius of the official seal pattern in the red area by adopting a Hough circle detection method.
And S14, intercepting a circular area where the official seal pattern is located according to the obtained coordinates and the obtained radius to obtain a first pseudo-official seal pattern.
S15, intercepting a circumscribed rectangular area of the circular area according to the detected coordinate and radius to obtain a positive sample of the official seal, wherein the expression of the circumscribed rectangular area is as follows:
x=[X-R-a,X+R+a];
y=[Y-R-a,Y+R+a];
wherein, (X, Y) is the center coordinates of the circular area, R is the radius of the circular area, and a is a preset offset and is a positive number.
That is, in this embodiment, the integrity of the red region where the obtained official seal pattern is located is ensured by the hough circle detection method, so as to obtain the high-quality first pseudo-official seal pattern. Meanwhile, a certain offset a value is reserved, so that the cut external rectangular area can be guaranteed to completely contain a complete official seal pattern, a high-quality official seal positive sample is guaranteed, and the a value is generally set to be 1.
S20, drawing the official seal pattern by using a graphic library to obtain a second pseudo-official seal pattern;
in this embodiment, step S20 specifically includes the following steps:
and S21, loading the graphic library and drawing a blank canvas.
And S22, drawing a official seal pattern on the blank canvas according to the preset official seal pattern, randomly selecting corresponding official seal characters, and pasting the official seal characters to corresponding positions on the official seal pattern to obtain a second pseudo-official seal pattern.
In this embodiment, a official seal pattern with a circle diameter of 420px and a line width of 12px in a preset official seal pattern is selected, a side line of the official seal is drawn at first, and then a five-pointed star pattern at the center of the official seal is drawn, wherein the five-pointed star pattern can directly use text characters, and the preset width and height of the five-pointed star are all drawn by 90 px; secondly, drawing a ring-shaped character close to the upper part in the side line of the official seal, wherein the sub-height of the preset character is 70px, the distance between the upper end of the character and the side line of the official seal is 10px, the angle of the ring plate is 250-270 degrees, and the character style is a long Song body; then drawing an annular official seal code close to the lower part in the official seal side line, presetting the official seal code to be 13 bits, the height to be 12px, the distance between the lower end of each number and the official seal side line to be 10px, and using the font to be a Song dynasty body; and finally, drawing horizontal characters below the five-pointed star, wherein the height of the horizontal characters is preset to be 64px, the distance between the top end of the characters and the horizontal line of the center of the official seal is 65px, and the used character style is the long Song style. After the drawing is finished, the generated official seal image is stored, and official seal patterns with various preset patterns can be drawn according to needs, so that the diversity of subsequent official seal negative samples is increased.
In this embodiment, a second pseudo official seal pattern is obtained by drawing, which is different from the first pseudo official seal pattern obtained by the "matting", so as to provide more various and abundant official seal negative sample materials for the subsequent training of the convolutional neural network model.
S30, respectively pasting a first pseudo official seal pattern and/or a second pseudo official seal pattern on the official seal-free area of the positive sample file, and carrying out corresponding sample extraction to obtain an official seal negative sample;
in this embodiment, step S30 specifically includes the following steps:
s31, carrying out graphic processing on the official seal positive sample, the first pseudo official seal pattern and the second pseudo official seal pattern to obtain a plurality of official seal positive samples, first pseudo official seal patterns and second pseudo official seal patterns;
the graphic processing specifically includes: and respectively and randomly adding noise points, randomly adjusting the chromaticity and randomly adjusting the contrast ratio to each official seal positive sample, the first pseudo official seal pattern and the second pseudo official seal pattern to obtain a plurality of official seal positive samples, the first pseudo official seal patterns and the second pseudo official seal patterns. The color, the contrast and the like of the finally generated official seal positive and negative samples are different through image processing, the number of the official seal positive and negative samples is further increased, and meanwhile, the subsequent training of the convolutional neural network model is more robust to the first degree.
And S32, acquiring the position areas and the radiuses of all official seal patterns in the positive sample file by adopting a Hough circle detection method.
S33, randomly generating a rectangular area in the positive sample file.
And S34, judging whether the rectangular area is intersected with the position areas of all the obtained official seal patterns, if the rectangular area is separated from the corresponding circles of all the official seal patterns, taking the rectangular area as an area to be pasted, otherwise, repeating the step S33.
S35, randomly selecting a first pseudo official seal pattern or a second pseudo official seal pattern after the graphic processing of the step S31 according to the value of R, G, B color channelSeparating the pattern pixels from the background if r2-g2)+(r2-b2)]If the value of R is greater than the first preset value and R is greater than the second preset value, the pattern pixel is retained, otherwise the value of the pattern pixel is reset to white, where R is the R channel pixel value, G is the G channel pixel value, and B is the B channel pixel value, in this embodiment, the first preset value is 800, and the second preset value is 150. In other equivalent embodiments, the first preset value is greater than or equal to 600, and the second preset value is greater than or equal to 120.
And S36, covering the first pseudo official seal pattern or the second pseudo official seal pattern obtained after the processing of the step S35 to a region to be pasted, and intercepting the region to be pasted to obtain an official seal negative sample.
And S37, repeating the steps S33-S36 to obtain a plurality of official seal negative samples.
That is, in this embodiment, the first pseudo official seal sample and the second pseudo official seal sample obtained by "matting" and "drawing" are separated from the background to obtain a sample having only official case patterns, so as to avoid that the patterns obtained by "matting" or "drawing" also contain the contents of other non-official seal patterns, for example, the first pseudo official seal pattern obtained by "matting" may contain black text in the original positive sample file, and then pasted to the rectangle generated in the non-official seal region in the positive sample file in a pasting manner, so as to generate a plurality of official seal negative samples.
In the embodiment, the positive and negative samples of the multiple official seals are generated in the modes of image extraction, segmentation and image drawing, so that the neural network obtained by subsequent training can distinguish the official seal obtained by 'matting' and the official seal drawn by software, and the problem that the training convolutional neural network model in the prior art is not sufficient in data and cannot achieve a good true test effect is solved.
Referring to fig. 2, the second embodiment of the present invention is:
on the basis of the first embodiment, in cooperation with the method for generating a positive and negative sample of a official seal of the first embodiment, a terminal 1 for generating a positive and negative sample of an official seal is provided, which includes a first memory 11, a first processor 12, and a first computer program stored in the first memory 11 and executable on the first processor 12, wherein the first processor 11 implements the steps in the method for generating a positive and negative sample of an official seal according to the first embodiment when executing the first computer program.
Referring to fig. 3, a third embodiment of the present invention is:
on the basis of any embodiment of the first embodiment or the second embodiment, by using the official seal positive sample and the official seal negative sample generated in the first embodiment or the second embodiment, the present embodiment provides an official seal verification method, which includes the steps of:
s40, converting the official seal positive sample and the official seal negative sample into a format required by a training convolutional neural network model;
in this embodiment, step S40 specifically includes the following steps:
and S41, respectively creating a training set file, a verification set file and a test set file.
And S42, respectively taking a preset number of official seal positive samples and official seal negative samples, and distributing the samples to a training set and a verification set according to the proportion of 3:1, wherein the number of the official seal positive samples and the number of the official seal negative samples in the training set and the verification set are the same.
And S43, distributing the remaining number of official seal positive samples and official seal negative samples to the test set.
And S44, respectively reading the images in the training set, the verification set and the test set to obtain a training image, a verification image and a test image.
S45, constructing a training sample generator, a verification sample generator and a test sample generator by using an ImageGenerator function in an image processing auxiliary tool module carried by Keras, and correspondingly inputting the training image, the verification image and the test image into the training sample generator, the verification sample generator and the test sample generator respectively.
S46, the training sample generator, the verification sample generator and the test sample generator normalize the pixel values of the training image, the verification image and the test image from [0,255] to [0,1], and unify the sizes of the training image, the verification image and the test image to be the same preset size;
in this embodiment, the preset size is 150 × 150, that is, the sizes of the positive and negative samples of all official seals are unified to 150 × 150, which is convenient for subsequent model training.
S47, converting the labels of the official seal positive samples and the official seal negative samples in the training set, the verification set and the testing set into binary data which can be input by a convolutional neural network model by using a flow _ from _ direction function of an image data generator in an image processing auxiliary tool module carried by Keras, wherein the number of the official seal positive samples and the number of the official seal negative samples which are converted in batches each time are 20, and the number of the official seal positive samples and the number of the official seal negative samples which are converted in batches each time are 1.
And S48, generating a training set sample, a verification set sample and a test set sample according to the training image, the verification image and the test image processed in the step S46 and the corresponding pixel values and binary data after normalization processing.
In other words, in this embodiment, by constructing the training sample generator, the verification sample generator, and the test sample generator, all the positive and negative samples of the official seal are converted into images with uniform sizes and pixel value ranges of [0,1], the labels of the positive and negative samples are converted into binary data with 0 being a negative sample and 1 being a positive sample, and finally, a training set sample, a verification set sample, and a test set sample are generated for training the convolutional neural network model.
S50, training the positive and negative samples of the official seal after format conversion based on the convolutional neural network model to obtain an official seal true and false classifier;
in this embodiment, step S50 specifically includes the following steps:
and S51, calling the convolutional neural network model to be trained.
And S52, adding a dense connection classifier on the convolutional neural network model and freezing the convolution base in the convolutional neural network model.
And S53, training the convolutional neural network model end to end by utilizing the frozen convolutional basis, wherein the training data are training set samples, verification set samples and test set samples, and obtaining the official seal true and false classifier.
In other words, in this embodiment, the sample generator generates a sample, the convolutional neural network model is trained based on a deep learning manner, and finally the official seal true and false classifier is obtained, so that the subsequent rapid verification of the authenticity of the official seal pattern to be detected is realized.
S60, verifying the authenticity of the official seal on the file to be tested by adopting an official seal authenticity classifier;
in this embodiment, step S60 specifically includes the following steps:
and S61, acquiring the official seal image to be detected on the file to be detected, and extracting the feature vector of the official seal image to be detected by utilizing the convolutional neural network model.
S62, performing color segmentation and Hough circle detection on the official seal image to be detected, and intercepting the circumscribed rectangle of each official seal image to be detected.
S63, leading each intercepted external rectangle into a test sample generator in sequence to obtain test data;
s64, testing the accuracy of the test data by using a official seal true and false classifier, and inputting the feature vector into the official seal true and false classifier to obtain a classification result;
in this embodiment, the output format of the classification result is:
[{“location”:{x:y:radius}
“tag”:true/false}
{“location”:{x:y:radius}
“tag”:true/false}
{“location”:{x:y:radius}
“tag”:true/false}]
in this embodiment, the feature vector of the official seal pattern to be tested is extracted through the trained convolutional neural network model and is input into the official seal true and false classifier, and the official seal true and false classifier can quickly output the classification result, thereby realizing effective official seal verification.
In this embodiment, the convolutional neural network model is trained by using the positive and negative samples of the official seal obtained in the first embodiment or the second embodiment, and the official seal true and false classifier is obtained to perform fast authenticity verification on the official seal in the file to be tested, so that an accurate and fast official seal authenticity verification effect is realized.
Referring to fig. 4, a third embodiment of the present invention is:
on the basis of the third embodiment, in cooperation with the official seal verification method of the third embodiment, a official seal verification terminal 2 is provided.
The fair-verification terminal 2 includes a second memory 21, a second processor 22, and a second computer program stored in the second memory 21 and executable on the second processor 22, and the second processor 21, when executing the second computer program, implements the steps in the official verification method according to the third embodiment.
In summary, the invention provides a method for generating a positive and negative sample of a official seal, a method for verifying the authenticity of the official seal and a terminal. Firstly, generating a plurality of official seal positive and negative samples in a mode of image extraction, segmentation and image drawing, then training a convolutional neural network model by utilizing the generated plurality of official seal positive and negative samples to obtain an official seal true and false classifier, and carrying out rapid true and false verification on the official seal in a file to be tested, thereby integrally realizing the following beneficial effects:
1. various and rich official seal positive and negative samples can be generated, and the problem of insufficient data for training a convolutional neural network model in the prior art is solved to a certain extent;
2. meanwhile, image processing (image extraction and segmentation) and image drawing methods are used to generate a official seal positive sample and two types of official seal negative samples, so that a neural network obtained by subsequent training can distinguish the work of 'image matting' and software drawing official seals;
3. further, random adjustment of noise points, chromaticity and contrast is carried out on official seal positive samples obtained by image extraction, first pseudo official seal patterns obtained by segmentation and second pseudo official seal patterns obtained by drawing, so that the number of all official seal positive and negative samples obtained subsequently is large, the colors, the contrast and the like are different, and the subsequent training of a convolutional neural network model can be more robust to a certain extent;
4. the convolutional neural network model based on deep learning is used, the depth features with scale and position invariance in the official seal image to be tested can be extracted, the classification result is obtained through the official seal authenticity classifier obtained through training, and the accurate and quick official seal authenticity verification effect is achieved.
The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all equivalent changes made by using the contents of the present specification and the drawings, or applied directly or indirectly to the related technical fields are included in the scope of the present invention.
Claims (10)
1. A method for generating a positive and negative sample of a official seal is characterized by comprising the following steps:
s10, obtaining a positive sample file covered with a official seal, and respectively carrying out sample extraction and official seal pattern segmentation on the official seal pattern in the positive sample file to obtain an official seal positive sample and a first false official seal pattern, wherein the sample extraction is to segment a graphic area comprising the official seal pattern according to a preset shape;
s20, drawing the official seal pattern by using a graphic library to obtain a second pseudo-official seal pattern;
and S30, respectively pasting the first pseudo official seal pattern and/or the second pseudo official seal pattern on the official seal-free area of the positive sample file, and performing corresponding sample extraction to obtain an official seal negative sample.
2. The method for generating official seal positive and negative samples according to claim 1, wherein the step S10 specifically comprises the following steps:
s11, obtaining a scanned piece of the positive sample file in the folder, traversing each page of the scanned piece, and converting the number of pages covered with common seals into a picture file;
s12, converting the image data of the picture file from an RGB color space to an HSV color space, and segmenting the picture file according to a H, S, V three-channel value to obtain a red region;
s13, acquiring coordinates and radius of the official seal pattern in the red area by adopting a Hough circle detection method;
s14, intercepting a circular area where the official seal pattern is located according to the obtained coordinate and the obtained radius to obtain the first pseudo official seal pattern;
s15, according to the detected coordinates and radius, intercepting a circumscribed rectangular area of the circular area to obtain the official seal positive sample, wherein the expression of the circumscribed rectangular area is as follows:
x=[X-R-a,X+R+a];
y=[Y-R-a,Y+R+a];
wherein, (X, Y) is the center coordinates of the circular area, R is the radius of the circular area, and a is a preset offset and is a positive number.
3. The method for generating official seal positive and negative samples according to claim 1, wherein the step S20 specifically comprises the following steps:
s21, loading a graph library and drawing a blank canvas;
and S22, drawing a official seal pattern on the blank canvas according to a preset official seal pattern, randomly selecting corresponding official seal characters, and pasting the official seal characters to corresponding positions on the official seal pattern to obtain the second pseudo-official seal pattern.
4. The method for generating official seal positive and negative samples according to claim 1, wherein the step S30 specifically comprises the following steps:
s31, carrying out graphic processing on the official seal positive sample, the first pseudo-official seal pattern and the second pseudo-official seal pattern to obtain a plurality of official seal positive samples, the first pseudo-official seal patterns and the second pseudo-official seal patterns;
s32, acquiring position areas and radiuses of all official seal patterns in the positive sample file by adopting a Hough circle detection method;
s33, randomly generating a rectangular area in the positive sample file;
s34, judging whether the rectangular area is intersected with the position areas of all the obtained official seal patterns, if the rectangular area is separated from the corresponding circles of all the official seal patterns, taking the rectangular area as an area to be pasted, otherwise, repeating the step S33;
s35, randomly selecting the first or second pseudo official seal pattern after the graphics processing in step S31, and separating the pattern pixel from the background according to the R, G, B color channel value if [ (r)2-g2)+(r2-b2)]If the value of the pattern pixel is larger than a first preset value and R is larger than a second preset value, the pattern pixel is reserved, otherwise the value of the pattern pixel is reset to be white, wherein R is an R channel pixel value, G is a G channel pixel value, B is a B channel pixel value, the first preset value is larger than or equal to 600, and the second preset value is larger than or equal to 120;
s36, covering the first pseudo official seal pattern or the second pseudo official seal pattern obtained after the processing of the step S35 to the region to be pasted, and intercepting the region to be pasted to obtain the official seal negative sample;
and S37, repeating the steps S33-S36 to obtain a plurality of official seal negative samples.
5. The method for generating official seal positive and negative samples according to claim 4, wherein the step S31 specifically comprises:
and respectively and randomly adding noise points, randomly adjusting the chromaticity and randomly adjusting the contrast ratio to each official seal positive sample, the first pseudo-official seal pattern and the second pseudo-official seal pattern to obtain a plurality of official seal positive samples, the first pseudo-official seal patterns and the second pseudo-official seal patterns.
6. An official seal positive and negative sample generation terminal, comprising a first memory, a first processor and a first computer program stored on the first memory and executable on the first processor, wherein the first processor implements the steps of a official seal positive and negative sample generation method according to any one of claims 1 to 5 when executing the first computer program.
7. An official seal authenticity verification method, characterized in that the official seal positive sample and the official seal negative sample obtained by the official seal positive and negative sample generation method according to any one of the claims 1 to 5 are adopted, and the method comprises the following steps:
s40, converting the official seal positive sample and the official seal negative sample into a format required by training the convolutional neural network model;
s50, training the official seal positive and negative samples after format conversion based on the convolutional neural network model to obtain an official seal true and false classifier;
and S60, verifying the authenticity of the official seal on the file to be tested by adopting the official seal authenticity classifier.
8. The official seal truth verification method according to claim 7, wherein the step S40 specifically comprises the steps of:
s41, respectively creating a training set, a verification set and a test set file;
s42, respectively taking a preset number of the official seal positive samples and the official seal negative samples and distributing the samples to the training set and the verification set according to the proportion of 3:1, wherein the number of the official seal positive samples and the number of the official seal negative samples in the training set and the verification set are the same;
s43, distributing the remaining number of official seal positive samples and official seal negative samples to the test set;
s44, respectively reading the images in the training set, the verification set and the test set to obtain a training image, a verification image and a test image;
s45, constructing a training sample generator, a verification sample generator and a test sample generator by using an ImageGenerator function in an image processing auxiliary tool module carried by Keras, and correspondingly inputting the training image, the verification image and the test image into the training sample generator, the verification sample generator and the test sample generator respectively;
s46, the training sample generator, the verification sample generator and the test sample generator normalize the pixel values of the training image, the verification image and the test image from [0,255] to [0,1] and unify the sizes of the training image, the verification image and the test image to be the same preset size;
s47, converting the labels of the official seal positive samples and the official seal negative samples in the training set, the verification set and the test set into binary data which can be input by the convolutional neural network model by using a flow _ from _ direction function of an image data generator in an image processing auxiliary tool module carried by Keras, wherein the number of the official seal positive samples and the number of the official seal negative samples in each batch conversion are 20, and the number of the official seal positive samples and the official seal negative samples in each batch conversion is 1;
and S48, generating a training set sample, a verification set sample and a test set sample according to the training image, the verification image and the test image processed in the step S46, the pixel values and the binary data corresponding to the training image, the verification image and the test image and subjected to the normalization processing.
9. The official seal truth verification method according to claim 8, wherein the step S50 specifically comprises the steps of:
s51, calling the convolutional neural network model to be trained;
s52, adding a dense connection classifier on the convolutional neural network model and freezing a convolution base in the convolutional neural network model;
s53, training the convolutional neural network model end to end by utilizing the frozen convolutional bases, wherein the trained data are the training set samples, the verification set samples and the test set samples, and obtaining a official seal true and false classifier;
the step S60 specifically includes the following steps:
s61, acquiring a to-be-detected official seal image on a to-be-detected file, and extracting a feature vector of the to-be-detected official seal image by using the convolutional neural network model;
s62, performing color segmentation and Hough circle detection on the official seal image to be detected, and intercepting a circumscribed rectangle of each official seal image to be detected;
s63, leading each intercepted external rectangle into the test sample generator in sequence to obtain test data;
and S64, testing the accuracy of the test data by using the official seal true and false classifier, and inputting the feature vector into the official seal true and false classifier to obtain a classification result.
10. An official seal authentication terminal comprising a second memory, a second processor and a second computer program stored on said second memory and executable on said second processor, said second processor implementing the steps of an official seal authentication method according to any one of claims 7 to 9 when executing said second computer program.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110822662.7A CN113505841B (en) | 2021-07-21 | 2021-07-21 | Official seal positive and negative sample generation method, official seal authenticity verification method and terminal |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110822662.7A CN113505841B (en) | 2021-07-21 | 2021-07-21 | Official seal positive and negative sample generation method, official seal authenticity verification method and terminal |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113505841A true CN113505841A (en) | 2021-10-15 |
CN113505841B CN113505841B (en) | 2023-02-10 |
Family
ID=78013320
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110822662.7A Active CN113505841B (en) | 2021-07-21 | 2021-07-21 | Official seal positive and negative sample generation method, official seal authenticity verification method and terminal |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113505841B (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106096667A (en) * | 2016-07-26 | 2016-11-09 | 江苏鸿信系统集成有限公司 | Bill images sorting technique based on SVM |
US10402699B1 (en) * | 2015-12-16 | 2019-09-03 | Hrl Laboratories, Llc | Automated classification of images using deep learning—back end |
CN112861906A (en) * | 2020-12-31 | 2021-05-28 | 深圳前海微众银行股份有限公司 | Method and device for detecting picture abnormity |
-
2021
- 2021-07-21 CN CN202110822662.7A patent/CN113505841B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10402699B1 (en) * | 2015-12-16 | 2019-09-03 | Hrl Laboratories, Llc | Automated classification of images using deep learning—back end |
CN106096667A (en) * | 2016-07-26 | 2016-11-09 | 江苏鸿信系统集成有限公司 | Bill images sorting technique based on SVM |
CN112861906A (en) * | 2020-12-31 | 2021-05-28 | 深圳前海微众银行股份有限公司 | Method and device for detecting picture abnormity |
Also Published As
Publication number | Publication date |
---|---|
CN113505841B (en) | 2023-02-10 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Zhang et al. | Interpreting adversarially trained convolutional neural networks | |
WO2021000702A1 (en) | Image detection method, device, and system | |
Mohammad et al. | Optical character recognition implementation using pattern matching | |
CN108090511B (en) | Image classification method and device, electronic equipment and readable storage medium | |
CN108596166A (en) | A kind of container number identification method based on convolutional neural networks classification | |
US10984284B1 (en) | Synthetic augmentation of document images | |
US8615129B2 (en) | Pattern separating extraction device, and pattern separating extraction method | |
CN105095892A (en) | Student document management system based on image processing | |
CN105631447A (en) | Method of recognizing characters in round seal | |
CN113223025B (en) | Image processing method and device, and neural network training method and device | |
CN110728687B (en) | File image segmentation method and device, computer equipment and storage medium | |
CN110555464A (en) | Vehicle color identification method based on deep learning model | |
CN109919149B (en) | Object labeling method and related equipment based on object detection model | |
CN106033528A (en) | Method and equipment for extracting specific area from color document image | |
CN107358184A (en) | The extracting method and extraction element of document word | |
CN106446885A (en) | Paper-based Braille recognition method and system | |
CN113076795A (en) | Automatic auditing method for form protocol image with seal | |
CN113221897B (en) | Image correction method, image text recognition method, identity verification method and device | |
CN111126266B (en) | Text processing method, text processing system, equipment and medium | |
CN113610090B (en) | Seal image identification and classification method, device, computer equipment and storage medium | |
KR20220088832A (en) | Seal certification assisting method using seal scanner | |
CN110705442A (en) | Method for automatically acquiring test paper answers, terminal equipment and storage medium | |
CN110263784A (en) | The English paper achievement of intelligence identifies input method | |
CN113505841B (en) | Official seal positive and negative sample generation method, official seal authenticity verification method and terminal | |
CN103617423A (en) | Image segmentation and recognition method based on color parameter |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |