A circle center positioning method for seal impression identification

By employing image preprocessing, connected component analysis, and adaptive compensation methods in seal imprint recognition, the robustness and accuracy issues of existing seal center positioning technologies have been resolved. This achieves high-precision, interference-resistant, and all-scenario adaptable seal center positioning, suitable for scenarios such as mobile smart office and online invoice verification.

CN123181583APending Publication Date: 2026-11-27ANHUI YUNXI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611708325.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-31
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Existing seal center positioning technology suffers from problems such as a single initial value benchmark, inability to quantify deviations, rigid correction strategies, and insufficient robustness in various scenarios, making it difficult to meet the requirements of intelligent seal control terminals for high consistency, high precision, strong anti-interference, and full-scenario adaptability.

Method used

The image is scaled to a standard detection space in the preprocessing stage, the HSV red imprint mask is extracted and morphological denoising is performed, the initial circle center is calculated by the centroid of the maximum connected component and the minimum bounding circle, and unsupervised scene classification and dynamic correction are achieved by combining image classification and adaptive compensation. Finally, the image is mapped to the original image coordinate system for cropping and output.

Benefits of technology

It significantly improves anti-interference capabilities, enhances positioning accuracy and robustness, adapts to stamp images with different shooting DPI and size specifications, provides high fault tolerance and industrial applicability, and meets the needs of low computing power environments on mobile devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123181583A_ABST
    Figure CN123181583A_ABST
Patent Text Reader

Abstract

The application discloses a circle center positioning method for seal mark identification, which comprises the following steps: scaling a to-be-detected image to a standard detection space, extracting an HSV red mark mask and performing morphological denoising to obtain a pure mask; performing connected domain analysis on the mask, selecting a maximum connected domain centroid as an initial circle center, and calculating an effective radius according to a percentile algorithm; calculating a minimum enclosing circle of all red pixels in the image to obtain a geometric circle center, and classifying the image according to the offset vector of the geometric circle center and the initial circle center; adaptively compensating the initial circle center according to the classification result and the size proportion of the mark to obtain a final circle center; and mapping the final circle center to an original image coordinate system, performing square cutting, and outputting the image in a normalized form. The application is accurate in circle center positioning, low in time consumption in single-image processing, and suitable for mobile terminal seal verification and bill verification scenes through double-reference cross-diagnosis and adaptive compensation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of machine vision imprint image processing technology, and in particular to a method for center positioning in seal imprint recognition. Background Technology

[0002] In scenarios such as mobile smart office, online invoice verification, and electronic document authentication, accurate positioning of the center of the seal imprint is the fundamental core step for subsequent feature comparison, authenticity recognition, and text extraction. The accuracy of the center positioning directly determines the accuracy and stability of the entire imprint recognition system.

[0003] Existing seal center positioning technologies are mainly divided into three mainstream implementation schemes: the first is the Hough circle detection algorithm based on contour fitting, which fits the center of the seal's outer circle contour; the second is the pentagram vertex geometric solution algorithm, which solves the center of the seal by finding the mean of the pentagram's corner points and the intersection of the perpendicular bisectors; and the third is the single connected domain centroid solution algorithm, which coarsely locates the center of the seal by weighting the centroid of the red imprint area.

[0004] The existing technology has the following inherent defects: 1. The single initial center model has poor robustness and weak adaptability to different scenarios. Existing patents and general algorithms all adopt the technical approach of solving the center of the circle using a single benchmark. In real business scenarios, seals generally suffer from interference such as stamping skew, uneven pressure, edge defects, local stains, incomplete imprint patterns, paper wrinkles, and local overlap of multiple seals. The single algorithm has obvious bias and extremely low fault tolerance.

[0005] 2. The lack of a dual-reference center cross-checking mechanism makes it impossible to quantify the positioning error level. Existing technologies do not have a technical solution for parallel solving of dual independent initial centers and quantification of the difference deviation. They cannot distinguish between "global region centroid deviation" and "local feature geometric deviation". The unified correction strategy leads to overcorrection of small deviations, undercorrection of large deviations, and failure to identify abnormal deviations.

[0006] 3. The calibration strategy is fixed and lacks intelligent hierarchical fine-tuning logic, resulting in an upper limit to accuracy and stability. Existing seal center fine-tuning all adopt a linear fixed strategy, which lacks the ability to adapt to working conditions and cannot adapt to seal images with different shooting DPIs and different sizes, resulting in extremely poor generalization ability.

