Seal authenticity determination method and device, storage medium, electronic equipment and product
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA CONSTRUCTION BANK
- Filing Date
- 2025-12-29
- Publication Date
- 2026-04-10
AI Technical Summary
[0004]本申请实施例提供了一种印章真伪的确定方法、装置、存储介质及电子设备、产品,以至少解决相关技术中,电子验印系统在Web端操作复杂、耗时长且系统架构繁重的问题
[0015]In this embodiment, a document image uploaded by a target object via an application programming interface (API) is received. The document image contains a seal to be verified. If the first contour feature corresponding to the seal to be verified in the document image is similar to the second contour feature corresponding to a preset standard seal, the seal to be verified is rotated multiple times at first angular intervals to determine a first matching angle between the seal to be verified and the preset standard seal. The first matching angle is adjusted according to a second angular interval to obtain a target matching angle between the seal to be verified and the preset standard seal. The similarity value between the image of the seal to be verified and the image of the preset standard seal at the target matching angle is calculated, and the authenticity of the seal to be verified is determined based on the similarity value. This technical solution solves the problems of complex operation, long processing time, and cumbersome system architecture in electronic seal verification systems on the Web platform. Furthermore, by receiving document images via the API, using contour feature similarity filtering, and combining hierarchical angular rotation matching to determine the optimal matching angle, the similarity of the adjusted image is calculated, achieving efficient online seal authenticity verification.
Smart Images

