A seal character and semantic recognition method based on multi-angle rotation sequence and spatial distribution analysis
Patent Information
- Application Number
- CN202611153950.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-31
- Publication Date
- 2026-10-16
AI Technical Summary
[0007]针对现有技术中传统OCR无法识别弯曲文字、无法理解印章排版结构及语义阅读顺序的问题,本发明提出了一种基于多角度旋转序列与空间分布分析的印章文字及语义识别方法,通过多角度旋转序列生成与跨帧文字关联融合,并结合文字空间分布几何特征分析以判断排版类型与阅读方向,实现了环形、线性、混合三种排版类型印章文字的准确识别与语义顺序的智能重建
本发明提出了环形排列、线性排列、混合排列的三分类排版理解体系,突破了现有技术仅能区分弯曲与非弯曲的二分类局限。通过RANSAC鲁棒拟合算法计算环形度得分和线性度得分,并引入角度分布熵、半径变异系数和主成分分析特征比三个补充统计特征,从多个维度刻画环形与线性排列的几何本质。消融实验表明,三个补充统计特征对排版分类准确率具有显著贡献,验证了多维空间分布特征融合的技术有效性,使系统能够准确识别同时包含环形文字和线性文字的复杂混合排版印章。
Smart Images

Figure CN122929580A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing and pattern recognition technology, and more specifically to a method for recognizing seal characters and semantics based on multi-angle rotation sequence and spatial distribution analysis. Background Technology
[0002] With the rapid advancement of archival digitization, the demand for automatic extraction and intelligent understanding of seal information in archives is becoming increasingly urgent. As the core identifier of the authenticity, authority, and legal validity of archival documents, seals carry key management information such as the name of the issuing authority, seal number, and date of use, playing an irreplaceable and vital role in application scenarios such as personnel file management, official document circulation, and forensic identification. However, the automatic recognition of seal text faces three unique technical challenges: First, the spatial arrangement of seal text is diverse—including circular arrangements evenly distributed along circular or elliptical boundaries, linear arrangements neatly arranged along rectangular boundaries, and mixed arrangements where circular and linear arrangements coexist—while traditional optical character recognition (OCR) technology can only effectively handle regular horizontally arranged text, with a sharp drop in accuracy for curved and rotated text. Second, the angle and position of the seal on the archive are random, and the orientation of the text on the same seal varies in different archives, further increasing the difficulty of recognition. Third, seals in real archives often suffer from image degradation problems such as uneven ink coverage, overlapping background text interference, and blurring and fading caused by paper aging, which severely restricts the recognition effect of conventional OCR methods. These challenges together constitute the technical bottleneck of intelligent seal text recognition.
[0003] The existing technology for automatic recognition of seal characters mainly includes the following two categories:
[0004] One type, represented by CN202210305130.0, detects text regions through a segmentation network, then performs elliptical fitting and polar coordinate transformation on curved text to expand it into a rectangle before feeding it into the recognition model. The essential limitations of this type of method are: (1) it only divides the layout into two categories, horizontal and curved, and does not have the ability to understand three categories of layout, such as circular, linear and mixed layouts; (2) after polar coordinate expansion, it only performs recognition and does not involve the judgment of the clockwise / counterclockwise reading direction of circular text or the reconstruction of semantic order; (3) it does not adopt a multi-angle rotation sequence and cross-frame information fusion strategy, and the recall rate of text with arbitrary rotation angles is limited.
[0005] Another type, represented by CN118053160A, calculates the rotation angle using a curved text detection model and a minimum bounding rectangle, and then uses a turn-to-normal detection model to determine the orientation of the text at 0 degrees or 180 degrees. The fundamental defects of this type of method are: (1) it cannot solve the problem of determining the clockwise / counterclockwise reading direction when circular text is laid out at any angle along the circumference; (2) it cannot handle the reading direction determination of linear text from left to right or from right to left; (3) it only relies on single-frame image processing and does not involve multi-frame fusion strategies to improve recognition robustness; (4) it does not involve the recognition and recursive processing of mixed layout types at all.
[0006] Furthermore, other related technical solutions only focus on character detection or geometric correction, without addressing a systematic analysis of the layout type of seal characters or intelligent judgment of reading direction and semantic order. Therefore, there is an urgent need for a seal character recognition method that can effectively handle arbitrary rotation angles, bending deformations, and mixed layout structures of seal characters, and intelligently determine reading direction and semantic order. Summary of the Invention
[0007] To address the problems of traditional OCR technology being unable to recognize curved characters, understand the layout structure of seals, and determine the semantic reading order, this invention proposes a seal character and semantic recognition method based on multi-angle rotation sequence and spatial distribution analysis. By generating multi-angle rotation sequences and fusing them with cross-frame text association, and combining the analysis of geometric features of text spatial distribution to determine the layout type and reading direction, this method achieves accurate recognition of seal characters of three layout types: circular, linear, and mixed, and intelligent reconstruction of their semantic order.
[0008] To achieve the above objectives, the present invention adopts the following technical solution: This invention provides a method for recognizing seal characters and semantics based on multi-angle rotation sequence and spatial distribution analysis, comprising the following steps: S1: Detect seals in the archive image and extract the seal region sub-image; S2: Determine the geometric type of the seal and determine the center point of the seal based on the sub-image of the seal area; the method for determining the center point adopts the corresponding geometric fitting method according to the different geometric types; S3: Calculate the adaptive rotation angle interval based on the seal size and text features, and rotate the seal area sub-image with the seal center point as the rotation center to generate a rotation sequence containing multiple frames of images; the adaptive rotation angle interval is configured to be divisible by 360 degrees to ensure the complete closure of the rotation sequence. S4: Perform text detection and recognition on each frame in the rotation sequence, extract the recognized text and its position information from each frame, and assign a unique global text ID to the same text through cross-frame association; S5: Extract the coordinate positions of each character in the sub-image of the seal area, construct a set of character coordinate points, perform spatial distribution geometric feature analysis on the set of points, and determine the layout type of the seal characters based on the analysis results; S6: Based on the type of layout, different strategies are adopted to determine the reading direction of the text, and the correct semantic order of the text is reconstructed according to the determined reading direction, and the seal text sequence is output.
[0009] Furthermore, step S1 specifically includes: A training dataset is constructed by collecting real archive scan images as background materials, generating virtual seal images of four geometric types including circles, rectangles, ellipses and rhombuses, and performing image degradation processing. The processed virtual seals are then combined with real archive background images to generate training images. The seals in the combined images and real archive images are annotated to generate annotation files. The YOLOv9 object detection architecture is used to train the seal detection model, and the domain transfer is fine-tuned on the COCO pre-trained weights. The scanned image of the document to be processed is input into the trained YOLOv9 model to perform forward inference. Non-maximum suppression is applied to the detection results, and the stamp region sub-image is cropped from the original image based on the coordinates of the finally retained detection box.
[0010] Furthermore, in step S2, the determination of the center point of the seal adopts the corresponding method according to the geometric type, specifically including: for circular seals, the center point is detected by Hough circle transformation; for rectangular seals, the maximum area contour is extracted and the center point is calculated using the minimum circumscribed rotating rectangle; for elliptical seals, the center point is extracted by ellipse fitting of the maximum contour; for rhomboid seals, the center point is calculated by polygon approximation of the maximum contour to the four vertices.
[0011] Furthermore, in step S3, the method for calculating the adaptive rotation angle interval is as follows: If the seal is round:
[0012] in, The diameter of the seal, denoted as the number of connected components of characters detected within the stamp area after Hough circle transformation, and c is the verification correction factor. If the seal is rectangular:
[0013] in, The width of the stamp area. The number of characters in the row with the most characters in the seal is obtained through horizontal projection analysis; If the seal is oval:
[0014] Where a and b are the semi-major and semi-minor axes of the fitted ellipse, respectively, both multiplied by 0.85 to exclude the seal border. The number of characters arranged along the elliptical path in the oval seal; If the seal is diamond-shaped:
[0015] in, The length of the horizontal diagonal of the rhombus. This refers to the number of characters arranged horizontally in a diamond-shaped seal.
[0016] Furthermore, in step S3, the sub-image of the seal region is rotated using the center point of the seal as the rotation center to generate a rotation sequence containing multiple frames of images, specifically including: Construct an affine transformation matrix with the center point as the center of rotation; Set the number of rotation frames Where α is the adaptive rotation angle interval; For the k-th frame image, calculate the rotation angle θ = k × α, k = 0, 1, ..., N; The stamp region sub-image is rotated according to the affine transformation matrix, and pixel filling is performed using bilinear interpolation. The pixel values of the blank areas after rotation are filled with white, generating a rotation sequence containing N+1 frames of images.
[0017] Furthermore, step S4 specifically includes: An OCR engine is used to perform text detection and recognition on each frame of the rotation sequence, and a list of detection results for each frame is output. When a text box in any of the detection results contains multiple consecutive characters, the width and number of characters of the text box are calculated. The text box is then uniformly divided into multiple sub-boxes in the horizontal direction according to the assumption of equal width. A corresponding single character is assigned to each sub-box and its coordinates in the original seal image coordinate system are recalculated. A structured record is created for each segmented single character, and the structured record includes at least the frame number, character content, position information in the original seal image coordinate system, and confidence level. For characters identified in two adjacent frames, the Hungarian algorithm is used for optimal matching. The optimal matching is based on spatial similarity and appearance similarity. The spatial similarity is determined based on the Euclidean distance between the predicted position and the actual detection position of the rigid body motion model with rotation angle as a parameter. The appearance similarity is determined based on the consistency of the text content. Successfully matched characters are assigned the same global literal ID, while unmatched characters are assigned a new global literal ID.
[0018] Furthermore, in step S4, an OCR engine is used to perform text detection and recognition on each frame of the rotated sequence, specifically including: The PaddleOCR PP-OCRv5 engine is used for text detection and recognition; For scenarios where circular curved text is dominant, polar coordinate expansion preprocessing is used before recognition. Taking the center point of the seal as the origin, the curved text is expanded into horizontal rectangular strips along the arc path to eliminate the influence of curvature on recognition.
[0019] Furthermore, in step S5, extracting the coordinate position of each character in the sub-image of the seal area specifically includes: for characters that are not directly recognized in the 0th frame of the rotation sequence, performing a reverse coordinate transformation by combining their position in the adjacent frame with the rotation angle, and estimating the coordinates of the character in the original sub-image of the seal area. The formula for the reverse coordinate transformation is:
[0020]
[0021] in, , This is the estimated coordinate of the text in the original image, frame 0 coordinate system. , The coordinates of the text detected by PP-OCRv5 in the nth frame of the rotated image; , The coordinates of the center point of the seal; Let be the rotation angle of the nth frame relative to the 0th frame. = × Counterclockwise is positive; This is the rotation frame number.
[0022] Furthermore, in step S5, the spatial distribution geometric feature analysis includes: calculating the ringness score using the RANSAC robust circular fitting algorithm; calculating the linearity score using the RANSAC robust linear fitting algorithm; and calculating the angular distribution entropy, radius variation coefficient, and principal component analysis feature ratio as supplementary statistical features.
[0023] Furthermore, in step S6, determining the reading direction of the text based on the layout type specifically includes: When the layout type is circular, the polar angle of each character is calculated with the center of the circle fitted by the circle as the pole. The initial sequence is obtained by sorting according to the polar angle. Candidate reading starting points are identified by detecting the angular gap between adjacent characters. Two candidate reading orders, clockwise and counterclockwise, are constructed respectively. The direction with the higher total score is selected as the final reading direction by using a weighted fusion method of geometric gap analysis and N-gram semantic verification. When the typesetting type is linear arrangement, the rows are divided and clustered according to the vertical axis of the text. The left and right boundary gaps of each row are calculated. The reading direction of each row is determined based on the comparison results of the boundary gaps and in combination with the traditional typesetting rules of Chinese seals. When the layout type is a mixed arrangement, a density-based spatial clustering algorithm is used to divide the text point set into multiple sub-clusters. For each sub-cluster, the layout type judgment and reading direction determination are recursively performed, and the overall reading order between sub-clusters is determined according to the spatial hierarchy rules. Sort the text according to the determined reading direction and output the sorted sequence of seal text.
[0024] The beneficial effects of the above-described technical solutions provided in the embodiments of the present invention include at least the following: This invention proposes a three-category typography understanding system for circular, linear, and mixed arrangements, overcoming the limitation of existing binary classification technologies that can only distinguish between curved and non-curved text. The circularity and linearity scores are calculated using the RANSAC robust fitting algorithm, and three supplementary statistical features—angular distribution entropy, radius variation coefficient, and principal component analysis feature ratio—are introduced to characterize the geometric essence of circular and linear arrangements from multiple dimensions. Ablation experiments show that the three supplementary statistical features significantly contribute to the typography classification accuracy, verifying the technical effectiveness of multi-dimensional spatial distribution feature fusion, enabling the system to accurately identify complex mixed typography seals containing both circular and linear text.
[0025] This invention models reading direction determination as a decision problem that fuses geometric and semantic evidence, fundamentally overcoming the limitation of existing technologies that can only determine the orientation of text. For circular arrangements, a geometric gap analysis score is constructed based on large gap detection, and semantic fluency is evaluated using an N-gram language model. A weighted fusion method is then used to determine the clockwise / counterclockwise reading direction. For linear arrangements, the left / right reading direction is determined by combining boundary gap analysis with traditional Chinese seal layout rules. The fusion of geometric and semantic features produces a significant complementary gain effect, maintaining robust direction determination capability under different seal quality conditions.
[0026] This invention uses the DBSCAN spatial clustering algorithm to automatically divide the text point set of mixed seals into different layout areas, recursively performs layout type judgment and reading direction determination for each sub-cluster, and then combines and outputs the complete text sequence according to spatial hierarchy rules.
[0027] This invention addresses the problem of arbitrary rotation angles of characters on seals by designing an adaptive angle-interval rotation sequence generation strategy with the center point as the rotation center. This strategy enables curved characters to appear as approximately horizontal characters in different directions in different frames. Combined with PP-OCRv5's frame-by-frame recognition and cross-frame association fusion, it effectively solves the problem of low recognition rate of curved and rotated characters in traditional OCR, and significantly improves the text recall rate and recognition accuracy. Attached Figure Description
[0028] To more clearly illustrate the technical solutions in the embodiments of the present 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 only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0029] Figure 1 This is a detailed flowchart illustrating the steps of the seal character and semantic recognition method based on multi-angle rotation sequence and spatial distribution analysis provided in this embodiment of the invention.
[0030] Figure 2 This is a schematic diagram of step S1, seal detection and extraction process, provided in an embodiment of the present invention.
[0031] Figure 3 This is a schematic diagram of the center point positioning process in step S2 provided in an embodiment of the present invention.
[0032] Figure 4 This is a schematic diagram of the rotation sequence generation process in step S3 provided in an embodiment of the present invention.
[0033] Figure 5 This is a schematic diagram of the multi-angle text recognition process in step S4 of this embodiment of the invention.
[0034] Figure 6 This is a schematic diagram of the spatial distribution analysis and layout type determination process for step S5 provided in an embodiment of the present invention.
[0035] Figure 7 This is a schematic diagram of step S6, determining the reading direction and sorting the text, provided in an embodiment of the present invention. Detailed Implementation
[0036] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0037] Example: like Figure 1 As shown, this invention discloses a method for recognizing seal characters and semantics based on multi-angle rotation sequence and spatial distribution analysis, including the following steps: S1: Perform seal detection on the archive image and extract the seal region sub-image; seal detection is based on a deep learning object detection model, and outputs the location information of the seal region and the corresponding seal geometry type.
[0038] Input: Scanned image of the document (TIFF / JPG / PNG / PDF format, resolution not less than 300dpi); Output: Sub-image of the stamp region (including location information) + stamp geometry type label S2: Determine the geometric type of the seal and determine the center point of the seal based on the sub-image of the seal area; the method for determining the center point adopts the corresponding geometric fitting method according to the different geometric types.
[0039] Input: a sub-image of the stamp region + a label for the stamp's geometric type; Output: Coordinates of the center point of the seal S3: Calculate the adaptive rotation angle interval based on the seal size and text features, and rotate the seal area sub-image with the seal center point as the rotation center to generate a rotation sequence containing multiple frames of images; the adaptive rotation angle interval is configured to be divisible by 360 degrees to ensure the complete closure of the rotation sequence.
[0040] Input: Sub-image of the seal area + coordinates of the seal center point; Output: A rotation sequence containing N+1 frames of images. S4: Perform text detection and recognition on each frame in the rotation sequence, extract the recognized text and its position information from each frame, and assign a unique global text ID to the same text through cross-frame association; cross-frame association is based on rigid body motion model prediction and Hungarian algorithm matching, assigning the same global text ID to text records belonging to the same physical character in different frames to eliminate duplicate recognition.
[0041] Input: Rotation sequence (N+1 frames of images); Output: A list of structured text records (including frame number, character content, position information in the original coordinate system, confidence level, and global text ID). S5: Extract the coordinate positions of each character in the sub-image of the seal area, construct a set of character coordinate points, perform spatial distribution geometric feature analysis on the point set, and determine the layout type of the seal characters based on the analysis results; the layout type includes three categories: circular arrangement, linear arrangement and mixed arrangement, and the spatial distribution geometric features include at least circularity features and linearity features, supplemented by angular distribution entropy, radius variation coefficient and principal component analysis feature ratio for comprehensive judgment.
[0042] Input: A list of structured text records (after deduplication); Output: Layout type (circular / linear / mixed / unknown) + spatial distribution feature score S6: Determine the reading direction of the text based on the type of layout, sort the text according to the determined reading direction, and output the sorted seal text sequence; the determination of the reading direction adopts differentiated strategies for circular arrangement, linear arrangement and mixed arrangement, respectively using polar angle sorting combined with gap detection and semantic verification, boundary gap analysis combined with traditional Chinese seal rules, and spatial clustering combined with recursive processing.
[0043] Input: A list of structured text records + formatting type; Output: The sorted sequence of seal characters (including reading direction information) This invention achieves end-to-end intelligent processing from seal area localization to semantic understanding of curved text layout. In particular, it proposes a three-classification system for layout types based on multi-dimensional spatial distribution features and a reading direction determination method based on geometric-semantic fusion, solving the technical problem that traditional OCR technology can only recognize text content but cannot understand the layout structure and semantic reading order of seal text.
[0044] The following is a detailed description of the seal character and semantic recognition method based on multi-angle rotation sequence and spatial distribution analysis of the present invention: like Figure 2 As shown, the training data construction, model training, and online inference process of the seal detection model are as follows: Detailed implementation of step S1, seal detection and extraction step: This step aims to accurately locate and extract the stamp area from a complex archival image background.
[0045] Step S11, Training Data Preparation and Augmentation: First, a dataset was constructed to train the seal detection model. Real document scan images were collected as background material. Using seal-making software, virtual seal images of four geometric shapes—circle, rectangle, ellipse, and rhombus—were generated, with at least 2000 images of each shape. The seal text content covered a database of common seal texts from government agencies and enterprises.
[0046] Image degradation processing is applied to the virtual seal image to simulate the effect of a seal on a real, old archive: 1. Add Gaussian noise with a mean of 0 and a standard deviation of [missing value]. ∈[5,25] are randomly selected; 2. Simulate motion blur, with a blur kernel length ∈ [3, 15] pixels and a random angle; 3. Adjust the contrast and brightness, with the contrast factor ∈ [0.7, 1.3] and the brightness offset ∈ [-20, 20]. 4. Randomly reduce saturation to simulate the fading effect of ink pad.
[0047] The processed virtual stamps are randomly positioned, with an edge constraint distance ≥50px, a rotation angle randomized from 0° to 360°, and a scaling factor of 0.8-1.2, and then composited with real archival background images to generate at least 10,000 composite training images. LabelImg or LabelMe is used to annotate the stamps in the composite images and at least 500 real archival images. The annotation information includes the coordinates of the four corner points of the stamp's bounding rectangle [x_min, y_min, x_max, y_max] and the corresponding stamp type label, such as 0-circle, 1-rectangle, 2-ellipse, 3-rhombus, generating a standard annotation file in YOLO format.
[0048] Step S12, Seal Detection Model Training: A stamp detection model was trained using the YOLOv9 object detection architecture. YOLOv9's advantage lies in its GELAN (Generalized Efficient Layer Aggregation Network) backbone, which achieves efficient feature extraction through hierarchical aggregation of multi-layer features. Combined with programmable gradient information and the PGI mechanism, it maintains multi-level deep supervision while assisting invertible branches in generating reliable gradients, effectively solving the information bottleneck problem in deep networks. The YOLOv9S version with 9.6M parameters was chosen, suitable for efficient deployment as the base network, and domain transfer fine-tuning was performed on the COCO pre-trained weights.
[0049] Training configuration: The dataset was randomly divided into training and validation sets in a 7:3 ratio. Hyperparameter settings: Input image resolution 640×640, batch size 16, initial learning rate 0.01, cosine annealing decay strategy, momentum 0.937, weight decay 0.0005, training for 300 epochs. The first 3 epochs were a warm-up phase, with the learning rate linearly increasing from 0.001 to 0.01. Bounding box regression was performed using the CIoU loss function.
[0050] Where IoU is the intersection-union ratio between the predicted bounding box and the ground truth bounding box. and ρ represents the center point of the predicted bounding box and the center of the ground truth bounding box, respectively; ρ is the Euclidean distance between the centers of the predicted bounding box and the ground truth bounding box; c is the diagonal length of the minimum bounding rectangle; α is the balance coefficient; and v measures the consistency of aspect ratio.
[0051] Data augmentation strategies include: Mosaic stitching (randomly stitching four images with a probability of 0.5), random horizontal flipping with a probability of 0.5, HSV color space enhancement (hue ±0.015, saturation ±0.7, brightness ±0.4), and scale transformation (±50%). Training continues until the model achieves an mAP@0.5 of 0.95 or higher on the validation set, typically converging within 150 to 200 epochs.
[0052] Step S13, Seal Detection and Extraction, Online Reasoning: In practical applications, the scanned images of the documents to be processed (supporting TIFF, JPG, PNG, and PDF formats, with a resolution of at least 300 dpi to ensure the recognizability of seal details) are input into the trained YOLOv9 model for forward inference. The model outputs one or more detection results, each containing: bounding box coordinates. The system calculates confidence scores (0-1) and seal type labels. Non-maximum suppression (NMS) is applied to overlapping detection boxes with an IoU threshold of 0.5, retaining only the detections with the highest confidence scores greater than 0.5. Seal region sub-images are cropped from the original image based on the retained detection box coordinates. For archival images containing multiple seals, each seal region is processed sequentially from left to right and top to bottom.
[0053] Step S2, Center Point Location: like Figure 3 As shown, the method for determining the center point of the stamp type is as follows: If the stamp type is circular, the Hough circle transform is used to detect the circular outline in the binary image, and the center coordinates are used as the center point; if the stamp type is rectangular, the outline with the largest area is extracted, the minAreaRect function is used to obtain the smallest circumscribed rotating rectangle, and its center coordinates are calculated as the center point; if the stamp type is elliptical, the largest outline is fitted with an ellipse, and the center point coordinates of the fitted ellipse are extracted; if the stamp type is rhombus, the largest outline is approximated with a polygon, and when the number of approximating vertices is 4, the arithmetic mean of the four vertices is calculated as the center point.
[0054] The method for calculating the adaptive rotation angle interval is as follows: First, estimate the average width of a single character in the seal image. For circular seals, estimate the average width of a single character based on its diameter and the number of characters. For non-circular seals, obtain the average width of a single character through character detection or edge projection analysis.
[0055] Then, the optimal rotation angle is calculated based on the stamp radius and the average width of a single character. The angle intervals are rounded up to values divisible by 360 degrees to ensure the complete closure of the rotation sequence. When the angle exceeds the range of 5 to 15 degrees, it is truncated to this range and recalculated. An affine transformation matrix is constructed with the center point as the rotation center to rotate the image, obtaining a rotation sequence containing multiple frames.
[0056] Step S3, detailed implementation of the rotation sequence generation step: like Figure 4 As shown, this step uses multi-angle rotation to present the curved text of the seal as approximately horizontal text in different directions in different frames, creating favorable conditions for subsequent OCR recognition.
[0057] First, the average width of a single character is estimated using heuristic rules based on seal size and character features. For circular seals, estimation is based on the seal diameter and the number of characters:
[0058] in, The diameter of the seal is taken as 0.9 times the diameter of the fitted circle to exclude the width of the seal border. The number of connected components of characters detected within the stamp area after Hough circle transformation is denoted by 1.1, which is an empirical correction factor considering character spacing. For rectangular seals:
[0059] in, The width of the stamp area. The number of characters in the row with the most characters in the seal is obtained through horizontal projection analysis; For oval-shaped seals:
[0060] Where a and b are the semi-major and semi-minor axes of the fitted ellipse, respectively, both multiplied by 0.85 to exclude the seal border. The number of characters arranged along the elliptical path in the oval seal; For diamond-shaped seals:
[0061] in, The length of the horizontal diagonal of the rhombus. This refers to the number of characters arranged horizontally in a diamond-shaped seal.
[0062] If the above heuristic rules are not effective If severe text adhesion results in a low number of connected components, projection analysis can be used as an alternative. The seal area is projected horizontally and vertically, and the average width of the projection peaks is taken as the mean. The estimated value; to obtain Then, calculate the optimal rotation angle:
[0063] in, The radius of the seal is an estimate; for circular seals, the fitted radius is used; for rectangular seals, the distance from the center point to the corner point is used; and for elliptical seals, the radius is used. For a rhombus-shaped seal, the average distance from the center point to the vertex is taken; the calculated value is then used to determine the distance. Round up to the nearest divisor of 360°, i.e., find the one that satisfies... Integer If α exceeds the range of 5° to 15°, then... Cut off to this range and recalculate ,in This indicates rounding up to the nearest integer.
[0064] The values of the above empirical correction coefficients are based on the following: Coefficients 0.9 and 0.85, representing the stamp border exclusion ratio, are based on statistics of 500 annotated stamps in the ICDAR 2023 ReST dataset. Statistics show that the average proportion of the stamp border width to the stamp radius is approximately 8.3% for circular stamps and 11.7% for elliptical stamps. Conservative estimates of 0.9 and 0.85 ensure that the complete information of all text is preserved while excluding border interference. Coefficient 1.1, representing the character spacing correction factor, is based on measured statistics of character spacing on 200 stamps with standard typesetting density. The average arc length between the center points of adjacent characters is approximately 1.08 to 1.15 times the width of a single character; 1.1 is taken as the median value. All the above coefficients are fixed values determined through statistical samples and can be adjusted in the configuration file according to the actual stamp style.
[0065] Rotation sequence generation process: using the coordinates of the seal center point determined in step S2 ( , Using as the center of rotation, construct a 2×3 affine transformation matrix. ,for From 0 to , Where α is the adaptive rotation angle interval; calculate the rotation angle. ,in =0,1,…,N, and =0 corresponds to the original image. Affine transformation and bilinear interpolation are applied to rotate the image. After rotation, blank areas are filled with white pixels with a value of 255. The original image is taken as frame 0, and each rotation is counter-clockwise. The degree is used to obtain subsequent frames, and finally obtain the content. +1 frame rotation sequence.
[0066] Step S4, Detailed Implementation of Multi-Angle Text Recognition: like Figure 5 As shown, this step systematically identifies seal characters from a multi-angle rotated image sequence and establishes a complete structured information record.
[0067] Step S41, Single-frame text recognition: For each frame of the rotation sequence The text detection and recognition were performed using the domestically developed open-source PaddleOCR PP-OCRv5 engine. PP-OCRv5 integrates DB++, Differentiable Binarization++ text detection algorithms, and SVTRv2, Scene Text Recognition with a Single Visual Model v2 text recognition algorithm. For text fields that are rotated to a near-horizontal orientation, PP-OCRv5 can recognize their content with high confidence.
[0068] For scenarios where circular or curved text is dominant, polar coordinate expansion preprocessing can be used before recognition, with the center point as the origin, along the arc path ( , The curved text is unfolded into horizontal rectangular strips to eliminate the impact of curvature on recognition. Each frame outputs a list of detection results, each containing: the text content, the coordinates of the four corner points of the text box, converted back to the original stamp image coordinate system, and the recognition confidence score.
[0069] Step S42: Text segmentation, structured information recording, and cross-frame association: When PP-OCRv5 detects a text box containing multiple consecutive characters, calculate the text box width. and number of characters According to the assumption of equal width, Divide the text box evenly in the horizontal direction into Each sub-frame is assigned a corresponding single character. The font is determined as either fixed-width or non-fixed-width based on the vertical projection histogram. Fixed-width fonts are divided equally, while non-fixed-width fonts are segmented using projection troughs. A structured record is created for each identified single character, and its coordinates in the original image coordinate system are recalculated after assigning the corresponding single character. A structured record containing the following fields is created for each identified single character: frame number n (identifying which frame of the rotated image the character comes from), the character char (single character), and position information. The original coordinate system contains the coordinates of the top left corner of the rectangle, its width and height, and the confidence score. It identifies the confidence score and the global text ID, a unique identifier used for cross-frame tracking.
[0070] For text identified in two adjacent frames, the Hungarian algorithm is used for optimal matching: spatial similarity is based on the position predicted by the motion model, with rotation angle... The Euclidean distance between the rigid body motion model with parameters and the actual detection position is used; appearance similarity is based on the consistency of text content. Successfully matched text retains the same global text ID, while new text that fails to match is assigned a new ID. All structured records are organized into a list L in frame number order, which serves as the data input for subsequent typesetting analysis.
[0071] Detailed implementation of step S5, spatial distribution analysis and layout type determination: like Figure 6 As shown, the type of layout can be accurately determined by directly analyzing the geometric characteristics of the spatial distribution of text on a two-dimensional plane.
[0072] Step S51, Extraction of raw location data: Extract each unique character from the structured list L generated in step S4, and deduplicate its coordinate information in the original image, frame 0, by global character ID. For characters not directly recognized in frame 0, since they are at an unfavorable angle for recognition, perform a reverse coordinate transformation based on their position in adjacent frames and rotation angle to calculate their coordinates in the original image. The formula for calculating the reverse coordinate transformation is:
[0073]
[0074] in, , This is the estimated coordinate of the text in the original image, frame 0 coordinate system. , The coordinates of the text detected by PP-OCRv5 in the nth frame of the rotated image; , The coordinates of the center point of the seal; Let be the rotation angle of the nth frame relative to the 0th frame. = × Counterclockwise is positive; The rotation frame number, ∈{0,1,..., }, .
[0075] The mathematical essence of this transformation is to first translate the text coordinates detected in the nth frame to a coordinate system with the center of the seal as the origin, then rotate them in the opposite direction by an angle θ (clockwise by θ), and finally translate them back to the original image coordinate system. When n=0, The transformation degenerates into an identity transformation.
[0076] After calculating the coordinates of all the text, construct the original location dataset. ,in The total number of distinct characters identified. For the first The character content of a text.
[0077] Step S52, Spatial Distribution Feature Extraction and Quantization: Perform multi-dimensional geometric feature analysis on dataset P.
[0078] Circularity feature: The coordinate point set was fitted using RANSAC (Random Sample Consensus), with 500 random samples and an interior point distance threshold of 0.05 × R. After eliminating outliers, the mathematical model was solved using the least squares method. parameters Calculate the circularity score The closer the score is to 1, the closer the point set is to a perfect circular distribution.
[0079] Linearity characteristics: The RANSAC robust line fitting algorithm is used to fit the equation of a straight line to the same set of coordinate points. , Solve for A, B, and C using the least squares method, and calculate the linearity score. ,in This represents the standard deviation of the distance from the coordinate point to the distribution center.
[0080] Supplementary statistical features include: angular distribution entropy Divide the polar angle of each point relative to the distribution center into uniform parts. For each interval, calculate the Shannon entropy of the distribution; a lower entropy value indicates a more concentrated angular distribution; the radius coefficient of variation... The ratio of the standard deviation of the distance from each point to the distribution center to the mean; principal component analysis eigenvalues. The ratio of the two eigenvalues of the coordinate covariance matrix reflects the difference in dispersion of the point set along the principal and secondary axes.
[0081] Step S53, Comprehensive judgment of layout type: A comprehensive decision is made based on the above feature scores. A threshold is set. and .
[0082] Decision-making rule: If and If it is determined to be a circular arrangement; and If it is determined to be a linear arrangement; and The arrangement is determined to be mixed, meaning the seal contains both circular and linear text; among them, For the circularity score, To determine the high threshold for ring detection, For linearity score, A low threshold is determined linearly. If none of the above conditions are met, it is marked as an unknown type and enters a special processing flow. When Low value and When the value is small, the confidence level of the circular arrangement determination is further enhanced.
[0083] Step S6, Detailed Implementation of Reading Direction Determination and Text Sorting Steps: like Figure 7 As shown, this step employs different strategies based on the type of layout to determine the reading direction of the text and reconstruct the correct semantic order.
[0084] Step S61: Determine the reading direction for the circular arrangement: The polar angle of each character is calculated using the center of the fitted circle as the pole and sorted by angle. Candidate reading starting points are identified through large gap detection, and two candidate reading orders, clockwise and counterclockwise, are constructed. A weighted fusion of geometric gap analysis and N-gram semantic verification is used to select the direction with the higher total score as the final reading direction. Specifically: The center of the circle fitted in step S52 Calculate the polar angle of each character, using the pole as the endpoint. Adjust the angle to The interval, and in the 12 o'clock direction, that is Alignment by rotating the reference point with the radian direction as 0: .according to Sort by ascending order, i.e., clockwise, to obtain the preliminary sequence:
[0085] in, Indicates the number after sorting by polar angle. Each character. Calculate the angular gap between adjacent characters after sorting. and the closing gap between the first and last characters. .
[0086] Statistical characteristics of the gap: average gap Standard deviation .when Time to determine the first one gap is a large gap, where is a sensitivity coefficient, with a default value of 1.8 and an adjustable range of 1.5 to 2.0. The theoretical basis for large gap detection is that there is usually a distinct blank area between the start and end positions of seal text, corresponding to the angle interval on the seal where no text is arranged, and the angular gap of this blank area is significantly larger than the uniform gap between texts. The calculation method of the geometric gap score is: for each candidate starting point position , which corresponds to the end point of the large gap or a user-specified position, the geometric rationality score of this position as the reading starting point is defined as:
[0087] where, is the large gap angle value before the candidate starting point, is the maximum value among all gaps, is a tiny constant for preventing division by zero. This score is normalized to the interval [0, 1] — the larger the gap, the closer the score is to 1, indicating that the geometric evidence of this position as the reading starting point is more sufficient. For the case where there is no obvious large gap, that is, all , is set to 0.5, indicating that the geometric features cannot distinguish the direction, and the direction depends entirely on semantic verification. At this time, the final direction is dominated by the semantic evaluation score.
[0088] Two candidate sequences are constructed, that is, the clockwise sequence arranged in ascending order , and arranged in descending order of the counter-clockwise sequence, that is, the reverse order of , for semantic evaluation respectively: calculate the probability score that the starting character belongs to the common starting character set {中, 省, 市, 公, 司, 国, 总, 北, 上, 广, 深}; calculate the probability score that the ending character belongs to the common ending character set {局, 办, 部, 印, 章, 司, 厅, 处, 室, 院}; evaluate the fluency of the full text using a 2-gram and 3-gram language model trained on Chinese corpora. Total semantic evaluation score = starting score × 0.3 + ending score × 0.3 + fluency score × 0.4.
[0089] The specific construction method of the N-gram language model is: collect about 50,000 Chinese institutional name corpora, including full names and standard abbreviations of administrative organs, public institutions, enterprises, and social organizations at all levels, as well as about 20,000 common Chinese seal term corpora, including suffix expressions such as special seal, financial seal, contract seal, and legal person seal, to construct a special training corpus. A hybrid language model combining 2-gram and 3-gram is adopted, the Kneser-Ney smoothing algorithm is used to solve the data sparsity problem, and the model is stored in ARPA format to support efficient retrieval. The fluency score obtained by weighted summation of the log probabilities of the text sequence under the 2-gram and 3-gram models: , the weights are determined via grid search to maximize the direction accuracy on the validation set. For rare institution names that do not appear in the training corpus, the model provides a reasonable probability estimation through the KneSer-Ney backoff mechanism, avoiding the zero-probability problem caused by data sparseness.
[0090] Finally: . This weight distribution is determined through ablation experiments. The direction judgment accuracy is 89.7% when only geometric features are used, 87.3% when only semantic features are used, and reaches 94.8% when the fusion ratio of 0.6:0.4 is adopted, which verifies the effectiveness of cross-modal fusion. The direction with a higher total score is selected as the final reading direction, and the complete seal text sequence is output according to this direction.
[0091] Step S62, determining the reading direction of linear arrangement: Cluster the characters according to the y-coordinate, with the clustering bandwidth being 0.5 times the average character height, to divide the characters into different lines. For each line, sort the characters from smallest to largest by x-coordinate to obtain a preliminary sequence. Calculate the left boundary gap of each line and the right boundary gap —— which are respectively defined as the distance from the left boundary of the first character in the line to the left boundary of the minimum enclosing rectangle of the characters in this line, and the distance from the right boundary of the last character in the line to the right boundary of the enclosing rectangle. Based on the typesetting rule that the boundary gap at the start end is usually larger than that at the end end: if the of most lines is significantly larger than and the ratio is >1.5, it is determined as reading from left to right; if the is significantly larger than the , it is determined as reading from right to left. Verification is carried out in combination with the traditional cultural rules of Chinese seals: official seals of government agencies, enterprises and public institutions usually adopt the modern typesetting mode from left to right; private name seals and traditional seals follow the traditional Chinese typesetting convention and adopt the typesetting mode from right to left. The text content clues include: when containing keywords of modern institution names, such as limited company, administration, committee, the direction tends to be from left to right; when ending with seal, stamp, imperial seal and having a small number of characters (≤4 characters), the direction tends to be from right to left. The final reading direction is determined by combining the geometric feature score and the semantic rule matching score.
[0092] Step S63, mixed arrangement processing, output and fault tolerance: Processing of mixed-arrangement seals: using the density-based DBSCAN spatial clustering algorithm, = 2 times the average character height, The text coordinate point set is divided into multiple sub-clusters, such as the circular text cluster on the outer edge of the seal and the linear text cluster in the center. Step S5 (layout type determination) is performed independently for each sub-cluster, and then steps S61 or S62 are recursively called to determine the reading direction and order of the text within each sub-cluster. The overall reading order is determined based on the spatial relationship and relative position between sub-clusters, following the rules: outer circle clusters precede inner circle clusters, upper sub-clusters precede lower sub-clusters, sorted based on the y-coordinate of the sub-cluster center; left sub-clusters precede right sub-clusters, sorted based on the x-coordinate of the sub-cluster center. This method is suitable for multi-column layout scenarios. The sub-clusters are combined in the determined order to generate the complete seal text, with appropriate separators added between the sub-clusters. The final structured output includes: layout type, reading direction, sorted text sequence and its coordinates in the original image, and processing confidence score. Warning signs are added to low-confidence results to suggest manual review. Visualized intermediate results are also provided, including circle fitting center and radius annotations, polar angle annotations, and reading direction arrow annotations for debugging and verification.
[0093] To verify the technical effectiveness of this invention, a systematic evaluation was conducted on the ICDAR 2023 ReST public dataset, containing 10,000 real seal images covering four geometric types: circle, rectangle, ellipse, and rhombus, and a self-built cadre personnel file seal dataset, containing 5,000 real scanned seal images derived from actual file digitization projects of various levels of organizational departments, including diverse samples with different stamping angles, ink quality, and background complexity. All experiments were performed in the same hardware environment: Huawei Ascend 910 NPU, 32GB system memory, Kirin V10 operating system, and PaddlePaddle 3.0 or later framework. Each experiment was repeated 5 times, the average value was taken, and the 95% confidence interval was reported.
[0094] Seal detection dimension: The seal detection module based on the YOLOv9-GELAN architecture of this invention achieves excellent detection accuracy and recall on public datasets, showing a significant improvement compared to the YOLOv8 baseline. On a self-built cadre personnel file seal dataset, it maintains high detection performance even under complex detection conditions such as low contrast and small size, verifying the robustness of the model in real-world application scenarios.
[0095] Text recognition dimension: Employing a multi-angle rotation sequence combined with PaddleOCR PP-OCRv5 frame-by-frame recognition and cross-frame association fusion strategy, the text recognition accuracy on public datasets is significantly better than single-frame OCR schemes that do not use rotation sequences. Excellent performance is also observed on self-built datasets, indicating that this method has good resistance to degradation phenomena such as ink fading and background interference.
[0096] Layout understanding dimension: High accuracy was achieved in the three-class classification of layout types, with ideal recognition results obtained for circular, linear, and mixed layout types. Ablation experiments show that the three supplementary statistical features introduced in this invention—angular distribution entropy, radius variation coefficient, and PCA feature ratio—significantly contribute to the layout classification accuracy, verifying the necessity of multi-dimensional spatial distribution feature fusion.
[0097] Reading direction judgment dimension: The comprehensive direction judgment achieved high accuracy, with excellent performance in judging clockwise and counterclockwise directions of circular text and left and right directions of linear text. The geometric-semantic fusion mechanism significantly improved the performance of direction judgment. Geometric features and semantic features can provide effective judgment criteria when used alone, but the accuracy of direction judgment after fusion is significantly better than either single feature scheme, verifying that cross-modal fusion produces a significant complementary gain effect.
[0098] End-to-end system performance: Under domestically developed IT hardware, the complete processing flow demonstrates high efficiency, meeting the actual processing speed requirements of the government archives digitization project. During trial operation, a large number of personnel file seals were processed, showing high overall end-to-end accuracy and high accuracy in reading the text order of circular seals, proving the stability and reliability of this method in practical applications. All core components of the system are implemented based on the domestic open-source PaddlePaddle framework, fully adapting to the domestic IT infrastructure environment.
[0099] In summary, this invention achieves superior performance in five dimensions: seal detection, character recognition, layout understanding, reading direction determination, and end-to-end system. Ablation experiments verify the technical contributions of each core innovative module. The overall solution demonstrates consistent superiority on both public datasets and self-built real datasets, providing an efficient, robust, and fully domestically produced end-to-end solution for seal character recognition and layout understanding in archival digitization projects.
[0100] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to the method section.
[0101] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for recognizing seal characters and semantics based on multi-angle rotation sequence and spatial distribution analysis, characterized in that, Includes the following steps: S1: Detect seals in the archive image and extract the seal region sub-image; S2: Determine the geometric type of the seal and determine the center point of the seal based on the sub-image of the seal area; the method for determining the center point adopts the corresponding geometric fitting method according to the different geometric types; S3: Calculate the adaptive rotation angle interval based on the seal size and text features, and perform rotation transformation on the seal area sub-image with the seal center point as the rotation center to generate a rotation sequence containing multiple frames of images. The adaptive rotation angle interval is configured to be divisible by 360 degrees to ensure the complete closure of the rotation sequence; S4: Perform text detection and recognition on each frame in the rotation sequence, extract the recognized text and its position information from each frame, and assign a unique global text ID to the same text through cross-frame association; S5: Extract the coordinate positions of each character in the sub-image of the seal area, construct a set of character coordinate points, perform spatial distribution geometric feature analysis on the set of points, and determine the layout type of the seal characters based on the analysis results; S6: Based on the type of layout, different strategies are adopted to determine the reading direction of the text, and the correct semantic order of the text is reconstructed according to the determined reading direction, and the seal text sequence is output.
2. The method as described in claim 1, characterized in that, Step S1 specifically includes: A training dataset is constructed by collecting real archive scan images as background materials, generating virtual seal images of four geometric types including circles, rectangles, ellipses and rhombuses, and performing image degradation processing. The processed virtual seals are then combined with real archive background images to generate training images. The seals in the combined images and real archive images are annotated to generate annotation files. The YOLOv9 object detection architecture is used to train the seal detection model, and the domain transfer is fine-tuned on the COCO pre-trained weights. The scanned image of the document to be processed is input into the trained YOLOv9 model to perform forward inference. Non-maximum suppression is applied to the detection results, and the stamp region sub-image is cropped from the original image based on the coordinates of the finally retained detection box.
3. The method as described in claim 1, characterized in that, In step S2, the center point of the seal is determined by the corresponding method according to the geometric type. Specifically, for circular seals, the center point is detected by Hough circle transform; for rectangular seals, the maximum area contour is extracted and the center point is calculated using the minimum circumscribed rotating rectangle; for elliptical seals, the center point is extracted by ellipse fitting of the maximum contour; for rhomboid seals, the center point is calculated by polygon approximating the maximum contour to the four vertices and then using the arithmetic mean.
4. The method as described in claim 1, characterized in that, In step S3, the method for calculating the adaptive rotation angle interval is as follows: If the seal is round: in, The diameter of the seal, denoted as the number of connected components of characters detected within the stamp area after Hough circle transformation, and c is the verification correction factor. If the seal is rectangular: in, The width of the stamp area. The number of characters in the row with the most characters in the seal is obtained through horizontal projection analysis; If the seal is oval: Where a and b are the semi-major and semi-minor axes of the fitted ellipse, respectively, both multiplied by 0.85 to exclude the seal border. The number of characters arranged along the elliptical path in the oval seal; If the seal is diamond-shaped: in, The length of the horizontal diagonal of the rhombus. This refers to the number of characters arranged horizontally in a diamond-shaped seal.
5. The method as described in claim 4, characterized in that, In step S3, the sub-image of the seal region is rotated using the center point of the seal as the rotation center to generate a rotation sequence containing multiple frames of images, specifically including: Construct an affine transformation matrix with the center point as the center of rotation; Set the number of rotation frames Where α is the adaptive rotation angle interval; For the k-th frame image, calculate the rotation angle θ = k × α, k = 0, 1, ..., N; The stamp region sub-image is rotated according to the affine transformation matrix, and pixel filling is performed using bilinear interpolation. The pixel values of the blank areas after rotation are filled with white, generating a rotation sequence containing N+1 frames of images.
6. The method as described in claim 1, characterized in that, Step S4 specifically includes: An OCR engine is used to perform text detection and recognition on each frame of the rotation sequence, and a list of detection results for each frame is output. When a text box in any of the detection results contains multiple consecutive characters, the width and number of characters of the text box are calculated. The text box is then uniformly divided into multiple sub-boxes in the horizontal direction according to the assumption of equal width. A corresponding single character is assigned to each sub-box and its coordinates in the original seal image coordinate system are recalculated. A structured record is created for each segmented single character, and the structured record includes at least the frame number, character content, position information in the original seal image coordinate system, and confidence level. For characters identified in two adjacent frames, the Hungarian algorithm is used for optimal matching. The optimal matching is based on spatial similarity and appearance similarity. The spatial similarity is determined based on the Euclidean distance between the predicted position and the actual detection position of the rigid body motion model with rotation angle as a parameter. The appearance similarity is determined based on the consistency of the text content. Successfully matched characters are assigned the same global literal ID, while unmatched characters are assigned a new global literal ID.
7. The method as described in claim 6, characterized in that, In step S4, an OCR engine is used to perform text detection and recognition on each frame of the rotation sequence, specifically including: The PaddleOCR PP-OCRv5 engine is used for text detection and recognition; For scenarios where circular curved text is dominant, polar coordinate expansion preprocessing is used before recognition. Taking the center point of the seal as the origin, the curved text is expanded into horizontal rectangular strips along the arc path to eliminate the influence of curvature on recognition.
8. The method as described in claim 1, characterized in that, In step S5, extracting the coordinate position of each character in the sub-image of the seal area specifically includes: for characters that are not directly recognized in the 0th frame of the rotation sequence, performing a reverse coordinate transformation by combining their position in the adjacent frame with the rotation angle, and estimating the coordinates of the character in the original sub-image of the seal area. The formula for the reverse coordinate transformation is: in, , This is the estimated coordinate of the text in the original image, frame 0 coordinate system. , The coordinates of the text detected by PP-OCRv5 in the nth frame of the rotated image; , The coordinates of the center point of the seal; Let be the rotation angle of the nth frame relative to the 0th frame. = × Counterclockwise is positive; This is the rotation frame number.
9. The method as described in claim 1, characterized in that, In step S5, the spatial distribution geometric feature analysis includes: calculating the ringness score using the RANSAC robust circular fitting algorithm; calculating the linearity score using the RANSAC robust linear fitting algorithm; and calculating the angular distribution entropy, radius variation coefficient, and principal component analysis feature ratio as supplementary statistical features.
10. The method as described in claim 1, characterized in that, In step S6, determining the reading direction of the text based on the layout type specifically includes: When the layout type is circular, the polar angle of each character is calculated with the center of the circle fitted by the circle as the pole. The initial sequence is obtained by sorting according to the polar angle. Candidate reading starting points are identified by detecting the angular gap between adjacent characters. Two candidate reading orders, clockwise and counterclockwise, are constructed respectively. The direction with the higher total score is selected as the final reading direction by using a weighted fusion method of geometric gap analysis and N-gram semantic verification. When the typesetting type is linear arrangement, the rows are divided and clustered according to the vertical axis of the text. The left and right boundary gaps of each row are calculated. The reading direction of each row is determined based on the comparison results of the boundary gaps and in combination with the traditional typesetting rules of Chinese seals. When the layout type is a mixed arrangement, a density-based spatial clustering algorithm is used to divide the text point set into multiple sub-clusters. For each sub-cluster, the layout type judgment and reading direction determination are recursively performed, and the overall reading order between sub-clusters is determined according to the spatial hierarchy rules. Sort the text according to the determined reading direction and output the sorted sequence of seal text.
Citation Information
Patent Citations
Method for identifying seal with curved text
CN114758347A