[0007] In summary, existing seal center positioning technologies suffer from several technical challenges, including a single initial value benchmark, inability to quantify deviations, rigid correction strategies, and insufficient robustness across various scenarios. These limitations make it difficult to meet the industrial-grade deployment requirements of intelligent seal control terminals, which demand high consistency, high precision, strong anti-interference capabilities, and full-scenario adaptability. Summary of the Invention

[0008] The purpose of this invention is to overcome the shortcomings of the existing technology. To achieve the above objective, a method for center positioning in seal imprint recognition is adopted to solve the problems mentioned in the background technology.

[0009] This invention provides a method for center location in seal imprint recognition, comprising the following steps: Step S1: Preprocess the image of the stamp imprint to be detected. The preprocessing includes scaling the image to a standard detection space, extracting the HSV red imprint mask and performing morphological denoising to obtain a clean imprint mask image. Step S2: Perform connected component analysis on the clean imprint mask image, select the largest connected component and calculate its centroid as the initial circle center, statistically analyze the imprint pixel distance distribution based on the initial circle center, and calculate the effective radius of the imprint using the percentile algorithm. Step S3: Calculate the minimum bounding circle for all red pixels in the clean imprint mask image to obtain the geometric center; calculate the offset vector between the geometric center and the initial center, and classify the image based on the offset vector; Step S4: Based on the image classification results and the imprint size ratio, adaptive compensation is performed on the initial circle center to obtain the final circle center; Step S5: Map the final circle center to the original image coordinate system, perform square cropping and normalize the output.

[0010] Furthermore, the specific steps of scaling the image to the standard detection space in step S1 are as follows: using a bilinear interpolation algorithm to scale the image of any size to a standard detection space of 710×710 pixels, and predefining global constants for detection scaling factor, output scaling factor, standard stamp radius, and standard cropping radius.

[0011] Further, the specific steps for extracting the HSV red imprint mask in step S1 are as follows: the HSV red gamut threshold is: hue H∈[0°,20°]∪[340°,360°], saturation S>0.30, and brightness V>0.25; and a degradation mechanism is set: when the total number of red pixels is less than 10, it is downgraded to RGB centroid detection, and when the total number of red pixels is less than 20, it is downgraded to center square cropping.

[0012] Furthermore, the specific steps for morphological denoising in step S1 are as follows: the morphological closing operation uses a 14-radius, 29×29 size operation kernel and adopts a separable implementation method to sequentially perform four one-dimensional operations: horizontal 1×29 dilation, vertical 29×1 dilation, horizontal 1×29 erosion, and vertical 29×1 erosion.

[0013] Furthermore, in step S2, a connected component BFS traversal is used to filter the connected component of the largest outer red circle of the stamp, and the initial center is solved by the average pixel coordinates; when the number of pixels in the largest connected component is less than 100, the full-image red dot MEC degradation process is started.

[0014] Furthermore, in step S2, the straight-line distances from all red pixels of the imprint to the initial center are collected, sorted in ascending order, and the 85th percentile distance value is taken as the effective radius of the imprint.

[0015] Furthermore, in step S3, a non-recursive iterative Welzl algorithm is adopted, with a fixed number of 100 iterations and a fixed random seed. The minimum enclosing circle is solved by random three-point circumcircle sampling and local pixel expansion optimization. When the iteration is singular, the centroid + P90 radius backtracking scheme is enabled.

[0016] Further, in step S3, the horizontal offset is defined as: mecDx = MEC center x - BFS center x, and the vertical offset is defined as: mecDy = MEC center y - BFS center y; wherein, the decision tree classification rule is: mecDx > 0 is determined to be an image without black text, mecDx ≤ 0 and mecDy > 0 is determined to be a vertical black text image, and mecDx < 0 and mecDy < 0 is determined to be a horizontal black text image.

[0017] Furthermore, in step S4, the adaptive compensation includes size ratio correction and scene difference compensation: the scaling factor is calculated by the ratio of the standard radius to the measured P85 radius, and the cropping radius is dynamically corrected; wherein, the image without black text is horizontally shifted to the left by 5.0px, the image with vertical black text is horizontally shifted to the right by 3.0px, and the image with horizontal black text is vertically shifted to the top by 5.0px. The vertical compensation amount is adaptively fine-tuned using a dynamic formula based on the radius ratio.

[0018] Furthermore, in step S5, coordinate mapping is completed based on the scaling ratio of the width and height of the original image and the detection space, the cropping radius is enlarged by 15% to construct a square cropping box, boundary clamping is used to prevent cropping from going out of bounds, and finally the cropped image is uniformly scaled to 710×710 pixels for output.

