Seal matching method and device, terminal equipment and storage medium
By performing format conversion, color analysis and edge detection on the target file, extracting and matching seal images, the problem of difficulty in seal verification consistency in the prior art is solved, and efficient and accurate seal recognition and verification are achieved.
Patent Information
- Application Number
- CN202411178995.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2024-12-31
AI Technical Summary
In the field of finance or insurance, it is difficult for the prior art to effectively verify whether the seal is consistent with the seal in the database, especially when the seal changes slightly, the recognition results are poorly robust, the processing process is longer and the efficiency is not high.
By obtaining the target file and converting the format, color analysis is performed to extract the target image, determining the seal position using edge detection, extracting the seal image and matching information with the preset seal, achieving accurate identification and verification of the seal.
It improves the accuracy and efficiency of seal recognition, reduces manual intervention, optimizes image processing results, and improves processing speed and reliability.
Smart Images

Figure CN119229146A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a seal matching method, device, terminal equipment and storage medium. Background Art
[0002] In the financial or insurance fields, the number of contracts signed is huge, and the need to verify the consistency of seals is particularly urgent. In these fields, the consistency recognition technology of seals faces many challenges, especially when the seal undergoes a slight change, the impact on the recognition result is very significant, and the robustness is poor. For example, subtle differences such as the depth of the seal, the amount of ink, and the direction of the seal will cause significant changes in the results of each stamp, making the processing complicated and the effect unsatisfactory. Compared with traditional methods, machine learning methods usually include the following steps: first determine the position of the seal through a detection model, then use text detection technology to identify the text on the seal, then extract the text through OCR technology, and finally compare the text on the seal with the expected text. However, the processing flow of this method is long and the efficiency is not high. Therefore, the existing technology still has certain difficulties in effectively verifying whether the seal is consistent with the seal in the database. Summary of the invention
[0003] The main purpose of the embodiments of the present invention is to provide a seal matching method, apparatus, terminal device and storage medium, aiming to solve the problem in the related art that there is still a certain degree of difficulty in effectively verifying whether a seal is consistent with a seal in a database.
[0004] In a first aspect, an embodiment of the present invention provides a seal matching method, comprising:
[0005] Obtaining a target file, and performing format conversion on the target file to obtain a corresponding initial image;
[0006] Performing color analysis on the initial image to obtain a target image corresponding to the initial image at a target pixel;
[0007] Performing seal edge detection on the target image according to edge detection to obtain a target position corresponding to the target seal;
[0008] Obtaining a seal image corresponding to the target seal from the initial image according to the target position;
[0009] The seal image is matched with a preset seal to obtain a matching result corresponding to the target seal.
[0010] In a second aspect, an embodiment of the present invention provides a seal matching device, comprising:
[0011] An image acquisition module is used to obtain a target file and perform format conversion on the target file to obtain a corresponding initial image;
[0012] An image analysis module, used for performing color analysis on the initial image to obtain a target image corresponding to the initial image at a target pixel;
[0013] An edge monitoring module is used to perform seal edge detection on the target image according to edge detection to obtain a target position corresponding to the target seal;
[0014] A seal extraction module, used for obtaining a seal image corresponding to the target seal from the initial image according to the target position;
[0015] The seal matching module is used to match the seal image with the preset seal to obtain the matching result corresponding to the target seal.
[0016] In the third aspect, an embodiment of the present invention further provides a terminal device, comprising a processor, a memory, a computer program stored in the memory and executable by the processor, and a data bus for realizing connection and communication between the processor and the memory, wherein when the computer program is executed by the processor, the steps of any one of the seal matching methods provided in the specification of the present invention are implemented.
[0017] In a fourth aspect, an embodiment of the present invention further provides a storage medium for computer-readable storage, characterized in that the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of any seal matching method provided in the specification of the present invention.
[0018] The embodiment of the present invention provides a seal matching method, apparatus, terminal device and storage medium. The method includes: obtaining a target file and performing format conversion to obtain a desired initial image. The format conversion step is the key to ensuring that the image is analyzed in a consistent standardized form during subsequent processing. Files of different formats may have different data structures and information contents. Therefore, by unifying the image format, subsequent operations can be simplified, potential compatibility issues can be avoided, and processing efficiency can be improved. Next, the initial image is subjected to color analysis to highlight important features or objects in the image. Color analysis can help identify and emphasize certain areas of specific colors in the image, which is crucial for further processing. Through this analysis, different areas and objects in the image can be distinguished, thereby significantly improving the accuracy of subsequent processing steps. The result of the color analysis will generate a target image, which is a specific view of the initial image extracted at the target pixel. After obtaining the target image, edge detection is used to identify the target seal in the target image. Edge detection can accurately locate the edge of the seal, thereby determining the specific position of the seal in the target image. This process improves the accuracy of seal extraction and recognition, because accurate edge positioning can ensure that the processed area is limited to the seal itself, excluding other interference factors. Subsequently, the image of the target seal is extracted from the initial image and detailed processing is focused on the seal area. This method ensures a detailed analysis and processing of the seal area. Next, the extracted seal image is matched with the preset seal. This step can accurately identify the type of the target seal and thus verify its identity or content. Through these steps, the accuracy, efficiency and automation level of image processing and analysis can be significantly improved. The implementation of each step enhances the accuracy and efficiency of image processing. From format conversion, color analysis, edge detection, to seal extraction and matching, the entire process optimizes image processing results, reduces manual intervention, and improves processing speed and reliability in various application scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0020] Figure 1 A schematic flow chart of a seal matching method provided by an embodiment of the present invention;
[0021] Figure 2 for Figure 1 A schematic flow chart of sub-step S103 of the seal matching method;
[0022] Figure 3A schematic diagram of a scenario for implementing the seal matching method provided in this embodiment;
[0023] Figure 4 A schematic diagram of the module structure of a seal matching device provided by an embodiment of the present invention;
[0024] Figure 5 A schematic block diagram of the structure of a terminal device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0025] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0026] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.
[0027] It should be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0028] The embodiment of the present invention provides a seal matching method, device, terminal device and storage medium. The seal matching method can be applied to a terminal device, which can be an electronic device such as a tablet computer, a laptop computer, a desktop computer, a personal digital assistant and a wearable device. The terminal device can be a server or a server cluster.
[0029] Some embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0030] Please refer to Figure 1 , Figure 1 A schematic flow chart of a seal matching method provided in an embodiment of the present invention.
[0031] like Figure 1 As shown, the seal matching method includes steps S101 to S105.
[0032] Step S101: Obtain a target file, and perform format conversion on the target file to obtain a corresponding initial image.
[0033] For example, the contract documents are obtained from the company's internal storage system, email attachments or file sharing platforms, or received from external partners, customers or suppliers, possibly through email, file transfer protocol (FTP), cloud storage links, etc. The target file can be a contract document with a seal in various fields.
[0034] For example, in the financial field or the insurance field, a contract document signed with a customer is determined as the target document.
[0035] Exemplarily, the target file may be in the format of a PDF document, an image file (such as JPG, PNG), etc. To ensure that the obtained file format can be used in subsequent processing and conversion steps, after obtaining the target file, the target file is converted into a format to obtain a corresponding initial image.
[0036] For example, the target file is converted into an image format such as JPEG, PNG or the like as needed to obtain an initial image. For example, when the target file is a PDF file, the target file is converted into a JPEG image.
[0037] In some embodiments, the format conversion of the target file to obtain the corresponding initial image includes: determining a target color and a target edge shape; screening the target file according to the target color to obtain a first intermediate file; performing edge recognition on the target color in the first intermediate file to obtain an initial edge shape corresponding to the target color; screening the first intermediate file according to the initial edge shape and the target edge shape to obtain a second intermediate file; and format conversion of the second intermediate file to obtain the corresponding initial image.
[0038] Exemplarily, the target color to be screened is determined, such as red or blue, and then the target pixel is determined according to the target color. The target edge shape is defined, and the target edge shape can be a circle, a square, or other predetermined stamp edge shapes.
[0039] Exemplarily, the corresponding target pixel is determined according to the target color, so as to calculate the minimum difference between the target pixel and the pixels contained in the target file. When the minimum difference is less than a preset value, the target file is determined as the first intermediate file; when the minimum difference is greater than or equal to the preset value, the target file is eliminated.
[0040] Exemplarily, all pixel positions corresponding to the target color in the first intermediate file are obtained, position clustering is performed based on all pixel positions, clustering clusters are obtained, and then the largest cluster in the clustering clusters is obtained, and then edge recognition is performed on the largest cluster to obtain the initial edge shape corresponding to the target color.
[0041] Exemplarily, the initial edge shape and the target edge shape are similarly calculated to obtain a similarity value. If the similarity value is greater than or equal to a preset similarity threshold, the first intermediate file is retained; if the similarity value is less than the preset similarity threshold, the first intermediate file is deleted. Thus, the retained first intermediate file will be determined as the second intermediate file.
[0042] Exemplarily, the second intermediate file is converted into an image format, such as JPEG, PNG or the like, so as to obtain an initial image.
[0043] Specifically, clarifying the target color and target edge shape helps to accurately extract the initial image. By using the target color and target edge shape, the intermediate files that meet the characteristics can be screened out, thereby excluding the files that do not meet the requirements. This process not only narrows the screening range, but also improves the processing efficiency, providing good support for subsequent seal analysis.
[0044] Step S102: Perform color analysis on the initial image to obtain a target image corresponding to the initial image at a target pixel.
[0045] Exemplarily, the real stamp color corresponding to the target pixel is determined, such as red or blue. The initial image is subjected to color analysis to identify whether the initial image contains the target pixel. If the initial image contains the target pixel, the initial image is retained and used as the target image. If the initial image does not contain the target pixel, the initial image is deleted.
[0046] For example, the initial image includes image 1, image 2, image 3, and image 4. When image 1 and image 3 contain target pixels, image 1 and image 3 are determined as target images; and image 2 and image 4 are deleted.
[0047] In some embodiments, performing color analysis on the initial image to obtain a target image corresponding to the initial image at the target pixel includes: performing color analysis on the initial image according to the target color to obtain a target area corresponding to the initial image; obtaining a target shape corresponding to the target color in the target area, and determining the target image corresponding to the initial image at the target pixel according to the target shape.
[0048] Exemplarily, the initial image is preprocessed, including denoising and adjusting the image contrast, to ensure that the subsequent color analysis is more accurate. The initial image is converted from the RGB color space to the HSV or LAB color space. This conversion can make the color analysis more intuitive, especially more effective in extracting specific colors.
[0049] Exemplarily, the range of the target color (for example, the value range of hue, saturation, and brightness) is clarified to obtain the pixel position corresponding to the target color from the initial image, and the horizontal minimum and horizontal maximum values in the horizontal direction are determined according to the pixel position, as well as the vertical minimum and vertical maximum values in the vertical direction; thereby, the target area corresponding to the initial image is determined according to the horizontal minimum, horizontal maximum, vertical minimum, and vertical maximum values.
[0050] In addition, to ensure the accuracy of the target area, the pixel position can be noise-removed to determine the horizontal minimum, horizontal maximum, vertical minimum and vertical maximum of the pixel position after noise removal, and then the target area corresponding to the initial image is determined based on the horizontal minimum, horizontal maximum, vertical minimum and vertical maximum to ensure the accuracy of the target area.
[0051] Exemplarily, a target shape corresponding to the target color in the target area is obtained by curve fitting, and then the target shape and the target edge shape are similarly calculated to obtain a similarity value. If the similarity value is greater than or equal to a preset similarity threshold, the initial image under the target area is determined as the target image. If the similarity value is less than the preset similarity threshold, there is no need to determine the initial image under the target area as the target image.
[0052] Specifically, by performing color analysis of the target color on the initial image, the target area in the image can be accurately identified and extracted. This method ensures that the part that matches the target color is accurately separated from the complex image, which helps to improve the accuracy of target recognition. Screening the target image according to the target shape can ensure that the obtained target image contains accurate target features, thereby providing an accurate basis for subsequent analysis.
[0053] Step S103: Perform seal edge detection on the target image according to edge detection to obtain a target position corresponding to the target seal.
[0054] Exemplarily, the target image is converted into a grayscale image, because edge detection is usually more effective on grayscale images. A filter (such as a Gaussian filter) is used to remove noise in the image to reduce interference with edge detection. Common algorithms include Canny edge detection, Sobel operator, Prewitt operator, etc. A suitable algorithm is selected for edge detection. Thus, the selected edge detection algorithm is applied to the grayscale image to generate an edge image.
[0055] Exemplarily, the edge image is smoothed to remove pseudo edges that may be generated during edge detection. The edge contour is extracted from the edge image. The edge image already contains the edge information of the target seal, which is usually manifested as continuous lines or curves in the target seal. Then, a contour detection algorithm (such as the `findContours` function in OpenCV) is used to identify the contours in the edge image, thereby screening out the contours that may represent the target seal based on the size, shape, and position of the contour. The area and shape features of the contour (such as circularity, aspect ratio, etc.) can be used to assist in screening. The bounding box is then calculated for the screened contour. The bounding box can help determine the target position of the target seal in the target image.
[0056] In some implementations, the seal edge detection is performed on the target image according to the edge detection to obtain the target position corresponding to the target seal. Specifically, referring to Figure 2 , step S103 includes: sub-step S1031 to sub-step S1034.
[0057] Sub-step S1031: Detect the edge of the target image using an edge detection algorithm to obtain a first edge image.
[0058] Exemplarily, the target image is converted into a grayscale image. Edge detection algorithms usually work best on grayscale images because color information does not interfere with edge detection. A filtering process (such as Gaussian filtering) is applied to the grayscale image to remove noise, thereby reducing the impact of small noise points in the grayscale image on edge detection.
[0059] Exemplarily, an edge detection algorithm is selected, including but not limited to Canny edge detection, Sobel operator, Prewitt operator, Laplace operator, etc., so that the selected edge detection algorithm is applied to the preprocessed grayscale image to obtain a first edge image.
[0060] Sub-step S1032: using a non-maximum suppression algorithm to perform a redundancy removal operation on the first edge image to obtain a second edge image.
[0061] Exemplarily, the gradient direction of each pixel in the first edge image is calculated. The gradient direction refers to the orientation of the edge and is used to determine how to compare in non-maximum suppression. Based on the gradient direction, each pixel is classified as an edge in a specific direction, such as horizontal, vertical or diagonal. Typically, the gradient direction is divided into several main directions such as 0°, 45°, 90° and 135°.
[0062] Exemplarily, for each pixel in the first edge image, its neighboring pixels in the gradient direction are checked. For example, according to the gradient direction of the current pixel, the two pixels before and after in this direction are selected. The gradient intensity of the current pixel is compared with the two pixels before and after along the gradient direction. If the intensity of the current pixel is a local maximum (i.e., greater than the intensity of the two neighboring pixels), the current pixel is retained; otherwise, its intensity value is set to 0 (i.e., non-edge point).
[0063] Exemplarily, the image obtained after non-maximum suppression is the second edge image. In the second edge image, only those edges identified as local maxima are retained, and the other parts are suppressed to 0. Thus, by removing redundant edge pixels, the details of the edge are accurately retained, making the final second edge image clearer and more accurate.
[0064] Sub-step S1033: performing contour recognition on the second edge image to obtain a target contour corresponding to the target seal.
[0065] Exemplarily, a contour detection algorithm is applied to the second edge image. The contour detection algorithm will identify closed edges in the image and extract contours. These contours will represent the edge shape of the target seal. Thus, based on the characteristics of the contours (such as size, shape, position, etc.), the target contours that may represent the target seal are screened out.
[0066] Sub-step S1034: obtaining the target position corresponding to the target seal from the target image according to the target outline.
[0067] For example, calculate the center point of the target contour, which is usually represented by the geometric center of the contour. The center point can be obtained by calculating the average position of the contour points. Calculate a bounding box for the target contour. The bounding box is a rectangle that can surround the entire contour. You can use the minimum enclosing rectangle or convex hull of the contour to determine the size and position of the bounding box.
[0068] Exemplarily, the target position of the target stamp is described using the calculated center point or bounding box. The center point usually gives the target precise position of the stamp, while the bounding box provides the overall area of the target stamp. Thus, the center point or bounding box of the contour is marked on the target image. This can be done by drawing a marking point or a rectangular box to obtain the target position corresponding to the target stamp.
[0069] Specifically, edge detection and non-maximum suppression can extract clear edge information, reduce noise and redundancy, and thus improve the accuracy of target contour recognition. Clear edges and accurate contour recognition make image analysis results more reliable, thereby obtaining more accurate target positions, providing support for subsequent improvement of seal matching accuracy.
[0070] Step S104: obtaining a seal image corresponding to the target seal from the initial image according to the target position.
[0071] Exemplarily, the area of the target stamp is defined according to the target position, which may include a center point of the target stamp, a bounding box, or other geometric information describing the target position.
[0072] For example, if the target location is a bounding box, you need to obtain the coordinates and dimensions (such as the upper left corner coordinates, width, and height) of the bounding box.
[0073] Exemplarily, the target position is mapped onto the initial image and then the target stamp region is cut out to obtain the stamp image. If the target position is a bounding box, the coordinates and size of the bounding box may be used to cut out the stamp image.
[0074] Step S105: Match the seal image with the preset seal to obtain a matching result corresponding to the target seal.
[0075] Exemplarily, the preset stamp is a reference stamp image or template, and the stamp image and the preset stamp are then standardized, such as resizing and rotating, so that they have the same scale and direction, which can help reduce errors in the matching process.
[0076] Exemplarily, feature information such as edges, corners, textures, colors, etc. is extracted from the seal image. These features can be used for image matching and comparison. The same feature extraction is performed on each preset seal to establish a feature database or feature descriptor. According to the extracted features, a suitable matching algorithm is selected. Common matching methods include: template matching, feature matching, similarity measurement (such as Euclidean distance, cosine similarity, etc.), etc. Thus, according to the score or similarity calculated by the matching method, it is determined which preset seal has the best matching result with the seal image.
[0077] For example, a threshold value may be set to determine the accuracy of the match, and the result exceeding the threshold value is considered to be a valid match, and then the preset seal with the highest score among the valid matches is taken as the matching result. If the score or similarity calculated according to the matching method does not exceed the threshold value, it is determined that no matching seal is found in the preset seals.
[0078] In some embodiments, the information matching of the seal image with the preset seal to obtain the matching result corresponding to the target seal includes: using the feature extraction layer of a deep neural network model to perform image feature extraction on the seal image to obtain a first feature vector corresponding to the seal image; using the feature extraction layer to perform image feature extraction on the preset seal to obtain a second feature vector corresponding to the preset seal; using the feature splicing layer of the deep neural network model to splice the first feature vector and the second feature vector to obtain a target feature vector; using the feature prediction layer of the deep neural network model to perform matching prediction on the target feature vector to obtain a prediction result; and determining the matching result corresponding to the target seal based on the prediction result.
[0079] Exemplarily, the pre-trained deep neural network model includes a feature extraction layer, a feature concatenation layer, and a feature prediction layer.
[0080] Exemplarily, the seal image is input into the feature extraction layer of the deep neural network model. The feature extraction layer is usually a convolutional layer or other types of layers, which are used to extract high-level feature information from the image. Through the forward propagation process of the network, the first feature vector corresponding to the seal image is obtained. The first feature vector is a high-dimensional feature representation that captures the key information of the seal image. Similarly, the preset seal is input into the feature extraction layer to obtain the second feature vector corresponding to the preset seal, and the second feature vector describes the characteristics of the preset seal.
[0081] Exemplarily, the first feature vector and the second feature vector are concatenated together using a feature concatenation layer of a deep neural network model. The feature concatenation layer is responsible for combining different feature vectors into a larger feature vector, thereby obtaining a target feature vector that integrates feature information of the seal image and the preset seal.
[0082] Exemplarily, the target feature vector is input into the feature prediction layer of the deep neural network model. The feature prediction layer is usually a fully connected layer or other prediction layer, which is used to classify and predict the spliced features. Matching prediction is performed based on the target feature vector, and a prediction result is output. The prediction result usually indicates the similarity or matching probability between the seal image and the preset seal.
[0083] For example, the degree of match between the seal image and the preset seal is determined based on the prediction result. The prediction result may be a matching category label, a similarity score, or other forms of output. Thus, based on the analysis of the prediction result, the final matching result corresponding to the seal image is determined. The matching result includes the seal type matched by the seal image, the matching accuracy evaluation, etc.
[0084] For example, if there are three seal images in the target file, three first feature vectors can be obtained, set as x1, x2, and x3. Assuming that there are two preset seals, two second feature vectors can be obtained, set as y1 and y2. Then the spliced target feature vectors are [x1, y1], [x1, y2], [x2, y1], [x2, y2], [x3, y1], [x3, y2]. Therefore, by splicing batches, only one operation is required to obtain the final prediction result, [r1, r2, r3, r4, r5, r6], where ri represents the output result of the i-th target feature vector, so that the seal type corresponding to the seal image corresponding to x1 is determined according to r1 and r2, the seal type corresponding to the seal image corresponding to x2 is determined by r3 and r4, and the seal type corresponding to the seal image corresponding to x3 is determined by r5 and r6.
[0085] Specifically, by processing the seal image using the feature extraction layer of the deep neural network model, a high-dimensional feature vector can be obtained. The deep network can automatically extract complex patterns and features in the image, such as edges, textures, shapes, etc., without the need for manually designed features. These deep features can more accurately describe the details of the seal. The target feature vector is generated by splicing the first feature vector (seal image) and the second feature vector (preset seal). This splicing process combines the two feature information, which helps to more comprehensively represent the relationship between the seal image and the preset seal. The spliced target feature vector contains the comprehensive features of the seal image and the preset seal, and can better capture the similarities and differences between them. The target feature vector is input into the feature prediction layer of the deep neural network model for matching prediction, and a clear prediction result can be obtained. This prediction result usually includes the probability of matching, category label or similarity score, which helps to accurately judge the matching between the seal image and the preset seal.
[0086] In some embodiments, obtaining the deep neural network model includes: obtaining first training data, the first training data including a real seal and an associated seal corresponding to the real seal in the preset seal; performing data enhancement on the real seal to obtain an enhanced image, and then forming second training data based on the enhanced image and the associated seal; removing the associated seal from the preset seal to obtain an irrelevant seal corresponding to the enhanced image; forming the third training data with the enhanced image and the irrelevant seal; determining target training data based on the second training data and the third training data; and performing model training on the deep neural network model based on the target training data to obtain the deep neural network model.
[0087] Exemplarily, the first training data is collected, including a real seal and its associated seal in a preset seal. The real seal refers to an actual seal image, and the associated seal refers to a seal related to the real seal in a preset seal set.
[0088] Exemplarily, the real seal image is processed using data enhancement technology. Data enhancement may include operations such as rotation, cropping, scaling, adjusting brightness and contrast, etc. to generate an enhanced image. The enhanced image is paired with an associated seal of the real seal in the preset seal to form the second training data. The second training data includes the enhanced image and its corresponding associated seal.
[0089] Exemplarily, the associated stamp corresponding to the enhanced image is removed from the preset stamps to obtain irrelevant stamps. These irrelevant stamps refer to other stamps that are irrelevant to the enhanced image. The enhanced image is paired with the irrelevant stamps to form third training data. The third training data includes the enhanced image and its corresponding irrelevant stamps. The third training data is used as a negative sample.
[0090] Exemplarily, the second training data and the third training data are jointly determined as target training data. The target training data is usually used to train a model so that it can distinguish between related seals and irrelevant seals.
[0091] Exemplarily, the deep neural network model is trained using target training data, so that the deep neural network model learns how to identify the corresponding seal based on the input image.
[0092] Specifically, the enhanced image and the associated seal form the second training data, and the enhanced image and the unrelated seal form the third training data, which helps the model learn clear distinguishing features. This method can improve the model's recognition accuracy of seal categories and reduce misclassification. By eliminating associated seals and introducing unrelated seals for training, the model can better learn how to exclude irrelevant features and focus on identifying features related to the target. This helps the model avoid misidentification in practical applications and improves the ability to accurately recognize related seals.
[0093] In some embodiments, the method also includes: obtaining a first sub-image and a second sub-image from the seal image; using the feature extraction layer to perform image feature extraction on the first sub-image to obtain a third feature vector corresponding to the first sub-image; using the feature extraction layer to perform image feature extraction on the second sub-image to obtain a fourth feature vector corresponding to the second sub-image; using the feature splicing layer to splice the third feature vector and the fourth feature vector to obtain a fifth feature vector; using the feature prediction layer to perform matching prediction on the fifth feature vector to obtain the degree of correlation between the first sub-image and the second sub-image.
[0094] Exemplarily, the pre-trained deep neural network model includes a feature extraction layer, a feature concatenation layer, and a feature prediction layer.
[0095] Exemplarily, two images are obtained arbitrarily from the seal image and respectively determined as the first sub-image and the second sub-image, and then the first sub-image is input into the feature extraction layer of the deep neural network model to obtain the third eigenvector corresponding to the first sub-image. Similarly, the second sub-image is input into the feature extraction layer to obtain the fourth eigenvector corresponding to the second sub-image. The feature concatenation layer of the deep neural network model is then used to concatenate the third eigenvector and the fourth eigenvector together. The feature concatenation layer is responsible for combining different eigenvectors into a larger eigenvector to obtain a fifth eigenvector, which integrates the feature information between the first sub-image and the second sub-image.
[0096] Exemplarily, the fifth eigenvector is input into a feature prediction layer of a deep neural network model. The feature prediction layer is usually a fully connected layer or other prediction layer, which is used to classify and predict the spliced features. Matching prediction is performed based on the fifth eigenvector to output a prediction result. The prediction result usually indicates the degree of similarity between the first sub-image and the second sub-image.
[0097] Exemplarily, based on the degree of similarity between the first sub-image and the second sub-image, it is determined whether the first sub-image and the second sub-image are from the same seal, that is, whether the first sub-image and the second sub-image are stamped by the same seal.
[0098] For example, if there are three seal images in the target file, any two images are obtained and determined as the first sub-image and the second sub-image, and then the third eigenvector v1 corresponding to the first sub-image and the fourth eigenvector v2 corresponding to the second sub-image are concatenated to obtain the fifth eigenvector [v1, v2]. Therefore, the final prediction result, if the probability that the two prediction results are the same is greater than the probability that the two are different, it indicates that the first sub-image and the second sub-image are the same seal; if the probability that the two prediction results are the same is less than or equal to the probability that the two are different, it indicates that the first sub-image and the second sub-image are different seals.
[0099] Specifically, by extracting two sub-images from the seal image and performing independent feature extraction on them, more accurate feature information can be obtained. This method can effectively capture the subtle differences and similarities between the sub-images, thereby improving the accuracy of matching. This not only helps to identify information with the same seal in the target file, but also provides a reliable basis for subsequent inspections to see if there is a mistake in the seal.
[0100] In some embodiments, after obtaining the matching result, the method further includes: when the matching result corresponding to the seal image is a matching failure, obtaining a mapping seal corresponding to the seal image from the preset seal; determining incremental training data based on the seal image and the mapping seal; and performing incremental training on the deep neural network model based on the incremental training data to obtain an updated deep neural network model.
[0101] For example, if the matching result is a match failure, it means that the seal image cannot find a suitable match in the preset seal. Then the seal image is manually determined to be the mapping seal that actually corresponds to the preset seal. Then, incremental training data is created based on the current seal image and its corresponding mapping seal. Incremental training data usually includes a pairing of a seal image and a mapping seal, which is used to supplement the training data of the model and help the model improve its recognition ability for similar seals.
[0102] Exemplarily, incremental training data is used to incrementally train the deep neural network model. The purpose of incremental training is to fine-tune the original model through the newly added data so that the model can better handle the newly added sample features. After incremental training, an updated deep neural network model is obtained. This model will have stronger recognition capabilities and can better handle seal images that could not be matched before.
[0103] Specifically, by using incremental training data to train the deep neural network model, the model's ability to recognize new or difficult-to-recognize seal images can be enhanced, thereby improving the overall accuracy of the model. Incremental training usually requires less computing and resources than retraining the entire model, so it can reduce training costs and improve training efficiency.
[0104] Please refer to Figure 3 , Figure 3 A schematic diagram of a scenario for implementing the seal matching method provided in this embodiment, as shown in FIG. Figure 3As shown, a target file is obtained, and a target color and a target edge shape are determined. The target file is screened according to the target color to obtain a first intermediate file. Edge recognition is performed on the target color in the first intermediate file to obtain an initial edge shape corresponding to the target color. The first intermediate file is further screened according to the initial edge shape and the target edge shape to obtain a second intermediate file. The second intermediate file is format converted to generate a corresponding initial image. Color analysis is performed on the initial image according to the target color to determine the corresponding target area in the initial image. The target shape corresponding to the target color is extracted from the target area, and the corresponding target image in the initial image is determined under the target pixel according to the target shape. The target image is processed using an edge detection algorithm to obtain a first edge image. Redundancy is removed from the first edge image using a non-maximum suppression algorithm to obtain a second edge image. Contour recognition is performed on the second edge image to obtain a target contour corresponding to the target seal. According to the target contour, the target position of the target seal is determined from the target image, and the seal image is extracted from the initial image according to the target position. The feature extraction layer of the deep neural network model is then used to extract features from the seal image to obtain a first feature vector corresponding to the seal image. Similarly, the feature extraction layer is used to extract features from the preset seal to obtain the second feature vector corresponding to the preset seal. The feature splicing layer of the deep neural network model is used to splice the first feature vector and the second feature vector to form a target feature vector. The feature prediction layer of the deep neural network model is used to match and predict the target feature vector to obtain the prediction result. Finally, the matching result of the target seal is determined based on the prediction result. Through these steps, the accuracy, efficiency and automation level of image processing and analysis can be significantly improved. The implementation of each step enhances the accuracy and efficiency of image processing. From format conversion, color analysis, edge detection, to seal extraction and matching, the entire process optimizes the image processing results, reduces manual intervention, and improves processing speed and reliability in various application scenarios.
[0105] See also Figure 4 , Figure 4A seal matching device 200 is provided for an embodiment of the present application. The seal matching device 200 includes an image acquisition module 201, an image analysis module 202, an edge monitoring module 203, a seal extraction module 204, and a seal matching module 205, wherein the image acquisition module 201 is used to obtain a target file and perform format conversion on the target file to obtain a corresponding initial image; the image analysis module 202 is used to perform color analysis on the initial image to obtain a target image corresponding to the initial image under target pixels; the edge monitoring module 203 is used to perform seal edge detection on the target image according to edge detection to obtain a target position corresponding to the target seal; the seal extraction module 204 is used to obtain a seal image corresponding to the target seal from the initial image according to the target position; and the seal matching module 205 is used to perform information matching between the seal image and a preset seal to obtain a matching result corresponding to the target seal.
[0106] In some implementations, the image acquisition module 201, during the process of converting the target file into a corresponding initial image, performs:
[0107] Determine the target color and target edge shape;
[0108] Screening the target file according to the target color to obtain a first intermediate file;
[0109] Performing edge recognition on the target color in the first intermediate file to obtain an initial edge shape corresponding to the target color;
[0110] Screening the first intermediate file according to the initial edge shape and the target edge shape to obtain a second intermediate file;
[0111] The second intermediate file is format converted to obtain the corresponding initial image.
[0112] In some implementations, the image analysis module 202 performs, during the process of performing color analysis on the initial image to obtain a target image corresponding to the initial image at a target pixel:
[0113] Performing color analysis on the initial image according to the target color to obtain a target area corresponding to the initial image;
[0114] A target shape corresponding to the target color in the target area is obtained, and the target image corresponding to the initial image at the target pixel is determined according to the target shape.
[0115] In some implementations, the edge monitoring module 203 performs, during the process of performing seal edge detection on the target image according to edge detection to obtain a target position corresponding to the target seal:
[0116] Detecting the edge of the target image using an edge detection algorithm to obtain a first edge image;
[0117] Using a non-maximum suppression algorithm to perform a redundancy removal operation on the first edge image to obtain a second edge image;
[0118] Performing contour recognition on the second edge image to obtain a target contour corresponding to the target seal;
[0119] The target position corresponding to the target seal is obtained from the target image according to the target contour.
[0120] In some implementations, the seal matching module 205 performs, during the process of matching the seal image with the preset seal to obtain the matching result corresponding to the target seal:
[0121] Using a feature extraction layer of a deep neural network model to extract image features from the seal image, obtaining a first feature vector corresponding to the seal image;
[0122] Using the feature extraction layer to extract image features of the preset seal to obtain a second feature vector corresponding to the preset seal;
[0123] Using the feature concatenation layer of the deep neural network model, concatenate the first feature vector and the second feature vector to obtain a target feature vector;
[0124] Using the feature prediction layer of the deep neural network model to perform matching prediction on the target feature vector to obtain a prediction result;
[0125] The matching result corresponding to the target seal is determined according to the prediction result.
[0126] In some implementations, the seal matching module 205 performs the following steps in the process of obtaining the deep neural network model:
[0127] Obtaining first training data, wherein the first training data includes a real seal and an associated seal corresponding to the real seal in the preset seal;
[0128] Performing data enhancement on the real seal to obtain an enhanced image, and then forming second training data according to the enhanced image and the associated seal;
[0129] Eliminate the associated seal from the preset seals to obtain irrelevant seals corresponding to the enhanced image;
[0130] The enhanced image and the irrelevant seal form the third training data;
[0131] Determine target training data according to the second training data and the third training data;
[0132] The deep neural network model is trained according to the target training data to obtain the deep neural network model.
[0133] In some implementations, the seal matching module 205 further performs:
[0134] Obtaining a first sub-image and a second sub-image from the seal image;
[0135] Using the feature extraction layer to extract image features from the first sub-image, obtaining a third feature vector corresponding to the first sub-image;
[0136] Using the feature extraction layer to extract image features from the second sub-image, obtaining a fourth feature vector corresponding to the second sub-image;
[0137] Using the feature concatenation layer to concatenate the third feature vector and the fourth feature vector to obtain a fifth feature vector;
[0138] The fifth feature vector is matched and predicted by using the feature prediction layer to obtain a correlation degree between the first sub-image and the second sub-image.
[0139] In some implementations, the seal matching apparatus 200 may be applied to a terminal device.
[0140] It should be noted that those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working process of the seal matching device 200 described above can refer to the corresponding process in the aforementioned seal matching method embodiment, and will not be repeated here.
[0141] See also Figure 5 , Figure 5 A schematic block diagram of the structure of a terminal device provided in an embodiment of the present invention.
[0142] like Figure 5 As shown, the terminal device 300 includes a processor 301 and a memory 302, and the processor 301 and the memory 302 are connected via a bus 303, such as an I2C (Inter-integrated Circuit) bus.
[0143] Specifically, the processor 301 is used to provide computing and control capabilities to support the operation of the entire terminal device. The processor 301 can be a central processing unit (CPU), and the processor 301 can also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc.
[0144] Specifically, the memory 302 may be a Flash chip, a read-only memory (ROM) disk, an optical disk, a USB flash drive, or a mobile hard disk.
[0145] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a partial structure related to the embodiment of the present invention, and does not constitute a limitation on the terminal device to which the embodiment of the present invention is applied. The specific server may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0146] The processor is used to run a computer program stored in the memory, and implement any one of the seal matching methods provided by the embodiments of the present invention when executing the computer program.
[0147] In one embodiment, the processor is used to run a computer program stored in the memory, and implements the following steps when executing the computer program:
[0148] Obtaining a target file, and performing format conversion on the target file to obtain a corresponding initial image;
[0149] Performing color analysis on the initial image to obtain a target image corresponding to the initial image at a target pixel;
[0150] Performing seal edge detection on the target image according to edge detection to obtain a target position corresponding to the target seal;
[0151] Obtaining a seal image corresponding to the target seal from the initial image according to the target position;
[0152] The seal image is matched with a preset seal to obtain a matching result corresponding to the target seal.
[0153] In some implementations, the processor 301, during the process of converting the format of the target file to obtain the corresponding initial image, executes:
[0154] Determine the target color and target edge shape;
[0155] Screening the target file according to the target color to obtain a first intermediate file;
[0156] Performing edge recognition on the target color in the first intermediate file to obtain an initial edge shape corresponding to the target color;
[0157] Screening the first intermediate file according to the initial edge shape and the target edge shape to obtain a second intermediate file;
[0158] The second intermediate file is format converted to obtain the corresponding initial image.
[0159] In some implementations, the processor 301, in the process of performing color analysis on the initial image to obtain a target image corresponding to the initial image at a target pixel, executes:
[0160] Performing color analysis on the initial image according to the target color to obtain a target area corresponding to the initial image;
[0161] A target shape corresponding to the target color in the target area is obtained, and the target image corresponding to the initial image at the target pixel is determined according to the target shape.
[0162] In some implementations, the processor 301, in the process of performing seal edge detection on the target image according to edge detection to obtain a target position corresponding to the target seal, executes:
[0163] Detecting the edge of the target image using an edge detection algorithm to obtain a first edge image;
[0164] Using a non-maximum suppression algorithm to perform a redundancy removal operation on the first edge image to obtain a second edge image;
[0165] Performing contour recognition on the second edge image to obtain a target contour corresponding to the target seal;
[0166] The target position corresponding to the target seal is obtained from the target image according to the target contour.
[0167] In some implementations, the processor 301 performs, during the process of matching the seal image with the preset seal to obtain the matching result corresponding to the target seal:
[0168] Using a feature extraction layer of a deep neural network model to extract image features from the seal image, obtaining a first feature vector corresponding to the seal image;
[0169] Using the feature extraction layer to extract image features of the preset seal to obtain a second feature vector corresponding to the preset seal;
[0170] Using the feature concatenation layer of the deep neural network model, concatenate the first feature vector and the second feature vector to obtain a target feature vector;
[0171] Using the feature prediction layer of the deep neural network model to perform matching prediction on the target feature vector to obtain a prediction result;
[0172] The matching result corresponding to the target seal is determined according to the prediction result.
[0173] In some implementations, the processor 301 executes, in the process of obtaining the deep neural network model:
[0174] Obtaining first training data, wherein the first training data includes a real seal and an associated seal corresponding to the real seal in the preset seal;
[0175] Performing data enhancement on the real seal to obtain an enhanced image, and then forming second training data according to the enhanced image and the associated seal;
[0176] Eliminate the associated seal from the preset seals to obtain irrelevant seals corresponding to the enhanced image;
[0177] The enhanced image and the irrelevant seal form the third training data;
[0178] Determine target training data according to the second training data and the third training data;
[0179] The deep neural network model is trained according to the target training data to obtain the deep neural network model.
[0180] In some implementations, the processor 301 further executes:
[0181] Obtaining a first sub-image and a second sub-image from the seal image;
[0182] Using the feature extraction layer to extract image features from the first sub-image, obtaining a third feature vector corresponding to the first sub-image;
[0183] Using the feature extraction layer to extract image features from the second sub-image, obtaining a fourth feature vector corresponding to the second sub-image;
[0184] Using the feature concatenation layer to concatenate the third feature vector and the fourth feature vector to obtain a fifth feature vector;
[0185] The fifth feature vector is matched and predicted by using the feature prediction layer to obtain a correlation degree between the first sub-image and the second sub-image.
[0186] It should be noted that those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the terminal device described above can refer to the corresponding process in the aforementioned seal matching method embodiment, and will not be repeated here.
[0187] An embodiment of the present invention also provides a storage medium for computer-readable storage, wherein the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of any seal matching method provided in the description of the embodiment of the present invention.
[0188] The storage medium may be an internal storage unit of the terminal device described in the foregoing embodiment, such as a hard disk or memory of the terminal device. The storage medium may also be an external storage device of the terminal device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc., equipped on the terminal device.
[0189] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In a hardware embodiment, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those of ordinary skill in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0190] It should be understood that the term "and / or" used in the present specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, including these combinations. It should be noted that, in this article, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. 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, method, article or system including the element.
[0191] The serial numbers of the embodiments of the present invention are only for description and do not represent the advantages and disadvantages of the embodiments. The above description is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A seal matching method, characterized in that: The method comprises: Obtaining a target file, and performing format conversion on the target file to obtain a corresponding initial image; Performing color analysis on the initial image to obtain a target image corresponding to the initial image at a target pixel; Performing seal edge detection on the target image according to edge detection to obtain a target position corresponding to the target seal; Obtaining a seal image corresponding to the target seal from the initial image according to the target position; The seal image is matched with a preset seal to obtain a matching result corresponding to the target seal.
2. The method according to claim 1, characterized in that The step of converting the target file into a corresponding initial image includes: Determine the target color and target edge shape; Screening the target file according to the target color to obtain a first intermediate file; Performing edge recognition on the target color in the first intermediate file to obtain an initial edge shape corresponding to the target color; Screening the first intermediate file according to the initial edge shape and the target edge shape to obtain a second intermediate file; The second intermediate file is format converted to obtain the corresponding initial image.
3. The method according to claim 2, characterized in that The performing color analysis on the initial image to obtain a target image corresponding to the initial image at a target pixel includes: Performing color analysis on the initial image according to the target color to obtain a target area corresponding to the initial image; A target shape corresponding to the target color in the target area is obtained, and the target image corresponding to the initial image at the target pixel is determined according to the target shape.
4. The method according to claim 1, characterized in that: The step of performing seal edge detection on the target image according to edge detection to obtain a target position corresponding to the target seal includes: Detecting the edge of the target image using an edge detection algorithm to obtain a first edge image; Using a non-maximum suppression algorithm to perform a redundancy removal operation on the first edge image to obtain a second edge image; Performing contour recognition on the second edge image to obtain a target contour corresponding to the target seal; The target position corresponding to the target seal is obtained from the target image according to the target contour.
5. The method according to claim 1, characterized in that The step of matching the seal image with a preset seal to obtain a matching result corresponding to the target seal includes: Using a feature extraction layer of a deep neural network model to extract image features from the seal image, obtaining a first feature vector corresponding to the seal image; Using the feature extraction layer to extract image features of the preset seal to obtain a second feature vector corresponding to the preset seal; Using the feature concatenation layer of the deep neural network model, concatenate the first feature vector and the second feature vector to obtain a target feature vector; Using the feature prediction layer of the deep neural network model to perform matching prediction on the target feature vector to obtain a prediction result; The matching result corresponding to the target seal is determined according to the prediction result.
6. The method according to claim 5, characterized in that Obtaining the deep neural network model includes: Obtaining first training data, wherein the first training data includes a real seal and an associated seal corresponding to the real seal in the preset seal; Performing data enhancement on the real seal to obtain an enhanced image, and then forming second training data according to the enhanced image and the associated seal; Eliminate the associated seal from the preset seals to obtain irrelevant seals corresponding to the enhanced image; The enhanced image and the irrelevant seal form the third training data; Determine target training data according to the second training data and the third training data; The deep neural network model is trained according to the target training data to obtain the deep neural network model.
7. The method according to claim 5, characterized in that The method further comprises: Obtaining a first sub-image and a second sub-image from the seal image; Using the feature extraction layer to extract image features from the first sub-image, obtaining a third feature vector corresponding to the first sub-image; Using the feature extraction layer to extract image features from the second sub-image, obtaining a fourth feature vector corresponding to the second sub-image; Using the feature concatenation layer to concatenate the third feature vector and the fourth feature vector to obtain a fifth feature vector; The fifth feature vector is matched and predicted by using the feature prediction layer to obtain a correlation degree between the first sub-image and the second sub-image.
8. A seal matching device, characterized in that: include: An image acquisition module is used to obtain a target file and perform format conversion on the target file to obtain a corresponding initial image; An image analysis module, used for performing color analysis on the initial image to obtain a target image corresponding to the initial image at a target pixel; An edge monitoring module is used to perform seal edge detection on the target image according to edge detection to obtain a target position corresponding to the target seal; A seal extraction module, used for obtaining a seal image corresponding to the target seal from the initial image according to the target position; The seal matching module is used to match the seal image with the preset seal to obtain the matching result corresponding to the target seal.
9. A terminal device, characterized in that: The terminal device includes a processor and a memory; The memory is used to store computer programs; The processor is configured to execute the computer program and implement the seal matching method according to any one of claims 1 to 7 when executing the computer program.
10. A computer storage medium for computer storage, characterized in that: The computer storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the seal matching method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Seal detecting method and system
CN103440671A
Seal identification method and device and storage medium
CN115810196A
Seal image authenticity identification method and device based on deep learning
CN117765561A
Jelly roll type electrode assembly and method of manufacturing the same
KR1020230014076A
