Seal recognition methods, systems, devices, and storage media based on generative seal recognition models.
By employing a preprocessing, detection, and recognition process based on a generative seal recognition model, the problems of low efficiency and low accuracy in seal recognition in existing technologies are solved, achieving efficient and accurate seal information recognition.
Patent Information
- Application Number
- CN202510270429.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-07
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2045-03-07
AI Technical Summary
Existing seal recognition technologies are inefficient and have low accuracy, making it difficult to meet the needs of modern applications.
A generative seal recognition model is adopted. The seal image to be recognized is preprocessed, the initial seal information is detected by a trained seal detection model, and the target seal image is segmented and recognized based on the generative seal recognition model. The end-to-end seal information recognition is achieved by combining the input layer, encoding layer and output layer of the generative seal recognition model.
It improves the efficiency and accuracy of seal recognition, simplifies the process, reduces computational overhead, avoids error propagation, and enhances the robustness and accuracy of the system.
Smart Images

Figure CN120163970B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method, system, device and storage medium for seal recognition based on a generative seal recognition model. Background Technology
[0002] Driven by the wave of informatization and intelligentization, the demand for seal recognition technology in scenarios such as electronic signing, contract management, and financial reimbursement is increasing daily. With the continuous advancement of computer information technology, seal recognition technology has gone through several stages of development, each of which has achieved certain technological breakthroughs, but it also faces many problems and shortcomings.
[0003] In related technologies, the traditional manual seal verification stage relies entirely on manual verification in the initial stage of seal recognition, comparing the seal's appearance, position, and content with the naked eye. While simple and intuitive, this method suffers from significant efficiency and accuracy issues. Manual verification is time-consuming, inefficient, and highly susceptible to subjective human factors, leading to frequent omissions or misjudgments. Furthermore, manual processing struggles to handle the verification needs of large volumes of seals, and its lack of scalability limits its application in modern scenarios. Traditional seal recognition technology remains entirely dependent on human experience and intuition, failing to meet the demands of complex business scenarios.
[0004] In the related technologies, the computer-aided recognition stage: With the development of computer image processing technology, seal recognition began to incorporate basic image processing methods such as edge detection and template matching. This stage involves acquiring images using scanning devices and completing simple recognition tasks with the help of computer algorithms, greatly reducing labor costs. However, computer-aided recognition technology still has many limitations. First, it is highly dependent on image quality (such as lighting and sharpness), and performs poorly when dealing with complex backgrounds, partially occluded or deformed seals. Second, different seal types require different matching rules, resulting in poor adaptability. Finally, this technology still requires manual verification of the recognition results, leading to low recognition efficiency and low accuracy.
[0005] Currently, the efficiency and accuracy of traditional seal recognition methods cannot meet the needs of modern applications. Summary of the Invention
[0006] This invention provides a seal recognition method, system, device, and storage medium based on a generative seal recognition model, which addresses the shortcomings of low efficiency and low accuracy in seal recognition in existing technologies. It enables the recognition of seal images and determination of target seal information by using a generative seal recognition model, thereby improving both the efficiency and accuracy of seal recognition.
[0007] In a first aspect, the present invention provides a seal recognition method based on a generative seal recognition model, comprising the following steps:
[0008] Acquire an image of the seal to be identified, and preprocess the image of the seal to be identified to obtain a preprocessed image;
[0009] The preprocessed image is detected based on the trained seal detection model to identify the initial seal information in the preprocessed image.
[0010] Based on the initial seal information, the target seal image is cut out from the seal image to be identified;
[0011] The target seal image is processed based on a trained generative seal recognition model to identify the target seal information in the target seal image.
[0012] Preferably, according to the seal recognition method based on a generative seal recognition model provided by the present invention, after the step of recognizing the target seal information in the target seal image based on the trained generative seal recognition model, the method includes:
[0013] The target seal information and the seal information to be identified in the seal image to be identified are compared.
[0014] If the target seal information and the seal information to be identified are different, the target seal information is corrected to obtain the correct target seal information.
[0015] If the target seal information and the seal information to be identified are the same, the target seal information is determined as the seal recognition result of a preset document; the preset document is a document that includes the image of the seal to be identified.
[0016] Preferably, in the seal recognition method based on a generative seal recognition model provided by the present invention, the initial seal information includes at least seal category information and seal coordinate information;
[0017] The preprocessed image is detected using a trained seal detection model to identify initial seal information, including:
[0018] Based on the seal detection model and the image information of the preprocessed image, features of the preprocessed image are extracted to determine different seal features; wherein, the image information includes at least: color information and scale information, and the different seal features include at least: seal features of different colors and seal features of different scales;
[0019] Based on a preset feature fusion strategy, the features of seals of different colors and seals of different scales are fused to determine the seal category information and the seal coordinate information.
[0020] Preferably, according to the seal recognition method based on a generative seal recognition model provided by the present invention, the step of cutting out the target seal image from the seal image to be recognized based on the initial seal information includes:
[0021] Based on the seal category information and the seal coordinate information, the target seal area is cropped from the seal image to be identified;
[0022] The target seal area is subjected to perspective transformation processing to determine the target seal image.
[0023] Preferably, according to the seal recognition method based on a generative seal recognition model provided by the present invention, the recognition of the generative seal recognition model includes at least: an input layer, an encoding layer, and an output layer;
[0024] The process of recognizing the target seal image based on the trained generative seal recognition model, and identifying the target seal information in the target seal image, includes:
[0025] The input layer generates seal input data for recognition learning by sequentially performing image segmentation, embedding mapping, and position encoding on the target seal image.
[0026] The encoding layer encodes the stamp input data from the input layer using a generative encoder to generate global feature information.
[0027] The output layer maps the global feature information generated by the encoding layer to the natural language output space through a generative decoder. It extracts context information from the global feature information mapped to the natural language output space through a multi-head self-attention mechanism and a cross-attention mechanism. The context information is then mapped to a stamp output sequence through a fully connected layer and a softmax activation function, and the stamp output sequence is used as the target stamp information.
[0028] Preferably, in the seal recognition method based on a generative seal recognition model provided by the present invention, the target seal information includes at least: a first name information located in a first position, a second name information located in a second position, and a registration number information located in a third position.
[0029] Secondly, the present invention also provides a seal recognition system based on a generative seal recognition model, comprising the following modules:
[0030] The preprocessing module is used to acquire the image of the seal to be identified and to preprocess the image of the seal to be identified to obtain a preprocessed image.
[0031] The detection module is used to detect the preprocessed image based on the trained seal detection model, and to detect the initial seal information in the preprocessed image.
[0032] The cutting module is used to cut out the target seal image from the seal image to be identified based on the initial seal information;
[0033] The recognition module is used to perform recognition processing on the target seal image based on a trained generative seal recognition model, and to identify the target seal information in the target seal image.
[0034] Thirdly, the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the seal recognition method based on the generative seal recognition model as described above.
[0035] Fourthly, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the seal recognition method based on the generative seal recognition model as described above.
[0036] Fifthly, the present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the seal recognition method based on the generative seal recognition model as described above.
[0037] This invention provides a seal recognition method, system, device, and storage medium based on a generative seal recognition model. The method involves acquiring a seal image to be recognized and preprocessing it to obtain a preprocessed image. A trained seal detection model is then used to detect initial seal information within the preprocessed image. Based on this initial seal information, a target seal image is extracted from the seal image to be recognized. Finally, the trained generative seal recognition model is used to recognize the target seal image, identifying the target seal information within it. This addresses the shortcomings of low efficiency and accuracy in existing seal recognition technologies by enabling the identification of seal images and the determination of target seal information using a generative seal recognition model. This not only improves the efficiency of seal recognition but also significantly enhances its accuracy. Attached Figure Description
[0038] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0039] Figure 1 This is one of the flowcharts of the seal recognition method based on the generative seal recognition model provided by the present invention.
[0040] Figure 2 This is a schematic diagram of the structure of the seal recognition system based on the generative seal recognition model provided by the present invention.
[0041] Figure 3 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0042] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0043] First, let's analyze some of the terms used in this invention:
[0044] The Transformer's self-attention mechanism is a core component of the Transformer model. It allows the model to comprehensively capture the dependencies between different positions in a sequence when processing sequential data. This mechanism enables the model to not only focus on information at the current position when processing sequences (such as words in a sentence), but also adjust its attention to that position based on information from other positions in the sequence. This capability allows the model to better understand the contextual information of the sequence, thus more accurately capturing semantic and logical relationships.
[0045] The softmax activation function is a commonly used activation function in machine learning and deep learning. In natural language processing (NLP), language models typically use the softmax function to predict the probability distribution of the next word or character.
[0046] In the relevant technologies, at least the following technical problems still exist:
[0047] In related technologies, the semi-automatic recognition stage based on machine learning: After entering the machine learning stage, seal recognition technology begins to rely on feature extraction algorithms (such as SIFT and HOG) and classifiers (such as SVM and random forest) to achieve a certain degree of automation. By training a classification model, the features of the seal can be quantified and used for recognition and classification. However, the technological development at this stage is still limited by the limitations of feature extraction and model capabilities. Traditional machine learning algorithms rely on manually designed features and are not adaptable enough to situations such as seal rotation, scaling, and noise interference. In addition, model training and optimization require a large amount of labeled data, which further increases the cost and difficulty of technology implementation.
[0048] In further related technologies, the two-stage intelligent recognition stage based on deep learning has emerged: With the rapid development of deep learning and computer vision technologies, seal recognition technology has entered the two-stage intelligent recognition stage. Through technologies such as convolutional neural networks (CNNs) and optical character recognition (OCR), features can be automatically extracted from images to complete the recognition task. The technological advantages of this stage are that it eliminates the need for manually designed features, significantly improves recognition accuracy, and can adapt to complex backgrounds and diverse scenarios. However, current two-stage intelligent recognition technology still faces several challenges. For example, deep learning models are heavily reliant on high-performance computing resources, resulting in high deployment and application costs; OCR relies on complex preprocessing and post-processing workflows, which significantly increases the computational cost of the entire system, especially when processing large-scale seal images, where performance bottlenecks are particularly pronounced; OCR has limited adaptability to language and seal types; model training depends on a large amount of labeled data, while obtaining high-quality data is difficult; errors in any recognition stage of a two-stage model are amplified in subsequent processes, and because OCR requires extracting text content character by character and line by line, errors in any recognition stage are amplified in subsequent processes, leading to a decrease in the robustness and accuracy of the overall system; in addition, the model's generalization ability when handling new, unseen seal types still needs improvement.
[0049] Therefore, current technologies for seal recognition suffer from low accuracy and low efficiency. Improving both the accuracy and efficiency of seal recognition is a pressing technical problem that needs to be addressed.
[0050] The following is combined with Figures 1-3 This invention describes a seal recognition method, system, device, and storage medium based on a generative seal recognition model, which addresses the shortcomings of low efficiency and low accuracy in seal recognition in the prior art. By recognizing seal images and determining target seal information based on a generative seal recognition model, this invention not only improves the efficiency of seal recognition but also greatly enhances its accuracy.
[0051] Figure 1This is one of the flowcharts illustrating a seal recognition method based on a generative seal recognition model provided by the present invention, such as... Figure 1 As shown, the method may include, but is not limited to, steps S100 to S400:
[0052] S100: Acquire the image of the seal to be identified, and preprocess the image of the seal to be identified to obtain a preprocessed image;
[0053] S200, The preprocessed image is detected based on the trained seal detection model to detect the initial seal information in the preprocessed image;
[0054] S300, based on the initial seal information, cut out the target seal image from the seal image to be identified;
[0055] S400, the target seal image is processed based on the trained generative seal recognition model to identify the target seal information in the target seal image.
[0056] In step S100 of some embodiments, an image of the seal to be identified is acquired, and the image of the seal to be identified is preprocessed to obtain a preprocessed image.
[0057] It should be noted that image acquisition terminals such as document scanners or cameras are used to acquire images or pictures of seal materials, documents, etc., containing images of the seal to be identified.
[0058] In embodiments of the present invention, the image acquisition terminal is used to acquire image information of documents such as text documents, image documents, and table documents.
[0059] The collected documents must include, but are not limited to, a seal image; no specific limitation is made here.
[0060] It should be noted that the image of the seal to be identified is annotated to facilitate recognition processing using a generative seal recognition model. Specific annotation methods may include, but are not limited to, enhancing color depth and adding anchor frames.
[0061] It should be noted that preprocessing includes, but is not limited to, processing the image of the seal to be identified by increasing or decreasing the color depth, rotating, translating, scaling, and normalizing.
[0062] The steps for preprocessing the image of the seal to be recognized to obtain a preprocessed image may include, but are not limited to, the following specific steps:
[0063] The color depth of the image of the seal to be identified is increased or decreased. Specifically, this involves enhancing and preserving color information beneficial to seal detection and recognition, while suppressing color information that negatively impacts seal detection. For example, if the seal to be identified is red, the non-red channels in the original image or the image itself are suppressed to a certain extent, thus highlighting the color information related to the red seal. This can improve the accuracy and efficiency of seal image recognition and detection.
[0064] Furthermore, preprocessing also includes further data processing such as rotation, translation, scaling, and normalization on the seal image to be identified after color information processing, so as to make the seal image easier to detect, thereby improving the detection efficiency of the seal image and reducing the detection cost of the seal detection model.
[0065] Rotating the image of the seal to be identified is to ensure that the image is consistent at a specific angle, facilitating subsequent matching and identification. Since the seal may be tilted due to different placement angles when the image is acquired, rotation corrects the image to a standard orientation.
[0066] Rotation processing can specifically involve detecting lines based on the Hough transform: The Hough transform is used to detect lines in the image, typically using the edges of a stamp or certain feature lines as reference lines. Based on the angle of the detected line, the required rotation angle of the image is calculated, and then an image rotation function (such as cv2.rotate in OpenCV) is used to rotate the image.
[0067] Template matching-based: If there is a known standard stamp template, the best matching angle between the image and the template can be found through the template matching algorithm, and then the image can be rotated according to that angle.
[0068] The purpose of translating the rotated image of the seal to be identified is to ensure that key features in the seal image are in fixed positions, reducing recognition errors caused by image position shifts. For example, the center of the seal can be translated to the center of the image, or a specific feature point can be translated to a designated position.
[0069] The specific implementation steps include, but are not limited to: calculating the translation amount: based on the features of the seal image and the target position, calculating the required horizontal and vertical distances for translation. The translation amount can be determined by detecting the center position, edge position, or other significant features of the seal.
[0070] Apply translation transformations: Use image translation functions (such as cv2.warpAffine or cv2.warpPerspective in OpenCV, when perspective transformations are involved) to perform translation operations on the image.
[0071] Scaling the translated image of the seal to be identified is to adjust it to a uniform size for easier subsequent processing and recognition. Seal images obtained from different acquisition devices or under different acquisition conditions may be of inconsistent sizes; scaling ensures that all images have the same dimensions.
[0072] The specific implementation steps include, but are not limited to: determining the scaling ratio: calculating the scaling ratio based on the target size and the original image size. The scaling ratio can be a constant scaling ratio (keeping the aspect ratio of the image unchanged) or a non-consistent scaling ratio (adjusted according to specific needs).
[0073] Apply scaling transformations: Use image scaling functions (such as cv2.resize in OpenCV) to scale the image.
[0074] Normalizing the scaled image of the seal to be identified is to map the pixel values of the seal image to a specific range (usually [0, 1] or [0, 255]) to improve the contrast and distinguishability of the image, while eliminating the influence of factors such as uneven lighting.
[0075] The specific implementation steps include, but are not limited to: linear normalization: for grayscale images, pixel values can be mapped to a target range through linear transformation. For example, the pixel value range [min_val, max_val] of the original image can be mapped to [0, 255].
[0076] Histogram equalization: This is a more complex normalization method that improves image contrast by adjusting the image's histogram to make the pixel distribution more uniform. It can be implemented using the `cv2.equalizeHist` function in OpenCV.
[0077] In step S200 of some embodiments, the preprocessed image is detected based on the trained seal detection model to detect the initial seal information in the preprocessed image.
[0078] It should be noted that the stamp detection model is a neural network built on the HasngDetNet (HDN) detection model, which is a modification of YOLOv8-s (YOLOv8-s is one of the YOLO series of object detection algorithms). Since the stamp detection task is relatively simple, the size of the target category is relatively uniform, and the proportion in the original image is small, the original YOLOv8-s model architecture is modified. Specifically, the number of output layers is reduced. Based on its original three output layers C3, C4, and C5, the detection model is changed to an HDN detection model with two output layers C2 and C3.
[0079] The YOLO model is a single-stage detection model, designed to differentiate it from two-stage detection models like SSD or Fast-CNN. Its purpose is to determine the seal category and coordinates from preprocessed images.
[0080] The input to the seal detection model is a preprocessed image, and the output is the initial seal information in the preprocessed image.
[0081] Initial seal information should include at least seal category information and seal coordinate information.
[0082] Seal category information indicates the category of the target seal image. Seal category information is descriptive data used to classify and identify seals, clearly indicating the specific category or type to which the seal belongs. For example, government departments may have different categories of seals such as "official seal," "financial seal," and "legal representative seal"; companies may have "contract seal," "invoice seal," and "department seal," etc. This information helps systems or personnel accurately identify the type of seal, avoiding confusion and misjudgment. When verifying seals, matching the seal category information can quickly determine the seal's legitimacy and purpose.
[0083] Seal coordinate information refers to the coordinate data used to determine the position of a seal within a specific document or image. It is typically represented in two-dimensional plane coordinates, such as (x, y), where x represents the horizontal coordinate and y represents the vertical coordinate. When verifying the authenticity of a seal, coordinate information can serve as one of the reference points to help determine whether the seal has been tampered with or moved.
[0084] The step of detecting the initial seal information in the preprocessed image based on the trained seal detection model specifically includes:
[0085] Based on the seal detection model and the image information of the preprocessed image, features of the preprocessed image are extracted to determine different seal features; wherein, the image information includes at least: color information and scale information, and the different seal features include at least: seal features of different colors and seal features of different scales.
[0086] Based on a preset feature fusion strategy, the features of seals of different colors and seals of different scales are fused to determine the seal category information and the seal coordinate information.
[0087] Specifically, a step-by-step feature map extraction process from shallow to deep can be used to gradually extract feature maps of different colors and different scales of seals, which correspond to the features of targets of different sizes in the original image.
[0088] Furthermore, two different scale feature fusion methods, bottom-up and top-down, are used to make fuller use of the information of feature maps at different scales, thereby enhancing the seal detection model's ability to detect texture details in the seal boundary region and thus enabling more accurate seal detection.
[0089] Furthermore, the seal detection model uses anchor frames of different scales to cover seals of different scales, thereby addressing the deformation of seal images of different scales or those of a certain scale due to the influence of shooting angle or shooting technique.
[0090] After training with a large amount of seal image data, the model can accurately identify the contours, text, patterns, and other features of seal images. For example, a well-trained seal detection model can accurately detect the presence of seals under various background disturbances.
[0091] The preprocessed image is input into the selected stamp detection model. The stamp detection model performs a comprehensive analysis of the preprocessed image and outputs the regions that may contain stamps, i.e., the target stamp regions. This process is similar to the initial localization of stamps in the image, providing a foundation for subsequent precise feature extraction.
[0092] Specifically, this can also involve using color scale information to assist in feature extraction:
[0093] Color Space Conversion and Analysis: Color space conversion is performed on preprocessed images, commonly from RGB to HSV or YCrCb color spaces. Different color spaces can better highlight the color characteristics of the seal. For example, in the HSV color space, the hue, saturation, and brightness of the seal color can be analyzed more intuitively, thus more accurately distinguishing the seal color from the background color.
[0094] Color and scale feature extraction: Based on color and scale information, extract the color and scale features of the seal, i.e., the features of seals of different colors and seals of different scales. This includes calculating statistical information such as the mean, variance, and color histogram of colors within the seal area. For example, by calculating the mean and variance of colors within the seal area, we can understand the overall distribution of seal colors and determine its uniformity or variability.
[0095] Combining color and shape features: In addition to color features, the shape features of the seal also need to be considered. Seals are typically circular, square, or other regular geometric shapes. The shape features of the seal can be determined by analyzing the edge contours of the image or using shape recognition algorithms. Combining color and shape features allows for a more comprehensive description of the seal's characteristics.
[0096] Determining the characteristics of seals at different colors and scales involves multi-scale analysis methods: Multi-scale analysis is used to process images to accommodate seals of varying sizes and colors. For example, methods such as Gaussian pyramids or Laplacian pyramids are used to decompose the image at different scales. At each scale, the color and shape features of the seal are extracted separately. This yields a series of seal features at different color scales, providing a more comprehensive reflection of the seal's characteristics.
[0097] Feature Description and Representation: For each color scale of the seal features, an appropriate feature description method is used. Features can be described using vectors or matrices for subsequent processing and analysis. For example, the color features of the seal can be represented as a color vector, including the three components of the color (such as RGB values); the shape features can be represented as a shape parameter vector, including information such as the shape's dimensions and aspect ratio.
[0098] The determination of seal category information and coordinate information based on a preset feature fusion strategy specifically includes the following steps:
[0099] In some embodiments of the present invention, the preset feature fusion strategy includes, but is not limited to:
[0100] Weighted fusion strategy: Different weights are assigned to different seal features based on their importance or reliability. For example, seals with obvious and stable color features are given higher weights for color features; seals with regular shapes and clear edges are given higher weights for shape features. Then, seal features at different color scales are fused using a weighted summation method.
[0101] Layered fusion strategy: Seal features are fused at different levels. First, within each color of the seal features, the features of different colors are initially fused to obtain the comprehensive features at that scale. Then, further fusion is performed between different feature scales, comprehensively considering information from multiple feature scales. For example, the color and shape features of the seal are first fused at a small scale to obtain the comprehensive features at that small scale; then the same operation is performed at a large scale; finally, the comprehensive features at different scales are fused to obtain the final seal features.
[0102] Feature selection and combination strategy: Based on the characteristics of the seal and specific application requirements, the most representative and distinctive features are selected for fusion. Feature selection algorithms or human experience can be used to determine which features are most critical for determining the seal category and coordinates. For example, for seals with specific patterns or text, features related to the patterns or text are selected for focused fusion.
[0103] The specific steps for determining seal category information include:
[0104] Category matching and classification algorithms: The fused seal features are matched against predefined seal category templates. Similarity metrics such as Euclidean distance and cosine similarity can be used to calculate the similarity between the fused features and each category template. Then, the seal category is determined based on the magnitude of the similarity. Alternatively, classification algorithms such as Support Vector Machines (SVM) and decision trees can be used to classify the fused features and obtain the seal category information.
[0105] Category Validation and Adjustment: To improve the accuracy of category determination, category validation and adjustment can be performed. For example, a threshold can be set; only when the similarity between the fused features and a certain category template exceeds the threshold is the stamp determined to belong to that category; otherwise, further analysis and judgment or readjustment of the feature fusion strategy is performed.
[0106] The specific steps for determining the coordinate information of the seal include:
[0107] Coordinate calculation based on feature location: The coordinates of the seal are calculated based on the positional information in the fused seal features. If the center position or key feature point positions of the seal are known, the seal coordinates can be determined directly based on this positional information and the pixel coordinate system of the image. For example, the geometric center of the seal image can be found and used as the seal's coordinate position.
[0108] Coordinate Correction and Optimization: Considering the influence of image distortion, noise, and other factors, it may be necessary to correct and optimize the calculated coordinates. Image registration algorithms or geometric transformation methods can be used to align the seal coordinates in the image with the actual physical coordinates or standard coordinate system. Simultaneously, by incorporating information such as the seal's size and angle, the coordinates can be further adjusted and optimized to improve the accuracy of the coordinate information.
[0109] Among them, the image registration algorithm can be a registration method based on grayscale information. Its principle is: using the grayscale information of the image, the displacement and rotation parameters between images are found through methods such as cross-correlation function to achieve image registration.
[0110] The specific steps are as follows: Select local regions (regions containing clear features) of the seal image and the reference image, and calculate their grayscale information. Then, use the cross-correlation function to calculate the similarity measure between the two images, and determine the displacement and rotation parameters between the images by finding the maximum similarity measure value. Finally, transform and correct the coordinates of the seal image based on the obtained parameters.
[0111] Furthermore, geometric transformation methods can be used to correct perspective distortion, a non-linear transformation that simulates the perspective effect observed by the human eye. In seal images, if perspective distortion exists (such as objects appearing larger when closer and smaller when farther away), it can be corrected through perspective transformation.
[0112] The specific steps can be as follows: Determine the parameters of the perspective transformation (such as vanishing point, projection center, etc.). The perspective transformation matrix can be solved using known control points. Then, apply the perspective transformation matrix to the coordinates of the seal image to achieve coordinate correction.
[0113] In step S300 of some embodiments, the target seal image is cut out from the seal image to be identified based on the initial seal information.
[0114] After completing step S200, the specific execution steps can be as follows: based on the seal category information and the seal coordinate information, crop out the target seal area from the seal image to be identified;
[0115] The target seal area is subjected to perspective transformation processing to determine the target seal image.
[0116] In some embodiments, the specific steps for cropping the target seal region from the seal image to be identified based on the seal category information and the seal coordinate information are as follows:
[0117] Specifically, the cropping area is first determined based on the stamp's coordinate information. Then, the cropping boundaries are defined according to the previously determined stamp coordinate information. The coordinate information typically includes the stamp's starting position (x1, y1) and ending position (x2, y2) in the image. These coordinates define a rectangular area that completely encloses the stamp. For example, if the stamp coordinate information shows that the top-left corner of the stamp is at (100, 150) and the bottom-right corner is at (200, 250), then the cropping area is this rectangular area with (100, 150) as the top-left corner and (200, 250) as the bottom-right corner.
[0118] In some embodiments, an error range is considered: to ensure complete cropping, a certain error range may be considered based on the coordinates. For example, the actual cropping area may be expanded by 2-5 pixels to prevent the edges of the stamped portion from being missed due to minor coordinate deviations.
[0119] The steps to perform the cropping operation are as follows:
[0120] Using image processing library functions: Utilize specialized image processing libraries, such as OpenCV (the cv2 module is commonly used in Python), to crop the target stamp region from the original image of the stamp to be identified by specifying the coordinate parameters of the cropping area. For example, in Python, the cv2.rectangle() function can be used to draw the cropping region based on coordinate information, and then functions such as cv2.bitwise_and() can be used to perform the cropping operation, extracting the image region containing only the stamp.
[0121] Generate the target seal area image: After cropping, a new image containing only the target seal is obtained. This image is the object to be processed by perspective transformation.
[0122] In some embodiments, the step of performing perspective transformation processing on the target seal area to determine the target seal image specifically includes:
[0123] First, determine the perspective transformation parameters, specifically:
[0124] Finding reference points: Within the target stamp area, determine reference points for perspective transformation. Typically, four vertices or specific points on the edges of the stamp are chosen as references. For example, for a rectangular stamp, its top-left, top-right, bottom-left, and bottom-right vertices can be selected as reference points.
[0125] Establishing the mapping relationship: Based on the original position of the reference point in the image and the expected position after transformation, establish the perspective transformation mapping relationship. This mapping relationship can be represented by a 3x3 transformation matrix. For example, if the coordinates of the top-left reference point in the original image are (x1, y1), the expected coordinates after transformation are (x1', y1'). The same applies to other reference points. The elements of the transformation matrix can be calculated through these correspondences.
[0126] Secondly, perform a perspective transformation, specifically:
[0127] Apply the transformation matrix: Use the perspective transformation function in the image processing library to apply the calculated transformation matrix to the target stamp area image.
[0128] In OpenCV, this can be achieved using the `cv2.warpPerspective()` function. This function resamples and interpolates the image based on the transformation matrix, transforming the stamp image according to a predetermined perspective.
[0129] Generating the target seal image: After perspective transformation, the final target seal image is obtained. This image may be a front view, which is more in line with human visual habits or meets specific system processing requirements. It has also removed the perspective distortion of the original image, and can more accurately display the details and content of the seal.
[0130] In step S400 of some embodiments, the target seal image is processed based on a trained generative seal recognition model to identify the target seal information in the target seal image.
[0131] This invention abandons the traditional pipeline-style OCR processing method and directly generates structured information from the target seal image through an end-to-end model architecture (generative seal recognition model). This step not only simplifies the process but also significantly improves processing efficiency.
[0132] Generative stamp recognition model (HGSRN model) adopts a Transformer-based architecture, which is widely used in natural language processing and computer vision due to its powerful feature extraction and sequence modeling capabilities.
[0133] In the task of seal recognition, the generative seal recognition model (HGSRN model) directly processes the pixel-level information of the image and uses the self-attention mechanism of the Transformer to capture the features in the seal image.
[0134] This enables generative seal recognition models (HGSRN models) to extract rich and comprehensive information from seal images without going through the intermediate step of OCR.
[0135] Compared to traditional OCR technology, the Generative Seal Recognition Model (HGSRN model) exhibits several advantages. Firstly, in terms of processing efficiency, the HGSRN model significantly reduces computational overhead through end-to-end processing, avoiding the cumbersome character-level operations of OCR and enabling rapid result generation. Secondly, regarding accuracy, by omitting the OCR stage, the HGSRN model avoids the progressive propagation of errors, directly interpreting the original image. This results in more stable and robust overall model performance, and a substantial improvement in processing speed.
[0136] In some embodiments of the present invention, the recognition of the generative seal recognition model includes at least: an input layer, an encoding layer, and an output layer;
[0137] The process of recognizing the target seal image based on the trained generative seal recognition model, and identifying the target seal information in the target seal image, specifically includes:
[0138] The input layer generates seal input data for recognition learning by sequentially performing image segmentation, embedding mapping, and position encoding on the target seal image.
[0139] The encoding layer encodes the stamp input data from the input layer using a generative encoder to generate global feature information.
[0140] The output layer maps the global feature information generated by the encoding layer to the natural language output space through a generative decoder. It extracts context information from the global feature information mapped to the natural language output space through a multi-head self-attention mechanism and a cross-attention mechanism. The context information is then mapped to a stamp output sequence through a fully connected layer and a softmax activation function, and the stamp output sequence is used as the target stamp information.
[0141] In some embodiments of the present invention, the generative seal recognition model (HasngGenSealRecNet, HGSRN) is used to recognize the seal text content in a seal image. The generative seal recognition model specifically includes an input layer, an encoding layer, and an output layer, and can realize end-to-end processing from seal image to natural language output.
[0142] The input layer is responsible for preprocessing the stamp image, generating input data suitable for Transformer learning through image segmentation, embedding mapping, and positional encoding.
[0143] Specifically, the seal image is first segmented into multiple fixed-size image blocks, and then the image blocks are embedded into a low-dimensional feature space through linear transformation and added to a trainable position embedding matrix, thereby preserving the spatial information of the seal layout.
[0144] The encoding layer is based on the Vision Transformer (ViT) architecture and includes a multi-head self-attention mechanism, residual connections, a feedforward neural network, and a regularization module. The multi-head self-attention mechanism captures global feature information of the stamp image by calculating the correlation weights between input image patches, and enhances feature representation capabilities by utilizing residual connections and the feedforward network. Layer normalization operations are used to stabilize model training and improve its generalization ability.
[0145] The output layer employs a generative decoder, which maps the global feature representations generated by the encoding layer to the natural language output space through a Transformer decoder. The decoder extracts contextual information from the global features using a multi-head self-attention mechanism combined with a cross-attention mechanism, and maps the features to the output sequence through a fully connected layer and a softmax activation function.
[0146] The output layer further supports multi-task adaptation, enabling tasks such as classification, information extraction, and sequence generation to be handled under a unified architecture.
[0147] In some embodiments of the present invention, the input layer specifically includes at least: image segmentation, embedding mapping, and positional encoding processing.
[0148] The purpose of image segmentation is to divide a target seal image into different regions so that the various parts of the seal can be better processed and analyzed. For example, for a seal containing text and patterns, image segmentation can separate the text and patterns, providing more accurate regions for subsequent feature extraction.
[0149] Image segmentation methods include thresholding and edge detection. For example, a pixel brightness thresholding method can be used to divide pixels with similar colors or grayscale values in a stamp image into regions, thereby distinguishing different parts.
[0150] The purpose of embedding mapping is to map the segmented stamp image regions to a high-dimensional vector space, making them easier for computers to understand and process. Each pixel or small region is transformed into a vector with higher-dimensional features, which can capture various information such as color and texture of the image.
[0151] Embedding mapping methods can be implemented using convolutional layers in convolutional neural networks (CNNs). For example, multiple convolutional kernels are slid across the image to perform convolution operations, extracting local features, and then these local features are combined to form an embedding vector.
[0152] The purpose of positional encoding is to add positional information to the stamp input data, enabling the model to distinguish features at different locations. Position within the stamp image is crucial for recognition; for example, the relative positions of the stamp's edge contours and internal patterns.
[0153] Positional encoding methods: Positional encoding can be performed using a combination of sine and cosine functions. For example, for one-dimensional positional encoding, based on the position index i, the encoded value for each position is calculated using the formulas PE(i)=sin(i / 10000^(0:d / 50)') and PE(i)=cos(i / 10000^(0:d / 50)'), where d is the embedding dimension. In this way, each position is assigned a unique encoded vector.
[0154] In some embodiments of the present invention, specifically, the coding layer includes at least a generative encoder and the generation of global feature information.
[0155] The role of a generative encoder is to further encode the stamp input data from the input layer and extract global feature information. It can transform low-level image features (such as edges and textures) into higher-level, more representative semantic features.
[0156] The structure of generative encoders typically employs a multi-layered neural network architecture, such as the Transformer encoder. It consists of multiple identical encoder layers stacked on top of each other, each containing a self-attention mechanism and a feedforward neural network. The self-attention mechanism allows the model to consider the influence of features from other locations when processing features at the current location, thus better capturing global information. The feedforward neural network is used to perform a non-linear transformation on the output of the self-attention mechanism, enhancing the model's expressive power.
[0157] The process of generating global feature information involves a generative encoder processing the input data to obtain global feature information that represents the entire seal image. For example, when processing a seal containing a company name and logo, the encoder considers information such as the shape of the characters, the stroke order, and the pattern of the logo to generate a fixed-dimensional vector representing the global features of the seal. This vector contains key information about the seal, such as company identity and seal type, providing crucial information for subsequent recognition.
[0158] In some embodiments of the present invention, the output layer includes at least the steps of: a generative decoder, context information extraction, and a fully connected layer and a softmax activation function, specifically:
[0159] The role of the generative decoder is to map the global feature information generated by the encoding layer to the natural language output space. This allows the semantic information of the seal to be expressed in natural language, making it easier for people to understand the meaning represented by the seal.
[0160] The structure of a generative decoder can also adopt a Transformer-based decoder structure. It consists of multiple decoder layers, each including a self-attention mechanism, a cross-attention mechanism, and a feedforward neural network. The self-attention mechanism is used to focus on the relationship between different positions in the output sequence during decoding, while the cross-attention mechanism is used to connect the encoder's output and the decoder's input, allowing the decoder to refer to the encoder's global feature information when generating the output.
[0161] Contextual information extraction includes multi-head self-attention mechanisms: these mechanisms utilize multiple heads to simultaneously compute attention, learning relationships between words in the input sequence from different representation subspaces. For example, in a multi-head self-attention mechanism, each head can focus on different types of semantic relationships, such as grammatical relationships and lexical similarity. The outputs of these heads are then concatenated to form a richer contextual representation. This allows for a more comprehensive extraction of contextual information from global features, contributing to more accurate seal recognition.
[0162] Cross-attention mechanism: This mechanism establishes a connection between the decoder and encoder, allowing the decoder to reference the global feature information of the encoder when generating each output tag. For example, when the decoder generates the name of the company to which the seal belongs, the cross-attention mechanism can help the decoder focus on the feature vectors in the encoder that are related to the company name, thereby improving the accuracy of the generation.
[0163] Fully connected layers and the softmax activation function: Fully connected layers: These layers weight and sum the extracted contextual information, integrating it into a linear score used to predict the probability distribution of each possible stamp output sequence. The weight parameters in the fully connected layer are learned through training, and can be assigned different weights based on the importance of the input contextual information.
[0164] The softmax activation function transforms the output of a fully connected layer into a probability distribution. For example, in a case with multiple possible stamp output sequences, the softmax function converts the score corresponding to each sequence into a probability value between 0 and 1, with the sum of all probability values being 1. This allows the determination of the most probable stamp output sequence, i.e., the target stamp information, based on the probability magnitude.
[0165] In some embodiments of the present invention, the target seal information includes at least: a first name information located in a first position, a second name information located in a second position, and a registration number information located in a third position.
[0166] Specifically, the target seal information should include at least the following:
[0167] Specifically, the primary name information, located in the first position, can be, but is not limited to, the company name. Its location and function: it is situated in the upper area of the seal. It is one of the most crucial identifying elements of the seal, used to clearly identify the company or entity to which it belongs. For example, the name "ABC Co., Ltd." can determine the origin and ownership of the seal, and has significant identification value in business activities, legal matters, and other scenarios.
[0168] The identifying characteristics of the primary name information (located in the first position) are: it is usually in a larger font, and the font style may be more formal and standardized to highlight the company's main position. The color may match the overall tone of the seal, but it generally has a clear contrast with the background for easy identification.
[0169] In some specific embodiments, the second name information located in the second position can be a description of the seal type or purpose, and its location and function: some seals, in addition to the above information, may also have a description of the seal type or purpose, such as "Contract Seal" or "Bidding Seal". This further clarifies the seal's usage scenarios and functions, helping to quickly determine the seal's applicability during use.
[0170] Furthermore, the identifying characteristics of the second name information located in the second position are: the text is concise and clear, directly explaining the purpose of the seal. Its position may be on the edge of the seal or in other places that do not affect the layout of the main information. The font size and style will be adjusted according to the overall design of the seal, but must ensure it is clearly legible.
[0171] In some embodiments, the second name information located in the second position may also be, but is not limited to, a department name. Its location and function are as follows: In some seal layouts, the department name may be marked below or near the company name. This helps to further refine the scope of the seal's use, clarifying which department within the company owns the seal. For example, the word "finance" in "finance seal" specifies that the seal is primarily used for finance-related matters.
[0172] Identification features: The font size may be relatively small compared to the company name, but it is still quite clear. The wording usually clearly indicates the nature or function of the department, such as "Marketing Department" or "Human Resources Department."
[0173] In some embodiments, the registration number information located in the third position can be the registration number of the official seal of the organization (located in the area below the seal). Its position and function are as follows: This is an important identifier of the seal's legitimacy. It is a unique number issued by the relevant management department, used for accurate identification and traceability of the seal in the seal management system. For example, a 13-digit registration number can ensure that each seal has a unique "identity," preventing forgery and misuse of seals.
[0174] Furthermore, the identification characteristics of the registration number information located in the third position are as follows: it is generally a combination of numbers and letters, and the format is relatively fixed. The arrangement of numbers and letters follows certain rules, possibly generated according to a specific coding method, and has a fixed position in the entire seal layout, usually located in the center or lower part of the bottom of the seal.
[0175] In some embodiments of the present invention, after the step of recognizing the target seal information in the target seal image based on the trained generative seal recognition model, the method includes:
[0176] The target seal information and the seal information to be identified in the seal image to be identified are compared.
[0177] If the target seal information and the seal information to be identified are different, the target seal information is corrected to obtain the correct target seal information.
[0178] If the target seal information and the seal information to be identified are the same, the target seal information is determined as the seal recognition result of a preset document; the preset document is a document that includes the image of the seal to be identified.
[0179] The comparison process includes at least the following steps: feature extraction and feature matching.
[0180] Specifically, the feature extraction steps are as follows: For the target seal information and the seal information to be identified, their respective features need to be extracted first. The features of the target seal information include the first name information (such as the company name), the second name information (department name), and the third location, such as the registration number. For the seal information to be identified, features such as text and patterns in the seal image are extracted using image processing techniques.
[0181] For example, optical character recognition (OCR) technology is used to identify the text portions of the seal image, including company names and registration numbers. Simultaneously, image analysis algorithms are used to extract the seal's pattern features, such as shape and texture.
[0182] The specific steps of feature matching are as follows: The extracted target seal information features are matched one by one with the seal information features to be identified. For text information, the content, font, font size, and arrangement of the text are compared to see if they are consistent. For pattern information, the shape, position, and proportion of the pattern are compared to see if they are the same.
[0183] For example, if the company name in the target seal information is "ABC Limited", then check if there is the same text in the image of the seal to be identified. At the same time, compare whether the combination of numbers and letters in the registration number is completely consistent, and whether the seal pattern matches the target seal in shape and layout.
[0184] Furthermore, when it is determined that the target seal information and the seal information to be identified are different, the target seal information needs to be corrected.
[0185] Specific corrective actions may include, but are not limited to, the following steps:
[0186] First, identify the specific differences. If the differences are in textual information, such as an incorrect company name, it needs to be corrected based on the correct name in the image of the seal to be identified. If the differences are in pattern information, such as a missing or distorted pattern, further analysis of the cause is needed, followed by repair or re-collection.
[0187] Secondly, the corrected target seal information needs to be verified. This can be done by comparing it again with the image of the seal to be identified, or by checking it against other reliable sources of seal information, to ensure the accuracy of the corrected information.
[0188] For example, if the company name "ABC Co., Ltd." in the target seal information is found to be different from the name "XYZ Co., Ltd." in the seal image to be identified, the company name in the target seal information needs to be corrected to "XYZ Co., Ltd." and verified.
[0189] When the target seal information and the seal information to be identified are the same, the target seal information is determined as the seal recognition result of the preset document.
[0190] The steps to determine the result may include, but are not limited to, the following:
[0191] First, ensure that the preset document contains the image of the seal to be recognized. The preset document can be a file containing multiple seal images, such as a contract or financial statement.
[0192] Secondly, the target seal information is associated with other relevant information in the pre-defined document. For example, in a contract document, in addition to seal information, it also includes information about both parties and contract terms. The accurate seal recognition results are added to the relevant records of the contract for subsequent retrieval and management.
[0193] For example, if the image of the seal to be identified in a sales contract is the same as the information of the target seal, then the seal identification result can be recorded as the official seal of Party A or Party B in the contract to confirm the validity of the contract.
[0194] This invention provides a seal recognition method based on a generative seal recognition model. Compared with traditional seal recognition methods, the end-to-end approach exhibits significant advantages in several aspects. First, by eliminating intermediate feature extraction steps, it significantly shortens processing time and improves recognition efficiency, particularly in scenarios requiring the processing of large amounts of seal data. Second, the end-to-end deep learning model possesses powerful feature learning capabilities, capable of handling challenges such as complex backgrounds and seal deformation, thus improving recognition accuracy. The end-to-end method directly optimizes the final recognition result, avoiding the accumulation of errors from intermediate steps and significantly improving the system's recognition accuracy. Finally, this method enhances its adaptability to complex samples through an attention mechanism, maintaining high accuracy even with seal rotation, partial occlusion, and complex backgrounds.
[0195] Overall, the end-to-end intelligent seal recognition method not only significantly reduces labor and time costs but also greatly expands the application scope of seal recognition technology, providing strong support for the intelligentization of fields such as electronic signatures, document management, and financial reimbursement. This innovative approach propels seal recognition technology towards a more efficient, accurate, and intelligent future.
[0196] This invention provides a seal recognition method, system, device, and storage medium based on a generative seal recognition model. The method involves acquiring a seal image to be recognized and preprocessing it to obtain a preprocessed image. A trained seal detection model is then used to detect initial seal information within the preprocessed image. Based on this initial seal information, a target seal image is extracted from the seal image to be recognized. Finally, the trained generative seal recognition model is used to recognize the target seal image, identifying the target seal information within it. This addresses the shortcomings of low efficiency and accuracy in existing seal recognition technologies by enabling the identification of seal images and the determination of target seal information using a generative seal recognition model. This not only improves the efficiency of seal recognition but also significantly enhances its accuracy.
[0197] The present invention provides a seal recognition system based on a generative seal recognition model. The seal recognition system based on a generative seal recognition model described below can be referred to in correspondence with the seal recognition method based on a generative seal recognition model described above.
[0198] like Figure 2 The diagram shown is a structural schematic of a seal recognition system based on a generative seal recognition model provided by the present invention. The seal recognition system based on a generative seal recognition model includes:
[0199] The preprocessing module 210 is used to acquire the image of the seal to be identified and to preprocess the image of the seal to be identified to obtain a preprocessed image.
[0200] The detection module 220 is used to detect the preprocessed image based on the trained seal detection model and detect the initial seal information in the preprocessed image.
[0201] The cutting module 230 is used to cut out the target seal image from the seal image to be identified based on the initial seal information;
[0202] The recognition module 240 is used to perform recognition processing on the target seal image based on the trained generative seal recognition model, and to identify the target seal information in the target seal image.
[0203] Preferably, the seal recognition system based on a generative seal recognition model provided by the present invention is further used to compare the target seal information with the seal information to be recognized in the seal image to be recognized.
[0204] If the target seal information and the seal information to be identified are different, the target seal information is corrected to obtain the correct target seal information.
[0205] If the target seal information and the seal information to be identified are the same, the target seal information is determined as the seal recognition result of a preset document; the preset document is a document that includes the image of the seal to be identified.
[0206] Preferably, the seal recognition system based on a generative seal recognition model provided by the present invention is further configured such that the initial seal information includes at least seal category information and seal coordinate information;
[0207] Based on the seal detection model and the image information of the preprocessed image, features of the preprocessed image are extracted to determine different seal features; wherein, the image information includes at least: color information and scale information, and the different seal features include at least: seal features of different colors and seal features of different scales;
[0208] Based on a preset feature fusion strategy, the features of seals of different colors and seals of different scales are fused to determine the seal category information and the seal coordinate information.
[0209] Preferably, the seal recognition system based on a generative seal recognition model provided by the present invention is further used to crop out the target seal area from the seal image to be recognized according to the seal category information and the seal coordinate information;
[0210] The target seal area is subjected to perspective transformation processing to determine the target seal image.
[0211] Preferably, the seal recognition system based on a generative seal recognition model provided by the present invention is further used for the recognition of the generative seal recognition model, which includes at least: an input layer, an encoding layer, and an output layer.
[0212] The input layer generates seal input data for recognition learning by sequentially performing image segmentation, embedding mapping, and position encoding on the target seal image.
[0213] The encoding layer encodes the stamp input data from the input layer using a generative encoder to generate global feature information.
[0214] The output layer maps the global feature information generated by the encoding layer to the natural language output space through a generative decoder. It extracts context information from the global feature information mapped to the natural language output space through a multi-head self-attention mechanism and a cross-attention mechanism. The context information is then mapped to a stamp output sequence through a fully connected layer and a softmax activation function, and the stamp output sequence is used as the target stamp information.
[0215] Preferably, the seal recognition system based on a generative seal recognition model provided by the present invention is further configured such that the target seal information includes at least: a first name information located in a first position, a second name information located in a second position, and a registration number information located in a third position.
[0216] This invention provides a seal recognition method, system, device, and storage medium based on a generative seal recognition model. The method involves acquiring a seal image to be recognized and preprocessing it to obtain a preprocessed image. A trained seal detection model is then used to detect initial seal information within the preprocessed image. Based on this initial seal information, a target seal image is extracted from the seal image to be recognized. Finally, the trained generative seal recognition model is used to recognize the target seal image, identifying the target seal information within it. This addresses the shortcomings of low efficiency and accuracy in existing seal recognition technologies by enabling the identification of seal images and the determination of target seal information using a generative seal recognition model. This not only improves the efficiency of seal recognition but also significantly enhances its accuracy.
[0217] Figure 3 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 3 As shown, the electronic device may include a processor 310, a communications interface 320, a memory 330, and a communication bus 340, wherein the processor 310, communications interface 320, and memory 330 communicate with each other via the communication bus 340. The processor 310 can call logical instructions in the memory 330 to execute a seal recognition method based on a generative seal recognition model. This method includes: acquiring a seal image to be recognized and preprocessing the seal image to obtain a preprocessed image; detecting the preprocessed image based on a trained seal detection model to detect initial seal information in the preprocessed image; cutting out a target seal image from the seal image to be recognized based on the initial seal information; and performing recognition processing on the target seal image based on the trained generative seal recognition model to recognize the target seal information in the target seal image.
[0218] Furthermore, the logical instructions in the aforementioned memory 330 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0219] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer is able to execute a seal recognition method based on a generative seal recognition model provided by the above methods. The method includes: acquiring a seal image to be recognized and preprocessing the seal image to obtain a preprocessed image; detecting the preprocessed image based on a trained seal detection model to detect initial seal information in the preprocessed image; cutting out a target seal image from the seal image to be recognized based on the initial seal information; and recognizing the target seal image based on the trained generative seal recognition model to recognize the target seal information in the target seal image.
[0220] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements a seal recognition method based on a generative seal recognition model provided by the methods described above. The method includes: acquiring a seal image to be recognized and preprocessing the seal image to obtain a preprocessed image; detecting the preprocessed image based on a trained seal detection model to detect initial seal information in the preprocessed image; cutting out a target seal image from the seal image to be recognized based on the initial seal information; and performing recognition processing on the target seal image based on the trained generative seal recognition model to recognize the target seal information in the target seal image.
[0221] The system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0222] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0223] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A seal recognition method based on a generative seal recognition model, characterized in that, include: Acquire an image of the seal to be identified, and preprocess the image of the seal to be identified to obtain a preprocessed image; The preprocessed image is detected based on the trained seal detection model to identify the initial seal information in the preprocessed image. The initial seal information includes at least seal category information and seal coordinate information; The preprocessed image is detected using a trained seal detection model to identify initial seal information, including: Based on the seal detection model and the image information of the preprocessed image, features of the preprocessed image are extracted to determine different seal features; wherein, the image information includes at least: color information and scale information, and the different seal features include at least: seal features of different colors and seal features of different scales; Based on a preset feature fusion strategy, the features of the seals of different colors and the features of the seals of different scales are fused to determine the seal category information and the seal coordinate information. The seal category information is used to determine the legality and purpose of the seal during seal verification, and the seal coordinate information is used to help determine whether the seal has been tampered with or moved. The feature extraction step, which utilizes color scale information, includes: Color space conversion and analysis steps: Perform color space conversion on the preprocessed image to obtain different color spaces, which are used to distinguish the seal color from the background color; Color and scale feature extraction steps: Extract the color and scale features of the seal based on the color and scale information; The steps for combining color and shape features are as follows: determine the shape features of the seal by analyzing the edge contours of the image or by using shape recognition algorithms; Determining the features of seals of different colors and at different scales specifically includes: using the Gaussian pyramid or Laplacian pyramid method to decompose the image at different scales, and extracting the color and shape features of the seal at each scale to obtain multiple seal features at different color scales. The preset feature fusion strategies include: Weighted fusion strategy steps: Assign different weights to different seal features based on their importance or reliability; The hierarchical fusion strategy involves: dividing the seal features into different levels for fusion; performing preliminary fusion of seal features of different colors within each color's seal features to obtain the comprehensive features at that scale; and then performing fusion between different feature scales to comprehensively consider information from multiple feature scales. Based on the initial seal information, the target seal image is cut out from the seal image to be identified; The target seal image is processed based on a trained generative seal recognition model to identify the target seal information in the target seal image.
2. The seal recognition method based on a generative seal recognition model according to claim 1, characterized in that, After the step of recognizing the target seal information in the target seal image based on the trained generative seal recognition model, the method includes: The target seal information and the seal information to be identified in the seal image to be identified are compared. If the target seal information and the seal information to be identified are different, the target seal information is corrected to obtain the correct target seal information. If the target seal information and the seal information to be identified are the same, the target seal information is determined as the seal recognition result of a preset document; the preset document is a document that includes the image of the seal to be identified.
3. The seal recognition method based on a generative seal recognition model according to claim 1, characterized in that, The step of cutting out the target seal image from the seal image to be identified based on the initial seal information includes: Based on the seal category information and the seal coordinate information, the target seal area is cropped from the seal image to be identified; The target seal area is subjected to perspective transformation processing to determine the target seal image.
4. The seal recognition method based on a generative seal recognition model according to any one of claims 1 to 3, characterized in that, The generative seal recognition model includes at least: an input layer, an encoding layer, and an output layer; The process of recognizing the target seal image based on the trained generative seal recognition model, and identifying the target seal information in the target seal image, includes: The input layer generates seal input data for recognition learning by sequentially performing image segmentation, embedding mapping, and position encoding on the target seal image. The encoding layer encodes the stamp input data from the input layer using a generative encoder to generate global feature information. The output layer maps the global feature information generated by the encoding layer to the natural language output space through a generative decoder. It extracts context information from the global feature information mapped to the natural language output space through a multi-head self-attention mechanism and a cross-attention mechanism. The context information is then mapped to a stamp output sequence through a fully connected layer and a softmax activation function, and the stamp output sequence is used as the target stamp information.
5. The seal recognition method based on a generative seal recognition model according to any one of claims 1 to 3, characterized in that, The target seal information includes at least: the first name information in the first position, the second name information in the second position, and the registration number information in the third position.
6. A seal recognition system based on a generative seal recognition model, characterized in that, include: The preprocessing module is used to acquire the image of the seal to be identified and to preprocess the image of the seal to be identified to obtain a preprocessed image. The detection module is used to detect the preprocessed image based on the trained seal detection model, and to detect the initial seal information in the preprocessed image. The initial seal information includes at least seal category information and seal coordinate information; The step of detecting initial seal information in the preprocessed image based on the trained seal detection model includes: extracting features from the preprocessed image based on the seal detection model and the image information of the preprocessed image to determine different seal features; wherein the image information includes at least color information and scale information, and the different seal features include at least different colored seal features and different scale seal features; and fusing the different colored seal features and the different scale seal features based on a preset feature fusion strategy to determine the seal category information and the seal coordinate information. The seal category information is used to determine the legality and purpose of the seal during seal verification, and the seal coordinate information is used to help determine whether the seal has been tampered with or moved. The feature extraction step, which utilizes color scale information, includes: Color space conversion and analysis steps: Perform color space conversion on the preprocessed image to obtain different color spaces, which are used to distinguish the seal color from the background color; Color and scale feature extraction steps: Extract the color and scale features of the seal based on the color and scale information; The steps for combining color and shape features are as follows: determine the shape features of the seal by analyzing the edge contours of the image or by using shape recognition algorithms; Determining the features of seals of different colors and at different scales specifically includes: using the Gaussian pyramid or Laplacian pyramid method to decompose the image at different scales, and extracting the color and shape features of the seal at each scale to obtain multiple seal features at different color scales. The preset feature fusion strategies include: Weighted fusion strategy steps: Assign different weights to different seal features based on their importance or reliability; The hierarchical fusion strategy involves: dividing the seal features into different levels for fusion; performing preliminary fusion of seal features of different colors within each color's seal features to obtain the comprehensive features at that scale; and then performing fusion between different feature scales to comprehensively consider information from multiple feature scales. The cutting module is used to cut out the target seal image from the seal image to be identified based on the initial seal information; The recognition module is used to perform recognition processing on the target seal image based on a trained generative seal recognition model, and to identify the target seal information in the target seal image.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the program, it implements the seal recognition method based on the generative seal recognition model as described in any one of claims 1 to 5.
8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the seal recognition method based on the generative seal recognition model as described in any one of claims 1 to 5.
9. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the seal recognition method based on the generative seal recognition model as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Signature identification method, device and equipment and readable storage medium
CN113361547A
Intelligent seal identification method and seal identification system
CN118918604A