[0019] Compared with the prior art, the present invention has the following technical advantages: By scaling images of arbitrary size to the standard detection space during the preprocessing stage and extracting the HSV red imprint mask and performing morphological denoising, the black text pollution and background noise in the document are effectively isolated, providing a clean imprint mask basis for subsequent circle center localization and significantly improving the anti-interference capability.

[0020] Using the centroid of the largest connected component as the initial circle center and calculating the effective radius of the imprint based on the percentile algorithm, the interference of outlier noise points is avoided, and the initial circle center positioning is robust. At the same time, the traditional Hough circle transform is replaced by connected component analysis, which greatly reduces memory and computational overhead and is suitable for low computing power environments on mobile devices.

[0021] By calculating the minimum bounding circle of all red pixels to obtain the geometric center, and forming an offset vector with the initial center, unsupervised image classification without training data and OCR is achieved. It can automatically distinguish different black text distribution scenes, providing a basis for differential compensation and overcoming the defect that the single initial center model cannot distinguish between regional centroid deviation and geometric deviation.

[0022] Adaptive compensation is performed on the initial center based on image classification results and imprint size ratio, so that the compensation amount dynamically changes with the actual size of the stamp and the shooting DPI. This solves the problem of poor generalization ability of traditional fixed pixel compensation, effectively corrects the center offset caused by black text contamination and imaging differences, and improves positioning accuracy.

[0023] Finally, the center of the circle is mapped to the coordinate system of the original image, then cropped into a square and normalized for output. This ensures the standardization of the output imprint image and the center of the circle, providing a unified benchmark for subsequent recognition and comparison. The entire process has high fault tolerance and industrial applicability. Attached Figure Description

[0024] The specific embodiments of the present invention will now be described in detail with reference to the accompanying drawings: Figure 1 This is a schematic diagram illustrating the steps of the circle center positioning method according to an embodiment of this application; Figure 2 This is a flowchart of a circle center positioning method according to an embodiment of this application; Figure 3 The images shown are illustrations illustrating the image imprint recognition effects for three types of images: horizontal black text, vertical black text, and no black text, according to embodiments disclosed in this application. Detailed Implementation

[0025] 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.

[0026] Example 1 Please refer to Figure 1 In this embodiment of the invention, a method for center location in seal imprint recognition includes the following steps: Step S1: Preprocess the image of the seal imprint to be detected. This step includes four sub-steps: native image decoding, detection space normalization scaling, HSV red imprint mask extraction, and separable morphological closing operation denoising, with the aim of obtaining a clean imprint mask image.

[0027] S11, Native Image Decoding: It receives JPEG / PNG binary Uint8List byte data of the stamp imprint uploaded from the mobile device, calls the instantiateImageCodec interface built into the dart:ui engine to complete the decoding, and obtains the original resolution image in ui.Image format. No third-party image processing libraries are called throughout the process, thus avoiding stability risks such as memory overflow in the mobile C-level library and program crashes.

[0028] S12, Detection space normalization scaling: The standard detection space size is defined as 710×710 pixels. The physical basis for this size is that a standard official seal with a diameter of 45mm corresponds to approximately 709 pixels in a 400DPI imaging specification. At 710 pixels, each pixel corresponds to approximately 0.063mm, meeting the sub-millimeter level center positioning accuracy requirement. The drawImageRect bilinear interpolation algorithm is used to completely map the original image of any size to the 710×710 pixel standard detection space. Predefined global constants are loaded synchronously: detection scaling factor 2.7734, output scaling factor 1.3867, standard seal radius 194.72 pixels, and standard cropping radius 203.01 pixels. This unified detection space provides a standardized benchmark for all subsequent coordinate calculations and scaling compensation.

[0029] S13, HSV red imprint mask extraction: The normalized RGB image is converted pixel by pixel to the HSV color space. This embodiment uses a fixed color gamut threshold: hue H∈[0°,20°]∪[340°,360°], saturation S>0.30, and lightness V>0.25. This threshold covers the full color gamut range of official seal vermilion (hue 0°-10°), orange-red (hue 10°-20°), and dark red (hue 340°-360°). The lower limit of saturation is relaxed from the conventional 0.50 to 0.30, and the lower limit of lightness is relaxed from 0.30 to 0.25 to accommodate color attenuation caused by ink diffusion, scanning distortion, and insufficient lighting under real shooting conditions. Pixels that meet the thresholds are set to 1, and the rest are set to 0, generating a binary mask image.