Figure CN121837894A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of process automation technology, and more specifically, to a method, apparatus, storage medium, electronic device, and product for determining the authenticity of a seal. Background Technology
[0002] Existing electronic signature verification systems, especially web-based applications, face a series of technical challenges that significantly impact user experience and overall system efficiency. Traditional solutions often rely on users installing specific browser plugins or local service programs. This not only increases the user's workload—requiring downloading, installation, and permission configuration—but also demands a certain level of computer literacy, limiting the application scope for users without a technical background. Furthermore, while enabling local services or deploying backend signature verification services can provide verification functionality to some extent, the former is less user-friendly due to the need for user-managed service processes, while the latter increases system complexity and maintenance costs due to the need for additional server resources, the pressure of concurrent access, and the risk of service failures.
[0003] Therefore, in related technologies, no effective solution has yet been proposed to address the problems of complex operation, long time consumption, and heavy system architecture of electronic seal verification systems on the Web. Summary of the Invention
[0004] This application provides a method, apparatus, storage medium, electronic device, and product for determining the authenticity of a seal, in order to at least solve the problems of complex operation, long time consumption, and heavy system architecture of electronic seal verification systems on the Web in related technologies.
[0005] According to one embodiment of this application, a method for determining the authenticity of a seal is provided, comprising: receiving a document image uploaded by a target object through an application programming interface, wherein the document image contains a seal to be verified; when it is determined that a first contour feature corresponding to the seal to be verified in the document image is similar to a second contour feature corresponding to a preset standard seal, performing multiple rotations on the seal to be verified at a first angular interval to determine a first matching angle between the seal to be verified and the preset standard seal; adjusting the first matching angle at a second angular interval to obtain a target matching angle between the seal to be verified and the preset standard seal; calculating a similarity value between the image of the seal to be verified and the image of the preset standard seal at the target matching angle, and determining the authenticity of the seal to be verified based on the similarity value.
[0006] In an exemplary embodiment, determining a first matching angle between the seal to be verified and a preset standard seal by performing multiple rotations on the seal to be verified at first angular intervals includes: calculating the similarity between the image of the seal to be verified and the image of the preset standard seal after each rotation to obtain multiple similarity values; identifying the maximum similarity value among the multiple similarity values and the rotation angle corresponding to the maximum similarity value; and determining the rotation angle as the first matching angle, wherein the first matching angle is the rotation angle corresponding to the seal to be verified after rotating based on its original position at at least one first angular interval.
[0007] In an exemplary embodiment, before determining that the first contour feature corresponding to the seal to be verified in the document image is similar to the second contour feature corresponding to the preset standard seal, and before performing multiple rotation processing on the seal to be verified according to the first angular interval to determine the first matching angle between the seal to be verified and the preset standard seal, the method further includes: determining the first width and first height corresponding to the contour of the seal to be verified in the first contour feature, and determining the second width and second height corresponding to the contour of the preset standard seal in the second contour feature; calculating the first similarity between the first width and the second width, and the second similarity between the first height and the second height; and performing a similarity calculation on the first contour feature and the second contour feature corresponding to the preset standard seal based on the first similarity and the second similarity.
[0008] In an exemplary embodiment, after calculating the similarity between the first contour feature and the second contour feature corresponding to a preset standard seal based on the first similarity and the second similarity, the method further includes: determining whether the first contour feature and the second contour feature are similar based on the relationship between the calculated similarity value and a preset similarity threshold; determining that the first contour feature and the second contour feature are similar if the similarity value is greater than the preset similarity threshold; and determining that the first contour feature and the second contour feature are not similar if the similarity value is less than or equal to the preset similarity threshold.
[0009] In an exemplary embodiment, after receiving the ticket image uploaded by the target object through the application programming interface, the method further includes: performing color filtering processing on the image of the seal to be verified and the image of the preset standard seal; and determining the red seal area in the image of the seal to be verified and the image of the preset standard seal based on the color filtering processing result.
[0010] In one exemplary embodiment, calculating the similarity value between the image of the seal to be verified and the image of a preset standard seal at the target matching angle, and determining the authenticity of the seal to be verified based on the similarity value, includes: determining whether the image matching degree between the seal to be verified and the preset standard seal at the target matching angle reaches a preset authenticity standard based on the similarity value; if the image matching degree reaches the authenticity standard, determining that the seal to be verified is a genuine seal; if the image matching degree does not reach the authenticity standard, determining that the seal to be verified is a counterfeit seal.
[0011] According to another aspect of the embodiments of this application, a device for determining the authenticity of a seal is also provided, comprising: a receiving module, configured to receive a document image uploaded by a target object through an application programming interface, wherein the document image contains a seal to be verified; a processing module, configured to, when determining that a first contour feature corresponding to the seal to be verified in the document image is similar to a second contour feature corresponding to a preset standard seal, perform multiple rotation processing on the seal to be verified at a first angular interval to determine a first matching angle between the seal to be verified and the preset standard seal; an adjustment module, configured to adjust the first matching angle at a second angular interval to obtain a target matching angle between the seal to be verified and the preset standard seal; and a calculation module, configured to calculate a similarity value between the image of the seal to be verified and the image of the preset standard seal at the target matching angle, and determine the authenticity of the seal to be verified based on the similarity value.
[0012] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer-readable storage medium, and the computer program is configured to execute the above-described method for determining the authenticity of a seal when it is run.
[0013] According to another aspect of the embodiments of this application, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the method for determining the authenticity of the seal through the computer program.
[0014] According to another aspect of the embodiments of this application, a computer program product is also provided, including a computer program, and a method for determining the authenticity of the above-mentioned seal when the computer program is executed by a processor.
[0015] In this embodiment, a document image uploaded by a target object via an application programming interface (API) is received. The document image contains a seal to be verified. If the first contour feature corresponding to the seal to be verified in the document image is similar to the second contour feature corresponding to a preset standard seal, the seal to be verified is rotated multiple times at first angular intervals to determine a first matching angle between the seal to be verified and the preset standard seal. The first matching angle is adjusted according to a second angular interval to obtain a target matching angle between the seal to be verified and the preset standard seal. The similarity value between the image of the seal to be verified and the image of the preset standard seal at the target matching angle is calculated, and the authenticity of the seal to be verified is determined based on the similarity value. This technical solution solves the problems of complex operation, long processing time, and cumbersome system architecture in electronic seal verification systems on the Web platform. Furthermore, by receiving document images via the API, using contour feature similarity filtering, and combining hierarchical angular rotation matching to determine the optimal matching angle, the similarity of the adjusted image is calculated, achieving efficient online seal authenticity verification. Attached Figure Description
[0016] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0017] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a schematic diagram of the hardware environment for a method of determining the authenticity of a seal according to an embodiment of this application;
[0019] Figure 2 This is a flowchart of a method for determining the authenticity of a seal according to an embodiment of this application;
[0020] Figure 3 This is a flowchart of a web-based signature verification algorithm according to an embodiment of this application;
[0021] Figure 4 This is a structural block diagram of a device for determining the authenticity of a seal according to an embodiment of this application. Detailed Implementation
[0022] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0023] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, apparatus, or device that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, apparatus, or devices.
[0024] According to one aspect of the embodiments of this application, a method for determining the authenticity of a seal is provided. This method for determining the authenticity of a seal is widely applicable to whole-house intelligent digital control application scenarios such as smart homes, smart home ecosystems, and intelligence house ecosystems. Optionally, in this embodiment, the above-mentioned method for determining the authenticity of a seal can be applied to, for example... Figure 1 The hardware environment shown consists of terminal device 102 and server 104. Figure 1 This is a schematic diagram of the hardware environment for a method of determining the authenticity of a seal according to an embodiment of this application, as shown below. Figure 1 As shown, server 104 is connected to terminal device 102 via a network and can be used to provide services (such as application services) to the terminal or clients installed on the terminal. A database can be set up on the server or independently of the server to provide data storage services for server 104. Cloud computing and / or edge computing services can be configured on the server or independently of the server to provide data processing services for server 104.
[0025] The aforementioned network may include, but is not limited to, at least one of the following: wired network, wireless network. The aforementioned wired network may include, but is not limited to, at least one of the following: wide area network, metropolitan area network, local area network. The aforementioned wireless network may include, but is not limited to, at least one of the following: Wi-Fi (Wireless Fidelity), Bluetooth. The terminal device 102 may not be limited to PC, mobile phone, tablet computer, smart air conditioner, smart range hood, smart refrigerator, smart oven, smart stove, smart washing machine, smart water heater, smart washing equipment, smart dishwasher, smart projector, smart TV, smart clothes rack, smart curtains, smart audio-visual equipment, smart socket, smart speaker, smart speaker box, smart fresh air equipment, smart kitchen and bathroom equipment, smart bathroom equipment, smart robot vacuum cleaner, smart window cleaning robot, smart mopping robot, smart air purifier, smart steam oven, smart microwave oven, smart water heater, smart air purifier, smart water dispenser, smart door lock, etc.
[0026] This embodiment provides a method for determining the authenticity of a seal, applied to the aforementioned terminal device. Figure 2 This is a flowchart of a method for determining the authenticity of a seal according to an embodiment of this application. The process includes the following steps:
[0027] Step S202: Receive a ticket image uploaded by the target object through the application programming interface, wherein the ticket image contains a seal to be verified;
[0028] Step S204: If it is determined that the first contour feature corresponding to the seal to be verified in the bill image is similar to the second contour feature corresponding to the preset standard seal, the seal to be verified is rotated multiple times according to the first angle interval to determine the first matching angle between the seal to be verified and the preset standard seal.
[0029] Step S206: Adjust the first matching angle according to the second angle interval to obtain the target matching angle between the seal to be verified and the preset standard seal;
[0030] Step S206: Calculate the similarity value between the image of the seal to be verified and the image of the preset standard seal at the target matching angle, and determine the authenticity of the seal to be verified based on the similarity value.
[0031] Through the above steps, a document image uploaded by the target object via an application programming interface (API) is received, wherein the document image contains a seal to be verified. If it is determined that the first contour feature corresponding to the seal to be verified in the document image is similar to the second contour feature corresponding to a preset standard seal, the seal to be verified is rotated multiple times according to a first angular interval to determine a first matching angle between the seal to be verified and the preset standard seal. The first matching angle is adjusted according to a second angular interval to obtain a target matching angle between the seal to be verified and the preset standard seal. The similarity value between the image of the seal to be verified and the image of the preset standard seal at the target matching angle is calculated, and the authenticity of the seal to be verified is determined based on the similarity value. This technical solution solves the problems of complex operation, long processing time, and cumbersome system architecture in electronic seal verification systems on the Web platform. Furthermore, by receiving document images through an API, using contour feature similarity filtering, and combining hierarchical angular rotation matching to determine the optimal matching angle, and then calculating the image similarity after adjusting the angle, efficient online seal authenticity verification is achieved.
[0032] In an exemplary embodiment, determining a first matching angle between the seal to be verified and a preset standard seal by performing multiple rotations on the seal to be verified at first angular intervals includes: calculating the similarity between the image of the seal to be verified and the image of the preset standard seal after each rotation to obtain multiple similarity values; identifying the maximum similarity value among the multiple similarity values and the rotation angle corresponding to the maximum similarity value; and determining the rotation angle as the first matching angle, wherein the first matching angle is the rotation angle corresponding to the seal to be verified after rotating based on its original position at at least one first angular interval.
[0033] Optionally, suppose we need to verify a seal on a document. The image of a standard seal is fixed, while the image of the seal to be verified may have angular deviations due to the actual stamping process. Therefore, we need to find the optimal matching angle to determine the authenticity of the seal. We set the first angle interval to 9 degrees. Starting from 0 degrees, we rotate the image of the seal to be verified every 9 degrees until a 360-degree coverage is achieved. After each rotation, we use an image processing algorithm to calculate the similarity value between the seal image and the standard seal image. Among all the calculated similarity values, we find the maximum value and its corresponding rotation angle. We determine the rotation angle corresponding to the maximum value as the first matching angle. Assume that after the document image is uploaded, the above process is used to perform a rotation matching test on the seal to be verified. Initially, the seal image has not been rotated, and its similarity value with the standard seal is calculated to be 0.6. Then, we rotate the seal image at 9-degree intervals. When rotated to 36 degrees, the calculated similarity value reaches 0.84. Continuing to rotate to 270 degrees, the similarity was calculated again. The similarity value at 270 degrees was found to be 0.89, exceeding all previous values. Therefore, 270 degrees was considered the rotation angle corresponding to the maximum similarity value and was thus determined as the first matching angle. This concrete example demonstrates that even with unknown angular deviations, setting an appropriate first angular interval allows for efficient and accurate finding of the optimal matching angle between two seal images, thereby improving the accuracy and reliability of seal verification.
[0034] In an exemplary embodiment, before determining that the first contour feature corresponding to the seal to be verified in the document image is similar to the second contour feature corresponding to the preset standard seal, and before performing multiple rotation processing on the seal to be verified according to the first angular interval to determine the first matching angle between the seal to be verified and the preset standard seal, the method further includes: determining the first width and first height corresponding to the contour of the seal to be verified in the first contour feature, and determining the second width and second height corresponding to the contour of the preset standard seal in the second contour feature; calculating the first similarity between the first width and the second width, and the second similarity between the first height and the second height; and performing a similarity calculation on the first contour feature and the second contour feature corresponding to the preset standard seal based on the first similarity and the second similarity.
[0035] Optionally, assume there are two images: one is a user-uploaded image of the seal to be verified, and the other is a preset standard seal image. For the seal to be verified (first contour feature), the smallest bounding rectangle of the seal is first extracted to obtain the first width and first height. For the standard seal (second contour feature), the second width and second height of its smallest bounding rectangle are similarly extracted. Next, similarity is calculated: for a document with a resolution of 300 dpi, the proportional difference between the first width and the second width is calculated to obtain the first similarity; similarly, the proportional difference between the first height and the second height is calculated to obtain the second similarity. The final contour matching degree is obtained by averaging these two similarities. If the document resolution is 200 dpi, then when calculating the similarity, the second width and the second height need to be multiplied by 1.5 before proportional comparison to adapt to the resolution change and ensure the fairness of the calculation. In this way, the similarity of the seal contour features can be effectively identified. Even when facing different resolutions and sizes, it can ensure accurate judgment of whether the seal matches the preset standard seal, thereby improving the reliability and applicability of electronic seal verification.
[0036] In an exemplary embodiment, after calculating the similarity between the first contour feature and the second contour feature corresponding to a preset standard seal based on the first similarity and the second similarity, the method further includes: determining whether the first contour feature and the second contour feature are similar based on the relationship between the calculated similarity value and a preset similarity threshold; determining that the first contour feature and the second contour feature are similar if the similarity value is greater than the preset similarity threshold; and determining that the first contour feature and the second contour feature are not similar if the similarity value is less than or equal to the preset similarity threshold.
[0037] Optionally, in a practical application, after calculating the contour similarity between the seal to be verified (first contour feature) and the standard seal (second contour feature), it is compared with a preset similarity threshold. Assuming the preset similarity threshold is 0.9 (meaning the width-to-height ratio must be at least 90% similar to be considered a match), specifically, the calculated contour similarity value between the current seal to be verified and the standard seal is compared with the preset similarity threshold. If the similarity value is greater than 0.9, the first contour feature and the second contour feature are determined to be similar. Conversely, if the similarity value is less than or equal to 0.9, the first contour feature and the second contour feature are determined to be dissimilar. For example, in a specific scenario, when the calculated final similarity is 0.92, because this value exceeds the preset threshold of 0.9, the seal to be verified is judged to be similar to the standard seal in contour. Conversely, if the calculated similarity is only 0.85, which does not reach the threshold, the seals are directly determined to be dissimilar, avoiding unnecessary in-depth comparisons and saving processing time and computational resources. With this threshold judgment mechanism, when processing a large number of seal verification requests, it is possible to quickly eliminate those obviously mismatched cases and focus on analyzing potential matching situations, thereby improving the overall seal verification efficiency and accuracy.
[0038] In an exemplary embodiment, after receiving the ticket image uploaded by the target object through the application programming interface, the method further includes: performing color filtering processing on the image of the seal to be verified and the image of the preset standard seal; and determining the red seal area in the image of the seal to be verified and the image of the preset standard seal based on the color filtering processing result.
[0039] Understandably, color filtering is applied to the acquired images of the document to be verified and the standard seal to determine the red seal area. Specifically, the RGB (Red, Green, Blue) images are converted to the HSV (Hue, Saturation, Value) color space. The HSV space makes it easier to distinguish the brightness and saturation of colors, thus effectively identifying the red seal. A threshold range for red in the HSV space is set; for example, the H value of red might range from 0° to 10° or 350° to 360°, while the S (Saturation) and V (Value) values are set according to the characteristics of a typical red seal. By using the threshold segmentation function of an image processing library, regions in both images that conform to the above-mentioned red HSV threshold range are extracted; these regions are the candidate regions for the red seal. Through the above color filtering process, the red seal area in the images of the document to be verified and the preset standard seal can be effectively determined, providing an accurate foundation for subsequent contour feature extraction and similarity comparison. For example, when processing an image of a document containing a red stamp and blue lettering, color filtering ensures that only the red stamp area is analyzed, ignoring the blue lettering and thus avoiding the influence of irrelevant factors on the verification results. In this way, even with complex backgrounds or uneven lighting, stamps can still be accurately identified and compared, improving the accuracy and reliability of verification.
[0040] In one exemplary embodiment, calculating the similarity value between the image of the seal to be verified and the image of a preset standard seal at the target matching angle, and determining the authenticity of the seal to be verified based on the similarity value, includes: determining whether the image matching degree between the seal to be verified and the preset standard seal at the target matching angle reaches a preset authenticity standard based on the similarity value; if the image matching degree reaches the authenticity standard, determining that the seal to be verified is a genuine seal; if the image matching degree does not reach the authenticity standard, determining that the seal to be verified is a counterfeit seal.
[0041] In other words, if the optimal rotation angle for the seal to be verified has been determined to be 60 degrees, then the similarity value between the seal image and a preset standard seal image is calculated at this angle, and the authenticity of the seal is determined based on this value. First, the image of the seal to be verified is rotated by 60 degrees to ensure that the two seal images are in the most matching visual state. Using an image comparison algorithm, the similarity value between the rotated image of the seal to be verified and the standard seal image is calculated. The calculated similarity value is compared with the preset authenticity standard. Assuming the preset authenticity standard similarity threshold is 0.9, if the similarity value is ≥0.9, the seal to be verified is determined to be a genuine seal. If the similarity value is <0.9, the seal to be verified is determined to be a counterfeit seal. If, at the target matching angle of 60 degrees, the similarity value between the seal to be verified and the standard seal is calculated to be 0.87, since 0.87 is less than the preset threshold of 0.9, the seal is immediately determined to be a counterfeit seal. This instant feedback mechanism allows for rapid verification of seals without requiring knowledge of complex image processing. Through these steps, not only can the authenticity of seals be confirmed quickly and accurately, but the entire process is also highly automated, reducing reliance on external factors such as human intervention or unstable service environments, thereby improving the reliability and efficiency of the entire seal verification system.
[0042] To better understand the process of determining the authenticity of the above-mentioned seal, the following description, in conjunction with optional embodiments, further illustrates the process of determining the authenticity of the above-mentioned seal, but is not intended to limit the technical solutions of the embodiments of this application.
[0043] In related technologies, electronic signature verification methods include installing browser plugins, starting local service programs, and relying on backend servers for signature verification. These methods either lead to a decline in user experience, such as the complex plugin installation and local service startup process, which requires a high level of computer operation skills from users; or they increase the complexity of the system architecture and resource consumption, such as the deployment of backend signature verification services, which not only requires additional server resources, but may also affect the use of all users due to concurrency issues or service failures. Overall, these traditional solutions are not user-friendly and have low system efficiency.
[0044] To address the aforementioned issues, this application proposes an optional embodiment of a web-based seal verification algorithm and optimization method. This method directly processes the uploaded document image in a web environment. First, it extracts the contour features of the seal to be verified from the image. Then, it compares the similarity of the contour features with those of a pre-stored standard seal. After confirming a basic contour match, it further performs angle matching to correct for any possible rotational deviations in the seal. Finally, it determines the authenticity of the seal based on the angle matching result.
[0045] Optional, Figure 3This is a flowchart of a web-based signature verification algorithm according to an embodiment of this application, specifically including the following steps:
[0046] Step 1: Image Reception and Preprocessing. The input to this seal verification algorithm is a pre-reserved seal image and an image of the document to be verified. The images are compressed using the cv.resize method of openCV.js, i.e., the width and height of pixels are reduced, which reduces the amount of computation required for subsequent similarity calculations and optimizes the algorithm's time consumption.
[0047] Optionally, the `cv.resize` method is a feature in the OpenCV.js image processing library used to resize images. This method can change the width and height of an image and is typically used in the image preprocessing stage, such as when performing image analysis or computer vision tasks, to speed up processing or reduce computational resource consumption by scaling the image to a smaller size.
[0048] Step Two: Color Space Conversion and Filtering. The specific steps are as follows:
[0049] Step 1: Convert the image from the RGBA (Red Green Blue Alpha) color space to the HSV color space to extract red more accurately.
[0050] Step 2: Convert the image in HSV color space back to grayscale and compress the image data again to reduce computation and optimize algorithm time.
[0051] Step 3: Contour Feature Extraction and Similarity Calculation. The `cv.findContours` method of OpenCV.js is used to extract the graphic contours from the seal image and the ticket image respectively. Then, the `cv.minArecRect` method is used to extract the minimum bounding rectangle of the contour. Finally, the similarity of the minimum bounding rectangles is calculated as the contour similarity. The algorithm for calculating contour similarity is as follows:
[0052] Optionally, the `cv.findContours` method is a powerful tool in the OpenCV library for image processing and computer vision, primarily used to detect and draw the contours of objects from binary images. The `cv.minArecRect` method is used to find the minimum bounding box (minimum enclosing rectangle) of a set of points or contours in an image.
[0053] (1) Size acquisition. Obtain the width and height of the two smallest bounding rectangles respectively. Since rotation may cause the width and height to be interchanged, take the minimum and maximum values of the width and height of the smallest bounding rectangle to ensure the correct size comparison.
[0054] (2) Ratio Calculation. For two different resolution ticket images (300dpi and 200dpi), at 300dpi, calculate the width ratio (widthRatio300) and height ratio (heightRatio300) of the two contours. At 200dpi, since the standard seal is prepared according to 300dpi, the ticket size of 200dpi needs to be enlarged by 1.5 times before calculating the ratio to obtain widthRatio200 and heightRatio200.
[0055] (3) Similarity assessment. The average ratio is used as the similarity index. For a 300dpi ticket image, the similarity 300 is (widthRatio300+heightRatio300) / 2. For a 200dpi ticket image, the similarity 200 is (widthRatio200+heightRatio200) / 2.
[0056] (4) Threshold Comparison and Result Output. The similarity threshold is set to 0.9. If either similarity300 or similarity200 is greater than 0.9, the contours are considered similar. The specific output result is encoded as follows:
[0057] If the similarity at 300dpi is greater than 0.9, then return 1, indicating that the contours are similar under the 300dpi condition.
[0058] If the similarity at 200dpi is greater than 0.9, then return 2, indicating that the contours are similar at 200dpi.
[0059] The specific pseudocode example of the algorithm is as follows:
[0060] Javascript
[0061] function compareRectSimilarity(rect1, rect2,dpi){const size1=rect1.size;
[0062] const size2 = rect2.size;
[0063] Let widthRatio and heightRatio;
[0064] if(dpi===300){widthRatio=Math.min(size1.width,size2.width) / Math.max(size1.width, size2.width);
[0065] heightRatio=Math.min(size1.height,size2.height) / Math.max(size1.height,size2.height)};
[0066] else if (dpi === 200) {
[0067] widthRatio=Math.min(size1.width,size2.width×1.5) / Math.max(size1.width,size2.width×1.5);
[0068] heightRatio=Math.min(size1.height,size2.height×1.5) / Math.max(size1.height, size2.height×1.5)};
[0069] const similarity=(widthRatio+heightRatio) / 2;
[0070] if(similarity>0.9){if(dpi===300){return 1};
[0071] else if(dpi===200){return 2};
[0072] return 0;
[0073] }".
[0074] It should be noted that in the algorithm for calculating contour similarity described above, rect1 and rect2 represent the smallest bounding rectangles of the standard seal and the seal on the document, respectively, and the dpi parameter is used to specify the resolution of the document. This implementation method allows for accurate determination of seal contour similarity even when considering different document resolutions.
[0075] Step 4: Angle Matching Optimization. If the outlines of the standard stamp and the stamp on the ticket are similar, the next step is to compare the similarity of the image content within the outlines. Since the stamp on the ticket is left by the user, the angle may differ from the pre-reserved stamp image angle. Therefore, it's necessary to continuously rotate the stamp image and use the `cv.matchTemplate` method from OpenCV.js to calculate the matching similarity between the rotated stamp image and the ticket image. Considering that a certain range of angles with optimal rotation will yield a relatively high similarity, an optimization approach of initial roughing followed by local refinement can be used. This avoids comparing every degree of rotation, reducing the need for 360 comparisons. The specific algorithm pseudocode is as follows:
[0076] "var maxSimilarResult=-Infinity / / Maximum similarity;
[0077] var tempAngle / / Temporary angle variable;
[0078] var betterAngle / / Preliminary optimal angle;
[0079] var bestAnger / / Calculates the final optimal angle;
[0080] var sealImg / / Image of a seal;
[0081] var voucherImg / / Image of the voucher;
[0082] for(tempAngle=0;tempAngle<360;tempAngle+=9){ / / Calculate the initial optimal angle;
[0083] const similarResult=cv.matchTemplate(sealImg,voucherImg);
[0084] if(similarResult>maxSimilarResult){maxSimilarResult=similarResult;
[0085] betterAngle=tempAngle;} / / Calculate the refined optimal angle;
[0086] for(tempAngle=betterAngle-4;tempAngle <betterAngle+4;tempAngle+=1){
[0087] const similarResult=cv.matchTemplate(sealImg,voucherImg);
[0088] if(similarResult>maxSimilarResult){
[0089] maxSimilarResult=similarResult;
[0090] bestAngle=tempAngle;}
[0091] }".
[0092] With the above optimization algorithm, the optimal angle can be found in just 49 rotations.
[0093] Step 5: Registration Image Synthesis and Authenticity Determination. Authenticity determination is based on the synthesized registration image. The authenticity of the seal is determined by evaluating the consistency of its outline, details, position, and angle. Specifically, based on the optimal rotation angle and displacement, image processing techniques are used to transform the image of the seal to be verified, overlapping it with a preset standard seal image to form a registration image. After the registration image is generated, the similarity between the registered seal to be verified and the standard seal is calculated again. Finally, based on the similarity evaluation after registration, it is compared with a preset authenticity decision threshold. If the similarity is higher than the preset threshold, the seal to be verified is determined to be genuine; otherwise, it is determined to be counterfeit or a seal that does not meet the standard.
[0094] In summary, this application preprocesses and extracts features from images using image processing technology, calculates the matching of seals using contour similarity, and employs optimized rotation and displacement algorithms to quickly locate the best matching state of the seal. This achieves an efficient seal verification process that requires no plugins, local services, or backend support, significantly improving the user experience and ease of use of the system.
[0095] Through the above description of the embodiments, those skilled in the art can clearly understand that the method for determining the authenticity of a seal according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platform. Of course, it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software device. This computer software device is stored in a storage medium (such as ROM / RAM, disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the method for determining the authenticity of a seal according to the various embodiments of this application.
[0096] This embodiment also provides an execution device for determining the authenticity of a seal. This device is used to implement the above embodiments and preferred embodiments, and details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0097] Figure 4 This is a structural block diagram of a device for determining the authenticity of a seal according to an embodiment of this application; as shown below. Figure 4 As shown, it includes:
[0098] Receiving module 42 is used to receive a ticket image uploaded by the target object through the application programming interface, wherein the ticket image contains a seal to be verified;
[0099] Processing module 44 is used to perform multiple rotations on the seal to be verified according to a first angle interval when it is determined that the first contour feature corresponding to the seal to be verified in the document image is similar to the second contour feature corresponding to the preset standard seal, thereby determining the first matching angle between the seal to be verified and the preset standard seal.
[0100] The adjustment module 46 is used to adjust the first matching angle according to the second angle interval to obtain the target matching angle between the seal to be verified and the preset standard seal.
[0101] The calculation module 48 is used to calculate the similarity value between the image of the seal to be verified and the image of the preset standard seal at the target matching angle, and to determine the authenticity of the seal to be verified based on the similarity value.
[0102] The above-described device receives a document image uploaded by a target object via an application programming interface (API), wherein the document image contains a seal to be verified. If it is determined that the first contour feature corresponding to the seal to be verified in the document image is similar to the second contour feature corresponding to a preset standard seal, the seal to be verified is rotated multiple times according to a first angular interval to determine a first matching angle between the seal to be verified and the preset standard seal. The first matching angle is adjusted according to a second angular interval to obtain a target matching angle between the seal to be verified and the preset standard seal. The similarity value between the image of the seal to be verified and the image of the preset standard seal at the target matching angle is calculated, and the authenticity of the seal to be verified is determined based on the similarity value. This technical solution solves the problems of complex operation, long processing time, and cumbersome system architecture in electronic seal verification systems on the Web platform. Furthermore, by receiving document images through an API, using contour feature similarity filtering, and combining hierarchical angular rotation matching to determine the optimal matching angle, and then calculating the image similarity after adjusting the angle, efficient online seal authenticity verification is achieved.
[0103] In an exemplary embodiment, the above-described processing module is further configured to calculate the similarity between the image of the seal to be verified and the image of a preset standard seal after each rotation, and obtain multiple similarity values; identify the maximum similarity value among the multiple similarity values, and the rotation angle corresponding to the maximum similarity value; and determine the rotation angle as a first matching angle, wherein the first matching angle is the rotation angle corresponding to the seal to be verified after rotating based on the original position at at least one first angular interval.
[0104] In an exemplary embodiment, the above-described apparatus further includes: a first determining module, configured to, when determining that a first contour feature corresponding to a seal to be verified in a document image is similar to a second contour feature corresponding to a preset standard seal, perform multiple rotation processing on the seal to be verified at a first angular interval before determining a first matching angle between the seal to be verified and the preset standard seal, determine a first width and a first height corresponding to the contour of the seal to be verified in the first contour feature, and determine a second width and a second height corresponding to the contour of the preset standard seal in the second contour feature; calculate a first similarity between the first width and the second width, and a second similarity between the first height and the second height; and perform a similarity calculation on the first contour feature and the second contour feature corresponding to the preset standard seal based on the first similarity and the second similarity.
[0105] In an exemplary embodiment, the first determining module further includes: a determining unit, configured to, after calculating the similarity between the first contour feature and the second contour feature corresponding to the preset standard seal based on the first similarity and the second similarity, determine whether the first contour feature and the second contour feature are similar based on the relationship between the calculated similarity value and the preset similarity threshold; if the similarity value is greater than the preset similarity threshold, determine that the first contour feature and the second contour feature are similar; if the similarity value is less than or equal to the preset similarity threshold, determine that the first contour feature and the second contour feature are not similar.
[0106] In one exemplary embodiment, the above apparatus further includes: a second determining module, wherein after the user receives the ticket image uploaded by the target object through the application programming interface, the user performs color filtering processing on the image of the seal to be verified and the image of the preset standard seal; and determines the red seal area in the image of the seal to be verified and the image of the preset standard seal based on the color filtering processing result.
[0107] In an exemplary embodiment, the above-mentioned calculation module is further configured to determine whether the image matching degree between the seal to be verified and the preset standard seal at the target matching angle reaches the preset authenticity standard based on the similarity value; if the image matching degree reaches the authenticity standard, the seal to be verified is determined to be a genuine seal; if the image matching degree does not reach the authenticity standard, the seal to be verified is determined to be a counterfeit seal.
[0108] Embodiments of this application also provide a storage medium including a stored program, wherein the program, when executed, performs any of the methods for determining the authenticity of a seal.
[0109] Optionally, in this embodiment, the storage medium may be configured to store program code for performing the following steps:
[0110] S1, Receive a ticket image uploaded by the target object through the application programming interface, wherein the ticket image contains a seal to be verified;
[0111] S2, when it is determined that the first contour feature corresponding to the seal to be verified in the bill image is similar to the second contour feature corresponding to the preset standard seal, the seal to be verified is rotated multiple times according to the first angle interval to determine the first matching angle between the seal to be verified and the preset standard seal.
[0112] S3, adjust the first matching angle according to the second angle interval to obtain the target matching angle between the seal to be verified and the preset standard seal;
[0113] S4, calculate the similarity value between the image of the seal to be verified and the image of the preset standard seal at the target matching angle, and determine the authenticity of the seal to be verified based on the similarity value.
[0114] Embodiments of this application also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0115] Embodiments of this application also provide a computer program product, including a computer program, wherein the computer program, when executed by a processor, performs the steps in any of the above method embodiments.
[0116] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0117] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0118] S1, Receive a ticket image uploaded by the target object through the application programming interface, wherein the ticket image contains a seal to be verified;
[0119] S2, when it is determined that the first contour feature corresponding to the seal to be verified in the bill image is similar to the second contour feature corresponding to the preset standard seal, the seal to be verified is rotated multiple times according to the first angle interval to determine the first matching angle between the seal to be verified and the preset standard seal.
[0120] S3, adjust the first matching angle according to the second angle interval to obtain the target matching angle between the seal to be verified and the preset standard seal;
[0121] S4, calculate the similarity value between the image of the seal to be verified and the image of the preset standard seal at the target matching angle, and determine the authenticity of the seal to be verified based on the similarity value.
[0122] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical discs.
[0123] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated here.
[0124] The collection, storage, use, processing, transmission, provision, and disclosure of financial data or user data involved in the technical solution of this application all comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0125] It should be noted that in the embodiments of this application, certain software, components, models and other existing solutions in the industry may be mentioned. These should be regarded as exemplary and are only intended to illustrate the feasibility of implementing the technical solution of this application. However, it does not mean that the applicant has used or necessarily used the solution.
[0126] Obviously, those skilled in the art should understand that the modules or steps of this application described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those presented here, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, this application is not limited to any particular combination of hardware and software.
[0127] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for determining the authenticity of a seal, characterized in that, include: Receive a ticket image uploaded by the target object through an application programming interface, wherein the ticket image contains a seal to be verified; If it is determined that the first contour feature corresponding to the seal to be verified in the document image is similar to the second contour feature corresponding to the preset standard seal, the seal to be verified is rotated multiple times according to the first angle interval to determine the first matching angle between the seal to be verified and the preset standard seal. The first matching angle is adjusted according to the second angle interval to obtain the target matching angle between the seal to be verified and the preset standard seal; Calculate the similarity value between the image of the seal to be verified and the image of the preset standard seal at the target matching angle, and determine the authenticity of the seal to be verified based on the similarity value.
2. The method for determining the authenticity of a seal according to claim 1, characterized in that, The seal to be verified is rotated multiple times according to a first angular interval to determine a first matching angle between the seal to be verified and the preset standard seal, including: Calculate the similarity between the image of the seal to be verified and the image of the preset standard seal after each rotation to obtain multiple similarity values; Identify the maximum similarity value among the plurality of similarity values, and the rotation angle corresponding to the maximum similarity value; The rotation angle is determined as the first matching angle, wherein the first matching angle is the rotation angle corresponding to the stamp to be verified after rotating at least one first angular interval based on the original position.
3. The method for determining the authenticity of a seal according to claim 1, characterized in that, Before determining that the first contour feature corresponding to the seal to be verified in the document image is similar to the second contour feature corresponding to a preset standard seal, and before performing multiple rotations on the seal to be verified according to a first angular interval to determine the first matching angle between the seal to be verified and the preset standard seal, the method further includes: Determine the first width and first height corresponding to the outline of the seal to be verified in the first outline feature, and determine the second width and second height corresponding to the outline of the preset standard seal in the second outline feature; Calculate a first similarity between the first width and the second width, and a second similarity between the first height and the second height; The similarity between the first contour feature and the second contour feature corresponding to the preset standard seal is calculated based on the first similarity and the second similarity.
4. The method for determining the authenticity of a seal according to claim 3, characterized in that, After calculating the similarity between the first contour feature and the second contour feature corresponding to the preset standard seal based on the first similarity and the second similarity, the method further includes: The similarity between the first contour feature and the second contour feature is determined based on the relationship between the calculated similarity value and the preset similarity threshold. If the similarity value is greater than the preset similarity threshold, the first contour feature is determined to be similar to the second contour feature. If the similarity value is less than or equal to the preset similarity threshold, it is determined that the first contour feature and the second contour feature are not similar.
5. The method for determining the authenticity of a seal according to claim 1, characterized in that, After receiving the ticket image uploaded by the target object through the application programming interface, the method further includes: Color filtering is applied to the image of the seal to be verified and the image of the preset standard seal. The red stamp area in the image of the stamp to be verified and the image of the preset standard stamp are determined based on the color filtering processing results.
6. The method for determining the authenticity of a seal according to claim 1, characterized in that, Calculating the similarity value between the image of the seal to be verified and the image of the preset standard seal at the target matching angle, and determining the authenticity of the seal to be verified based on the similarity value, includes: Based on the similarity value, determine whether the image matching degree between the seal to be verified and the preset standard seal at the target matching angle reaches the preset authenticity standard; If the image matching degree meets the authenticity standard, the seal to be verified is determined to be a genuine seal. If the image matching degree does not meet the authenticity standard, the seal to be verified is determined to be a counterfeit seal.
7. A device for determining the authenticity of a seal, characterized in that, include: The receiving module is used to receive a ticket image uploaded by the target object through the application programming interface, wherein the ticket image contains a seal to be verified. The processing module is used to determine the first matching angle between the seal to be verified and the preset standard seal by performing multiple rotations on the seal to be verified according to a first angle interval when it is determined that the first contour feature corresponding to the seal to be verified in the document image is similar to the second contour feature corresponding to the preset standard seal. An adjustment module is used to adjust the first matching angle according to a second angle interval to obtain the target matching angle between the seal to be verified and the preset standard seal. The calculation module is used to calculate the similarity value between the image of the seal to be verified and the image of the preset standard seal at the target matching angle, and to determine the authenticity of the seal to be verified based on the similarity value.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, it implements the steps of the method for determining the authenticity of a seal as described in any one of claims 1 to 6.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method for determining the authenticity of a seal as described in any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the method for determining the authenticity of a seal as described in any one of claims 1 to 6.