[0030] Simultaneously, a two-level degradation mechanism is configured for pixel-scarce scenes: when the total number of red pixels is less than 10, it is judged as an extremely abnormal image and downgraded to RGB centroid detection mode; when the total number of red pixels is less than 20, it downgrades to center square cropping mode. This mechanism ensures that the process is not interrupted for extremely dark, extremely blurry, or non-stamp images.

[0031] S14, Separable Morphological Closure Operation Denoising: A 29×29 large kernel morphological closing operation with a radius of 14 is applied to the binary mask image. This embodiment adopts a separable implementation method, decomposing the traditional two-dimensional closing operation into four one-dimensional operations, which are performed sequentially: horizontal 1×29 dilation, vertical 29×1 dilation, horizontal 1×29 erosion, and vertical 29×1 erosion.

[0032] The processing effect is reflected in two aspects: First, the expansion operation will bridge the 1 to 2 pixel gaps on the outer red circle of the stamp caused by uneven ink, so that the outer circle forms a complete connected region; Second, the discrete pseudo-red scatter points generated by the intersection of black text and red imprint in the document will remain as independent small connected regions after the closing operation, and will not be connected to the main connected region of the outer circle, thus being naturally isolated in the subsequent connected region analysis.

[0033] The computational complexity of the separable implementation is reduced from O(N²×841) to O(N²×58), with a theoretical speedup of 14.5 times. In a 710×710 detection space, this step takes 30 to 80 ms in actual tests.

[0034] Step S2: Perform connected component analysis on the clean imprint mask image. This step includes two sub-steps: BFS centroid location of connected components and P85 percentile radius calculation. The purpose is to obtain a robust initial center and effective imprint radius.

[0035] S21, BFS connection centroid location: The denoised mask image is traversed using a breadth-first search (BFS) of connected components. All red connected components are marked, and the number of pixels in each connected component is counted. The connected component with the largest pixel volume—the red circle connected component on the outer edge of the stamp—is selected as the center positioning reference.

[0036] The theoretical basis lies in the fact that the outer red circle of the seal, after closing the loop, forms a "thick ring" structure, whose pixel size (typically 5000 to 50000 pixels) is much larger than that of the central pentagram (approximately 500 pixels) and the seal name text (approximately 1000 pixels). Therefore, the largest connected component is the outer red circle, and its geometric centroid corresponds to the geometric center of the seal. The initial center of the circle (bestCx, bestCy) is obtained by calculating the mean of the pixel coordinates using BFS.

[0037] Simultaneously, a connected component pixel threshold is set: when the maximum number of connected component pixels is less than 100, BFS localization is determined to have failed, and the full-map red dot MEC degradation process is automatically started to ensure stable output under abnormal scenarios.

[0038] Calculation of S22 and P85 percentile radii: Using the initial circle center as a reference, traverse all valid red pixels of the imprint, calculate the straight-line distance from each pixel to the initial circle center, generate a distance array and sort it in ascending order, and extract the 85th percentile distance value as the effective radius of the imprint.

[0039] The reason for choosing P85 instead of the maximum value is that outliers on the outer red circle—such as ink splatter, scanning noise, and isolated distant points caused by imaging distortion—can make the maximum value 5 to 10 pixels too large, resulting in a larger cropping radius and the inclusion of background noise. The P85 percentile algorithm effectively eliminates these extreme outliers, making the radius parameter more robust and providing a stable input for subsequent scaling factor calculation and cropping box construction.

[0040] In the specific implementation steps, P85 is a reasonable value determined through experiments, a threshold with good redundancy. Of course, the range of P80-P90 is also reasonable for imprints under different conditions. For imprints with high precision, it can be increased to P90, while for imprints with poor ink quality, it may be necessary to adjust it to P80, depending on the actual situation.

[0041] Step S3: Calculate the minimum bounding circle for all red pixels in the clean imprint mask image and obtain the image classification. This step includes two sub-steps: MEC minimum bounding circle diagnostic calculation and offset vector decision tree image classification. Its purpose is to establish a dual-center model and perform unsupervised scene classification.

[0042] S31, MEC Minimum Enclosing Circle Diagnostic Calculation: A non-recursive iterative Welzl minimum bounding circle algorithm is used for all red pixels in the image. The recursive implementation of the classic Welzl algorithm is eliminated (due to the tailless recursion optimization in Dart language, recursion is prone to stack overflow and incurs high list copying overhead). Instead, an iterative scheme with a fixed number of 100 iterations and a fixed random seed (seed=42, ensuring reproducibility) is adopted. In each iteration, three different red pixels are randomly selected, and the circumcircle of these three points is calculated. Then, the farthest point outside the circle is found by traversing all red pixels in the image. The radius of the bounding circle is updated through local pixel expansion optimization. After the iteration terminates, the initial center and radius of the MEC geometric circle are output.

[0043] The purpose of this step is to obtain the center of a geometrically unbiased enclosing circle that represents the distribution of red pixels across the entire image. Its physical meaning differs from that of the BFS centroid in that the BFS centroid reflects the "centroid of mass distribution" of the largest connected region, while the MEC centroid reflects the "geometric containment center" of all red pixels in the image. The two centroids have different offset directions under different black-text contamination scenarios, forming the signal basis for subsequent classification.

[0044] When an outlier occurs during the iterative solution (such as three collinear points causing the determinant to approach zero), the centroid + P90 radius fallback scheme is automatically activated. The arithmetic centroid of all red pixels in the image is used as the estimated value of the MEC center, and the P90 percentile value of the distance distribution is used as the estimated value of the radius, ensuring that this diagnostic step will not become a point of interruption in the process.

[0045] S32, Offset Vector Decision Tree Image Classification: Calculate the offset vector components between the MEC center and the initial BFS center: mecDx = MEC center x BFS center x (horizontal offset) mecDy = MEC center y BFS center y (vertical offset) An unsupervised decision tree is constructed based on the sign of the offset vector, and the classification rules are as follows: When mecDx > 0, it is determined to be an image without black text. The physical meaning is: when the distribution of red imprints is symmetrical, the geometric center of MEC is slightly to the right relative to the centroid of BFS, indicating that there is no significant skew of the BFS centroid by the black text in the document.

[0046] When mecDx≤0 and mecDy>0, it is determined to be a vertical black text image. The physical meaning is: the vertical black text is located on the left and right sides of the seal, which pulls the BFS centroid to the horizontal direction, while the MEC circle center is located below the BFS centroid.

[0047] When mecDx < 0 and mecDy < 0, it is determined to be a horizontal black text image. The physical meaning is: the horizontal black text pulls the BFS centroid downwards and to the right, and the MEC circle center is located to the upper left of the BFS centroid.

[0048] This decision tree relies solely on the sign of the offset vector, requiring no training data, no OCR recognition, and no additional feature extraction. The classification logic does not overlap across the three scenarios. In the experimental verification data of this embodiment: horizontal black text sample (Figure number 1920138) mecDx= 1.3, mecDy= 5.1 Correct classification; Vertical black text sample (Figure number 1752582) mecDx= 0.7, mecDy=+2.3, correctly classified; no black text sample (image number 1370137) mecDx=+0.9, correctly classified.

[0049] Step S4: Perform adaptive center compensation based on image classification results and imprint size ratio. The purpose of this step is to correct the initial circle center of BFS to a high-precision final circle center. The compensation logic consists of two parts: size ratio correction and scene difference compensation.

[0050] S41. Size Proportion Correction: Define the scaling factor _s = _stdR / max(1.0, current P85 radius), where _stdR is the standard stamp radius of 194.72 pixels, and the current P85 radius is calculated in step S2.2. The physical meaning of _s is the size ratio of the current imprint to the standard stamp. The cropping radius is dynamically adjusted based on the scaling factor. radius256 = max(10.0, _stdCropR / _s 4.0) Where _stdCropR is the standard crop radius of 203.01 pixels. This formula adjusts the crop radius proportionally to the actual size of the stamp, with a large stamp corresponding to a large crop radius and a small stamp corresponding to a small crop radius, and uniformly reduces it by 4 pixels to eliminate background noise outside the outer red circle.

[0051] S42, Scene Differentiation Compensation: Based on the classification results of step S3.2, differential correction is performed on the center coordinates.

[0052] Horizontal direction: Shift the image without black text (cx) 5.0px to the left (noBlackExtra=) 5.0); the vertical black text image cx is shifted 3.0px to the right (vertExtra=+3.0); no additional compensation is applied to the horizontal black text image in the horizontal direction.

[0053] Vertical direction: The horizontal black text image cy is moved up 5.0px (horizExtra= 5.0); The vertical compensation amount is calculated using the dynamic formula 8.0 × radius 256 / 72.20. 9.0 performs adaptive fine-tuning, where 8.0 is the baseline fine-tuning amount in the 256 space, and radius256 / 72.20 is the ratio coefficient between the current cutting radius and the baseline radius. 9.0 is a unified base offset (an empirical calibration value used to counteract the systematic pull-down effect of the red text at the bottom on the centroid).

[0054] This formula consists of a size ratio conversion term and a fixed offset term: the ratio conversion term dynamically adjusts according to the ratio of the actual stamp size to the reference size, used to compensate for the centroid pull-down offset that changes linearly with the stamp size; the fixed offset term is used to offset systematic biases that do not change with size. In the standard detection space (710×710 pixels), for standard-sized stamps, this formula is equivalent to a fixed offset value; for non-standard-sized stamps, this formula automatically scales the compensation amount according to the radius ratio, thus adapting to different DPI devices and different stamp sizes.

[0055] The core advantage of this proportional compensation lies in the fact that the compensation amount dynamically changes with the actual cropping radius of each image, rather than being a fixed pixel value. The compensation ratio remains consistent across different DPI devices and different sized stamps, overcoming the systematic failure problem of fixed pixel compensation under varying imaging conditions.

[0056] The compensation parameters for the three scenarios in this embodiment are summarized as follows:

[0057] Step S5: Map the final circle center to the original image coordinate system and perform normalized cropping output. The purpose of this step is to accurately map the compensation results in the detection space back to the original resolution image, thus completing the standardized output.

[0058] S51. Original image coordinate mapping: Based on the scaling ratio between the original image and the detection space, the compensated center coordinates and cropping radius in the detection space are mapped to the original image coordinate system: origCx = cx256 × scaleX origCy = cy256 × scaleY origRadius = radius256 × 1.15 × min(scaleX, scaleY) Where scaleX and scaleY are the ratios of the original image width and height to the detection space size of 710 pixels, respectively. The radius magnification factor of 1.15 (i.e., 15%) is used to ensure that the cropping frame completely includes the outer red circle of the stamp, avoiding the loss of the stamp due to compensation errors or incomplete edges.

[0059] S52, Square Cutting and Boundary Clamping: A square cropping box with a side length equal to twice the origRadius is constructed, centered at the compensated center (origCx, origCy). Boundary clamping operations are used to constrain the cropping box within the valid area of ​​the original image, preventing cropping out of bounds.

[0060] S53, Normalized Output: The cropped area is uniformly scaled to a standard output size of 710×710 pixels using a bilinear interpolation algorithm to obtain a standardized imprint image with a centered center and uniform specifications, thus completing the entire process of center positioning and preprocessing.

[0061] Multi-level fault degradation link This invention configures a complete multi-level degradation mechanism, covering the following extreme scenarios: Level 1: When the total number of red pixels is less than 10, it is downgraded to RGB centroid detection, and the centroid of the red channel is directly calculated and centered in the RGB color space; Level 2: When the total number of red pixels is less than 20, it is downgraded to a central square cropping, which performs equilateral cropping with the geometric center of the image as the center. Level 3: When the maximum number of connected pixels is <100, BFS localization fails and is downgraded to the full-image red dot MEC process, where the MEC center directly replaces the BFS centroid for subsequent compensation. Level 4: When solving singularities using MEC iteration, enable the centroid + P90 radius fallback scheme.

[0062] The degradation mechanisms at each level are interconnected, ensuring that any input image—including abnormal conditions such as extreme blur, severe red deficiency, and noise overload—can output stable results, making the system extremely robust.

[0063] Example 2 like Figure 2 As shown, based on Embodiment 1, some steps are described in detail below. The specific steps are as follows: Step 1: Native Image Decoding: Receive JPEG / PNG binary Uint8List byte data of the stamp image uploaded by the mobile device, call the dart:ui engine's instantiateImageCodec interface to complete native decoding, and obtain the original resolution image in ui.Image format. No third-party image processing libraries are called throughout the process, avoiding memory overflow and program crash issues.

[0064] Step 2, Detection Space Normalization Scaling: Define a standard detection size of 710×710 pixels. Using the drawImageRect bilinear interpolation algorithm, the original image is completely mapped to the standard detection space. Simultaneously load predefined constants: detection scaling factor 2.7734, output scaling factor 1.3867, standard stamp radius 194.72 pixels, and standard crop radius 203.01 pixels to complete the unified normalization preprocessing of the image.

[0065] Step 3: HSV Red Imprint Mask Extraction: Convert the 710×710 normalized RGB image pixel by pixel to the HSV color space. Filter red pixels according to the thresholds H∈[0°,20°]∪[340°,360°], S>0.30, and V>0.25 to generate a binary mask image. Perform a degradation judgment: RGB centroid degradation is triggered if the total number of red pixels is <10; center square cropping degradation is triggered if the total number of red pixels is <20.

[0066] Step 4: Separable Morphological Closure Denoising: Using a 14-radius, 29×29 kernel, perform horizontal 1×29 dilation, vertical 29×1 dilation, horizontal 1×29 erosion, and vertical 29×1 erosion sequentially. Close the 1-2 pixel ink break in the outer red circle of the stamp, forming a complete connected region in the outer circle. At the same time, filter out the discrete false red scattering points caused by black text contamination to obtain a clean imprint mask connected region image. The measured computation time is 30-80ms.

[0067] Step 5: BFS Connected Component Centroid Location: The BFS algorithm is used to traverse the mask image, marking all red connected components and counting the number of pixels. The outer red circle connected component with the largest number of pixels is selected, and the average x and y coordinates of all pixels in this connected component are calculated to obtain the initial BFS centroid (bestCx, bestCy). If the maximum number of pixels in the largest connected component is less than 100, the full-image red dot MEC degradation process is initiated.

[0068] Step 6, Calculate the 85th percentile radius: Traverse all red pixels in the largest connected region, calculate the straight-line distance from each pixel to the initial center of the BFS circle, generate a distance array and sort it in ascending order, extract the 85th percentile distance value as the initial radius of the imprint, and remove extreme outliers caused by ink splatter and scanning distortion to ensure the stability of the radius parameter.

[0069] Step 7: MEC Minimum Enclosing Circle Diagnostic Calculation: An iterative Welzl algorithm is used, with a fixed number of 100 iterations and a fixed random seed. In each iteration, three red pixels are randomly selected to solve for the circumcircle. The optimal enclosing circle radius is expanded by traversing the loop, and finally, the initial geometric center and radius of the MEC are output. When singular values ​​are encountered in the iterative solution, the centroid + P90 radius fallback scheme is automatically activated.

[0070] Step 8: Offset Vector Decision Tree Image Classification: Calculate the offset vectors mecDx = MEC.cx - BFS.cx and mecDy = MEC.cy - BFS.cy, and perform decision tree classification: if mecDx > 0, it is classified as an image without black text; if mecDx ≤ 0 and mecDy > 0, it is classified as an image with vertical black text; if mecDx < 0 and mecDy < 0, it is classified as an image with horizontal black text. The three scene classifications have no overlap and the accuracy is 100%.

[0071] Step 9, Multi-Scene Adaptive Center Compensation: Calculate the size scaling factor _s = _stdR / max(1.0, current P85 radius), and correct the cropping radius radius256 = max(10.0, _stdCropR / _s - 4.0). Perform differential compensation: shift the cx of the image without black text to the left by 5.0px, shift the cx of the vertical black text image to the right by 3.0px, and shift the cy of the horizontal black text image to the top by 5.0px; the vertical coordinate is dynamically corrected using 8.0 × radius256 / 72.20 - 9.0 to adapt to different stamp sizes and device DPIs.

[0072] Step 10: Original Image Coordinate Mapping and Normalized Cropping: Based on the aspect ratio of the original image and the detection space, the compensated center and cropping radius of the detection space are mapped to the original image coordinate system. The cropping radius is enlarged by 15% to construct a square cropping box, and boundary clamping is used to prevent out-of-bounds movement. Finally, the cropped area is bilinearly interpolated and scaled to 710×710 pixels to output a normalized imprint image, completing the precise positioning of the center.

[0073] Actual test results data Under the baseline configuration of this embodiment, the algorithm's processing performance is as follows: The average processing time for a single image is 474ms, including approximately 150ms for HSV mask extraction, approximately 50ms for morphological closing operation, approximately 10ms for BFS connected component analysis, approximately 2ms for MEC calculation, approximately 30ms for cropping and scaling, and approximately 200ms for image decoding, which meets the real-time processing requirements of mobile devices.

[0074] Regarding the accuracy of circle center localization, the residuals after compensation for all three image types were controlled within 2 pixels (equivalent to 0.28% of the standard 710-pixel space), achieving sub-pixel level localization accuracy. The decision tree classification achieved 100% accuracy on the test set in this embodiment.

[0075] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention. The scope of the invention is defined by the appended claims and their equivalents, all of which should be included within the scope of protection of the invention.

Claims

1. A method for center positioning in seal imprint recognition, characterized in that, Includes the following steps: Step S1: Preprocess the image of the stamp imprint to be detected. The preprocessing includes scaling the image to a standard detection space, extracting the HSV red imprint mask and performing morphological denoising to obtain a clean imprint mask image. Step S2: Perform connected component analysis on the clean imprint mask image, select the largest connected component and calculate its centroid as the initial circle center, statistically analyze the imprint pixel distance distribution based on the initial circle center, and calculate the effective radius of the imprint using the percentile algorithm. Step S3: Calculate the minimum bounding circle for all red pixels in the clean imprint mask image to obtain the geometric center; calculate the offset vector between the geometric center and the initial center, and classify the image based on the offset vector; Step S4: Based on the image classification results and the imprint size ratio, adaptive compensation is performed on the initial circle center to obtain the final circle center; Step S5: Map the final circle center to the original image coordinate system, perform square cropping and normalize the output.

2. The method for center positioning in seal imprint recognition according to claim 1, characterized in that, The specific steps of scaling the image to the standard detection space in step S1 are as follows: using a bilinear interpolation algorithm to scale an image of any size to a standard detection space of 710×710 pixels, and predefining global constants for detection scaling factor, output scaling factor, standard stamp radius, and standard cropping radius.

3. The method for center positioning in seal imprint recognition according to claim 1, characterized in that, The specific steps for extracting the HSV red imprint mask in step S1 are as follows: The HSV red gamut threshold is: hue H∈[0°,20°]∪[340°,360°], saturation S>0.30, and brightness V>0.25; and a degradation mechanism is set: when the total number of red pixels is less than 10, it is downgraded to RGB centroid detection, and when the total number of red pixels is less than 20, it is downgraded to center square cropping.

4. The method for center positioning in seal imprint recognition according to claim 1, characterized in that, The specific steps for morphological denoising in step S1 are as follows: the morphological closing operation uses a 14-radius, 29×29 size operation kernel and adopts a separable implementation method to perform four one-dimensional operations in sequence: horizontal 1×29 dilation, vertical 29×1 dilation, horizontal 1×29 erosion, and vertical 29×1 erosion.

5. The method for center positioning in seal imprint recognition according to claim 1, characterized in that, In step 2, a connected component BFS traversal is used to filter the connected component of the largest outer red circle of the stamp, and the initial center is solved by the average pixel coordinates; when the number of pixels in the largest connected component is less than 100, the full-image red dot MEC degradation process is started.

6. The method for center positioning in seal imprint recognition according to claim 1, characterized in that, In step S1, the straight-line distance from all red pixels of the imprint to the initial center is collected, sorted in ascending order, and the 85th percentile distance value is taken as the effective radius of the imprint.

7. The method for center positioning in seal imprint recognition according to claim 1, characterized in that, In step S3, a non-recursive iterative Welzl algorithm is used, with 100 fixed iterations and a fixed random seed. The minimum enclosing circle is solved by random three-point circumcircle sampling and local pixel expansion optimization. When iterating singularities, the centroid + P90 radius fallback scheme is enabled.

8. The method for center positioning in seal imprint recognition according to claim 1, characterized in that, In step S3, the horizontal offset is defined as: mecDx = MEC center x - BFS center x, and the vertical offset is defined as: mecDy = MEC center y - BFS center y. The decision tree classification rules are as follows: if mecDx > 0, the image is classified as having no black text; if mecDx ≤ 0 and mecDy > 0, the image is classified as having vertical black text; and if mecDx < 0 and mecDy < 0, the image is classified as having horizontal black text.

9. The method for center positioning in seal imprint recognition according to claim 1, characterized in that, In step S4, adaptive compensation includes size ratio correction and scene difference compensation: the scaling factor is calculated by the ratio of the standard radius to the measured P85 radius, and the cutting radius is dynamically corrected. Specifically, images without black text are shifted horizontally to the left by 5.0px, images with vertical black text are shifted horizontally to the right by 3.0px, and images with horizontal black text are shifted vertically upward by 5.0px. The vertical compensation amount is adaptively fine-tuned using a dynamic formula based on the radius ratio.

10. The method for center positioning in seal imprint recognition according to claim 1, characterized in that, In step S5, coordinate mapping is completed based on the scaling ratio of the width and height of the original image and the detection space. The cropping radius is enlarged by 15% to construct a square cropping box. Boundary clamping is used to prevent cropping from going out of bounds. Finally, the cropped image is uniformly scaled to 710×710 pixels for output.