CN116416626B - Method, device, equipment and storage medium for acquiring circular seal data - Google Patents

Method, device, equipment and storage medium for acquiring circular seal data Download PDF

Info

Publication number
CN116416626B
CN116416626B CN202310684211.0A CN202310684211A CN116416626B CN 116416626 B CN116416626 B CN 116416626B CN 202310684211 A CN202310684211 A CN 202310684211A CN 116416626 B CN116416626 B CN 116416626B
Authority
CN
China
Prior art keywords
seal
image
circular
coordinates
circular seal
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202310684211.0A
Other languages
Chinese (zh)
Other versions
CN116416626A (en
Inventor
孙铁
王琳婧
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Bank Co Ltd
Original Assignee
Ping An Bank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Bank Co Ltd filed Critical Ping An Bank Co Ltd
Priority to CN202310684211.0A priority Critical patent/CN116416626B/en
Publication of CN116416626A publication Critical patent/CN116416626A/en
Application granted granted Critical
Publication of CN116416626B publication Critical patent/CN116416626B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/10Character recognition
    • G06V30/18Extraction of features or characteristics of the image
    • G06V30/186Extraction of features or characteristics of the image by deriving mathematical or geometrical properties from the whole image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/82Arrangements for image or video recognition or understanding using pattern recognition or machine learning using neural networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/10Character recognition
    • G06V30/14Image acquisition
    • G06V30/1444Selective acquisition, locating or processing of specific regions, e.g. highlighted text, fiducial marks or predetermined fields
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/10Character recognition
    • G06V30/14Image acquisition
    • G06V30/146Aligning or centring of the image pick-up or image-field
    • G06V30/1465Aligning or centring of the image pick-up or image-field by locating a pattern
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/10Character recognition
    • G06V30/14Image acquisition
    • G06V30/146Aligning or centring of the image pick-up or image-field
    • G06V30/147Determination of region of interest
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/10Character recognition
    • G06V30/18Extraction of features or characteristics of the image
    • G06V30/1801Detecting partial patterns, e.g. edges or contours, or configurations, e.g. loops, corners, strokes or intersections
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/10Character recognition
    • G06V30/18Extraction of features or characteristics of the image
    • G06V30/18105Extraction of features or characteristics of the image related to colour
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/10Character recognition
    • G06V30/19Recognition using electronic means
    • G06V30/191Design or setup of recognition systems or techniques; Extraction of features in feature space; Clustering techniques; Blind source separation
    • G06V30/19107Clustering techniques
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/30Computing systems specially adapted for manufacturing

Landscapes

  • Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Computation (AREA)
  • Mathematical Physics (AREA)
  • Computing Systems (AREA)
  • Mathematical Optimization (AREA)
  • Mathematical Analysis (AREA)
  • Algebra (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Pure & Applied Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Medical Informatics (AREA)
  • Software Systems (AREA)
  • Collating Specific Patterns (AREA)
  • Image Analysis (AREA)

Abstract

The application discloses a method, a device, equipment and a storage medium for acquiring circular seal data, wherein the method comprises the following steps: acquiring a seal image containing a circular seal; positioning each corner of the five-pointed star positioned in the middle area of the circular seal to obtain the corner area coordinate of each corner; and calculating the coordinates of the central point of the circular seal according to the coordinates of the corner areas of all corners. According to the characteristic that the center point of the circular seal with the five-pointed star is positioned in the five-pointed star, the five corners of the five-pointed star are positioned, and the coordinates of the center point of the circular seal are positioned according to the coordinates of the corner areas of the five corners, so that the method can realize the accurate positioning of relevant data such as the center point of the circular seal on the circular seal image with any size and any inclination degree and with any size without being influenced by the inclination degree of the picture and the size of the circular seal, and has small deviation and high accuracy.

Description

Method, device, equipment and storage medium for acquiring circular seal data
Technical Field
The present application relates to the field of image processing technologies, and in particular, to a method, an apparatus, a device, and a storage medium for acquiring circular seal data.
Background
In the financial fields of banks, insurance and the like, more auditing and approval links exist, wherein the identification of enterprise seals or personal seals in user data is one of important links. The premise of identifying the text in the seal is that the related data of the seal can be accurately positioned. In the prior art, when related data of a seal in an image is acquired, the seal is usually detected firstly, but errors exist in detection due to factors such as large image, small seal and the like, the obtained result is that a real seal is not necessarily completely attached to the detected image, and any one of possible angle deviation exists between the upper part, the lower part, the left part and the right part, so that the related data such as the center or the radius of the seal is difficult to determine.
Disclosure of Invention
The application mainly aims to provide a method, a device, equipment and a storage medium for acquiring circular seal data, which can solve the technical problem of inaccurate positioning of related data such as the center of a seal in a seal image in the prior art.
To achieve the above object, a first aspect of the present application provides a method for acquiring circular seal data, the method comprising:
acquiring a seal image containing a circular seal;
Positioning each corner of the five-pointed star positioned in the middle area of the circular seal to obtain the corner area coordinate of each corner;
and calculating the coordinates of the central point of the circular seal according to the coordinates of the corner areas of all corners.
In order to achieve the above object, a second aspect of the present application provides an apparatus for acquiring circular seal data, comprising:
the image acquisition module is used for acquiring a seal image containing a circular seal;
the pentagonal detection module is used for positioning each corner of the pentagon located in the middle area of the circular seal to obtain the corner area coordinate of each corner;
and the center point determining module is used for calculating the center point coordinates of the circular seal according to the corner region coordinates of all the corners.
To achieve the above object, a third aspect of the present application provides a computer-readable storage medium storing a computer program which, when executed by a processor, causes the processor to perform the steps of:
acquiring a seal image containing a circular seal;
positioning each corner of the five-pointed star positioned in the middle area of the circular seal to obtain the corner area coordinate of each corner;
and calculating the coordinates of the central point of the circular seal according to the coordinates of the corner areas of all corners.
To achieve the above object, a fourth aspect of the present application provides a computer apparatus including a memory and a processor, the memory storing a computer program which, when executed by the processor, causes the processor to perform the steps of:
Acquiring a seal image containing a circular seal;
positioning each corner of the five-pointed star positioned in the middle area of the circular seal to obtain the corner area coordinate of each corner;
and calculating the coordinates of the central point of the circular seal according to the coordinates of the corner areas of all corners.
The embodiment of the application has the following beneficial effects:
according to the characteristic that the center point of the circular seal with the five-pointed star is positioned in the five-pointed star, the five corners of the five-pointed star are positioned, and the coordinates of the center point of the circular seal are positioned according to the coordinates of the corner areas of the five corners, so that the circular seal center point can be accurately positioned without being influenced by the inclination degree of the picture and the size of the circular seal, and the circular seal image with any size and any inclination degree can be accurately positioned.
Drawings
In order to more clearly illustrate the embodiments of the application or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
wherein :
FIG. 1 is a flowchart of a method for acquiring circular seal data according to an embodiment of the present application;
FIG. 2 is an effect diagram of a circular stamp according to an embodiment of the present application;
FIG. 3 is a diagram showing the effect of tilting a circular stamp according to an embodiment of the present application;
FIG. 4 is a schematic effect diagram of processing a circular stamp according to an embodiment of the present application;
FIG. 5 is a block diagram illustrating a circular stamp data acquisition apparatus according to an embodiment of the present application;
fig. 6 is a block diagram of a computer device in an embodiment of the application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The method for acquiring the circular seal data is applied to a system for acquiring the circular seal data. The circular seal data acquisition system can be installed in a desk terminal or a mobile terminal or a server. The mobile terminal can be at least one of a mobile phone, a tablet computer, a notebook computer and the like. The server may be implemented as a stand-alone server or as a server cluster composed of a plurality of servers.
In one embodiment, as shown in fig. 1, a method for acquiring circular seal data is provided. The method is applied to a computer device. The method for acquiring the circular seal data specifically comprises the following steps:
s100: and obtaining a seal image containing the circular seal.
Specifically, the seal image comprises a circular seal, a five-pointed star is arranged in the middle of the circular seal, and surrounding seal characters are distributed on the periphery of the five-pointed star.
S200: and positioning each corner of the five-pointed star positioned in the middle area of the circular seal to obtain the corner area coordinate of each corner.
Specifically, each corner of the five-pointed star in the middle of the circular stamp can be located by a target detection method. The angular region coordinates are the minimum x-coordinate xmin, the minimum y-coordinate ymen, the maximum x-coordinate xmax, and the maximum y-coordinate ymax of a small region (angular region) including one angle. That is, the polar coordinates are expressed as: (xmin, xmax, ymax).
Alternatively, the angular region coordinates are the center coordinates (x_center, y_center) of a small region (angular region) including one angle, and the width w and the height h of this angular region. That is, the center point coordinates are expressed as: (x_center, y_center, w, h).
The corner region including a corner may be a rectangular region or a rectangular frame.
S300: and calculating the coordinates of the central point of the circular seal according to the coordinates of the corner areas of all corners.
Specifically, the angular region coordinates are represented by polar coordinates as an example. The point coordinates of this angle are calculated from the minimum x-coordinate xmin, the minimum y-coordinate ymin, the maximum x-coordinate xmax, and the maximum y-coordinate ymax contained in the angular region coordinates.
For example, the point coordinates of the five angles are (x 1, y 1), (x 2, y 2), (x 3, y 3), (x 4, y 4), (x 5, y 5), respectively.
Wherein xmin1, xmax1, ymin1, ymax1 are the minimum x-coordinate, the maximum x-coordinate, the minimum y-coordinate, and the maximum y-coordinate of the first angle, respectively.
Wherein xmin2, xmax2, ymin2, ymax2 are the minimum x-coordinate, the maximum x-coordinate, the minimum y-coordinate, and the maximum y-coordinate, respectively, of the second angle.
Wherein xmin3, xmax3, ymin3, ymax3 are the minimum x-coordinate, the maximum x-coordinate, the minimum y-coordinate, and the maximum y-coordinate of the third angle, respectively.
Wherein xmin4, xmax4, ymin4, ymax4 are the minimum x-coordinate, the maximum x-coordinate, the minimum y-coordinate, and the maximum y-coordinate of the fourth angle, respectively.
Wherein xmin5, xmax5, ymin5, ymax5 are the minimum x-coordinate, the maximum x-coordinate, the minimum y-coordinate, and the maximum y-coordinate of the fifth angle, respectively.
Taking the angular region coordinates as an example represented by the center point coordinates, the point coordinates of the five angles are (x_center, y_center) in the corresponding center point coordinate representation.
The calculation formula of the center point coordinate o (x 0, y 0) of the circular seal is as follows:
wherein, the central point of circular seal is located inside the five-pointed star.
According to the characteristic that the center point of the circular seal with the five-pointed star is positioned in the five-pointed star, the five corners of the five-pointed star are positioned, and the coordinates of the center point of the circular seal are positioned according to the coordinates of the corner areas of the five corners, so that the circular seal can be accurately positioned without being influenced by the inclination degree of the picture and the size of the circular seal, and the circular seal image with any size and any inclination degree can be accurately positioned.
In one embodiment, after obtaining the center point coordinates, the method further comprises:
calculating the distance from the center point of the circular seal to any one corner of the five-pointed star according to the center point coordinates and the corner region coordinates; calculating the radius of the circular seal according to preset seal design parameters, five-pointed star design parameters and distances;
or ,
calculating the distance from the center point of the circular seal to each corner of the five-pointed star according to the center point coordinates and the corner region coordinates; solving a distance average value of the obtained five distances; calculating the radius of the circular seal according to preset seal design parameters, five-pointed star design parameters and a distance average value;
The seal design parameter is a round seal design diameter, and the five-pointed star design parameter is a design diameter of a minimum circumcircle of the five-pointed star; or the seal design parameter is a round seal design radius, and the five-pointed star design parameter is a design radius of the minimum circumcircle of the five-pointed star.
Specifically, the distance from the center point of the circular seal to each corner of the five-pointed star is calculated, namely, the distance from the center point of the circular seal to the point coordinates of each corner is calculated, and the calculation of the distance is calculated by the following formula:
the radius of the circular seal is calculated by the following formula:
wherein R is the radius of the circular seal, a is the design parameter of the seal, b is the design parameter of the five-pointed star, L is the distance (one of Lc1, lc2, lc3, lc4 and Lc 5) from the center point of the circular seal to any one of the five-pointed star angles, or L is the average value (average value of Lc1, lc2, lc3, lc4 and Lc 5) from the center point of the circular seal to the five-pointed star angles.
The diameter of a common round seal is 4.2cm according to the design specification of the seal real object, the diameter of the minimum circumcircle of the five-pointed star is 1.4cm, and the condition that the diameter of the seal is designed to be 3.8cm also exists. Optionally, the ratio of the stamp diameter to the minimum circumcircle diameter of the five-pointed star is selected to be the largest.
In the prior art, the seal image may be inclined, and the angle is calculated by traversing pixels to obtain the text region at present on the aspect of obtaining the rotation angle or deflection angle of the seal, and usually, serious deviation exists.
In one embodiment, after obtaining the circular seal radius, the method further comprises:
detecting and positioning a text area of each character in the circular seal;
the pixels of all the text areas are covered in the same color;
cutting the seal image to obtain a circular image containing all text areas, wherein the radius of the circular image is not larger than the radius of the circular seal;
converting the circular image into a gray image, and performing binarization processing to obtain a binarized image;
determining a target pixel point and pixel values and coordinates of the target pixel point on a circle formed by traversing the radius by taking the central point as the circle center in the binarized image based on a preset traversing rule;
grouping the target pixel points according to the pixel values of the target pixel points to obtain pixel point groups which are continuous and have the target pixel values, wherein the grouping number of the pixel point groups is related to the type of the circular seal;
and calculating the deflection angle of the seal image according to the coordinates of the first target pixel point and the last target pixel point in any pixel point group and the radius of the circular seal.
Specifically, the characters in the circular seal can comprise Chinese characters, letters, numbers and the like, and a certain interval exists between the characters. In addition, according to the design specification of the circular seal, the characters in the circular seal encircle the five-pointed star, but do not completely seal the five-pointed star in the characters, but rather, certain white remains (namely, the partial area of the periphery of the five-pointed star is free of characters). FIG. 2 is an effect diagram of a circular stamp according to an embodiment of the present application; referring to fig. 2, there is a piece of character-free area directly under the five-pointed star of the circular stamp a, and there is a piece of character-free area respectively under the five-pointed star of the circular stamp B at the left and right. Of course, fig. 2 is merely illustrative of the differences in character-free areas of different circular stamps. The application is suitable for circular seal images with various different designs, and is not limited to the application.
If the circular seal picture is not inclined, the character-free area is not inclined; conversely, if the circular stamp picture is tilted, the character-free region is tilted accordingly. Referring specifically to fig. 3, the effect diagram of the inclination of the circular seal a and the circular seal B is shown.
Based on the above, the embodiment finds the character-free area in the circular seal by traversing the pixel points, and determines the deflection angle of the circular seal according to the character-free area.
In a specific embodiment, each character in the circular seal can be positioned by a target detection method, and a text area corresponding to each character is obtained. The text region of each character may be a rectangular box.
FIG. 4 is a schematic effect diagram of processing a circular stamp according to an embodiment of the present application; referring to fig. 4, 5 corners of the five-pointed star in the circular stamp are positioned to obtain corner regions of 5 corners. And positioning each character to obtain a text region of each character. In fig. 4, both the corner area and the text area are indicated by dashed boxes.
The same color coverage is performed on all the text areas, specifically, the text areas are filled with the same color, so that pixels of the text areas are all the same color. For example, since a seal is generally red, a text region can be filled with red, and the RGB of a pixel in the text region is (255, 0).
Other colors may of course be used to cover the text region, as the application is not limited in this regard. However, it is necessary to ensure that the pixels of the text region in the binarized image are different in color from the pixels of the character-free region after the text region is subjected to the same color coverage and then binarized.
And after the same-color coverage is completed, cutting the seal image to obtain a circular image containing all text areas.
The circular image may be the smallest circumscribed circle containing all text regions, as shown in fig. 4, with a radius Rc. In this case, the stamp image may be cut out in close contact with the text region.
Optionally, rc is greater than or equal to 3/4R, less than or equal to 12/13R.
Alternatively, the radius of the circular image Rc may be 5/6R.
After cutting, converting the circular image into a gray image, and then performing binarization processing to obtain a binarized image containing black and white. The color of the pixels of the character-free region in this binarized image is different from the color of the pixels of the text region. Therefore, the character area and blank non-character pixel points can be effectively distinguished.
In a specific embodiment, the binarization process may be implemented by the following steps: after converting the cut circular image into a gray image, traversing each wide and high pixel, converting pixel points smaller than 200 pixel values into black, namely 0 pixel value, converting pixel points larger than or equal to 200 pixel values into white, namely 255 pixel value, and obtaining a binary image with only pure white and pure black. Of course, this embodiment is only an exemplary binarization processing manner, and the present application is not limited to other binarization processing methods.
And forming a circle on the binarized image by using the center point of the circular seal as the circle center and the traversing radius Rb smaller than the radius Rc of the circular image. With particular reference to fig. 4. Alternatively, the circle formed by traversing radius Rb passes through all text regions.
And finding a plurality of target pixel points on the circumference formed by the traversing radius Rb through a preset traversing rule, and obtaining the pixel value of each target pixel point, wherein the target pixel points are all the pixel points on the circumference.
In addition, the pixel points on the traversing circumference can be traversed clockwise or counterclockwise, which is not limited by the application. The target pixel points traversed successively are also arranged or stored according to the traversing sequence.
Some of the target pixel points are black, and some of the target pixel points are white. The color of the target pixel points belonging to the text region on the circumference is different from that of the target pixel points belonging to the character-free region. Our goal is to find consecutive target pixels on the circumference that belong to the character-free region. However, since there is a gap between characters, the pixel value of the target pixel point located in the gap between adjacent text regions is the same as the pixel value of the pixel point of the character-free region, and therefore, the gap needs to be eliminated.
Based on the above, all the target pixels are grouped according to the pixel values and the continuity, and the continuous target pixels with the pixel values being the target pixel values are grouped into one group, so as to obtain the pixel grouping. The target pixel value, that is, the pixel value of the pixel point of the character-free region, is different from the pixel value of the pixel point of the character region. The pixel point groupings may include one or more. The number of groupings of pixel groupings is related to the type of circular stamp. As shown in fig. 3, if the stamp a is circular, the number of groups of pixel points is one. If the stamp B is a circular stamp, the grouping number of the pixel points is 2.
The deflection angle of the seal image can be calculated by using any pixel point group if the seal image is inclined whether the seal image is a circular seal A or a circular seal B.
The first target pixel point and the last target pixel point in this embodiment are the first traversed target pixel point and the last traversed target pixel point in the same pixel point group.
According to the coordinates of the first target pixel point, the coordinates of the last target pixel point and the circular seal radius R in the same pixel point group, the deflection angle of the seal image can be calculated.
According to the embodiment, pixel-level accurate coverage is performed on each character area in the seal, the initial character position and the end position are accurately judged, the character-free area is found, and the deflection angle of the seal is accurately calculated according to the character-free area.
In one embodiment, grouping the target pixels according to the pixel values of the target pixels to obtain pixel groups with continuous target pixels and target pixel values, including:
grouping the continuous target pixel points with the pixel value being the target pixel value according to the pixel value of the target pixel point to obtain candidate groups which all contain the target pixel points with the set quantity;
if the number of the candidate groups exceeds the grouping threshold, the set number is increased, the steps are re-executed until the number of the candidate groups obtained in the same round of grouping is the grouping threshold, the candidate groups obtained in the last round of grouping are used as pixel point grouping, and the grouping threshold is determined according to the type of the round seal.
Specifically, if it is a circular stamp a, the grouping threshold is 1. If the stamp is a circular stamp B, the grouping threshold is 2.
The target pixel points obtained through the preset traversal rules are fixed, but a plurality of grouping methods can be used for grouping the target pixel points. For example, the number of candidate packets obtained may be different, given a different set number per packet. The set number is the desired number of target pixels that each packet should contain. The smaller the set number, the larger the number of packets obtained. Based on this, in this embodiment, a set number is agreed in the same round of grouping, and the continuous target pixel points with the target pixel value are grouped, so that the number of target pixel points included in each candidate group is the set number. Counting the number of the candidate packets obtained in the round of packets, if the number of the packets exceeds a packet threshold, indicating that the set number is set to be too small, so that the number of the packets is too large to meet the requirement, and the set number needs to be changed to regrow.
The set number of next round of packets may be a number added to the set number of previous round of packets, such as 1, 2, 3, 4, etc., which the present application is not limited to.
And the next round of grouping is carried out again according to the new set number, and the step of grouping is carried out on the continuous target pixel points with the pixel value being the target pixel value according to the pixel value of the target pixel point, so that candidate grouping which all comprises the set number of the target pixel points is obtained, and the number of the candidate grouping obtained in the same round of grouping is a grouping threshold value.
And stopping grouping after multiple rounds of grouping (the set number of the grouping in each round is different), wherein the number of the obtained candidate grouping is a grouping threshold value. And grouping the candidate group obtained by the last round of grouping as pixel points.
In this embodiment, the number of sets is increased to perform multiple rounds of grouping, so as to find the optimal pixel point grouping meeting the grouping threshold. The pixel points in the gaps of the character areas (the pixel points in the gaps are less than the pixel points in the non-character areas) can be eliminated, and the pixel points in the non-character areas can be accurately positioned.
In one embodiment, any two adjacent target pixel points are equally spaced.
Specifically, the equidistant refers to that the angle difference or radian of the angles corresponding to any two adjacent target pixel points relative to the initial pixel point is equal.
For example, angles corresponding to the plurality of target pixel points with respect to the start pixel point are 0 °, 1 °, 2 °, 3 °, 4 °, respectively. The angle difference between two adjacent target pixel points is 1 deg.
The larger the interval between two adjacent target pixel points, namely the angle difference is, the fewer the obtained target pixel points are; the smaller the interval between two adjacent target pixel points, namely the angle difference, the more target pixel points are obtained. Based on the above, the angle difference corresponding to any two adjacent target pixel points is set according to the actual application scene, which is not limited by the application.
The target pixel points are all located on the same circumference. The target pixel points are regularly searched from the circumference through equidistant preset traversal rules, and the found target pixel points are more representative.
In one embodiment, the coordinates of any one target pixel point are calculated by the following formula (2):
(2)
wherein ,for the coordinates of the target pixel point p, +.>The coordinate of the central point of the circular seal is that i is the angle of the target pixel point p to the radius corresponding to the initial pixel point on the circumference, i is a number not more than 360, and% >To traverse the radius.
Specifically, i is a variable not greater than 360, and the values of i corresponding to different target pixel points are different. The preset traversal rule may be that the value of i is one of j, 2j, 2j+1, 3j, 4j, etc., j is a variable, and i varies along with the value of j.
When i=j, for example, j=0, 1, 2, 3..360, the value of i is 0, 1, 2, 3..360.
When i=2j, for example, j=0, 1, 2, 3..180, the value of i is 0, 2, 4, 6..360.
When i=2j+1, for example, j=0, 1, 2, 3..179, the value of i is 1, 3, 5, 7..359.
When i=3j, for example, j=0, 1, 2, 3..120, the value of i is 0, 3, 6, 9, and..360.
When i=4j, for example, j=0, 1, 2, 3..90, the value of i is 0, 4, 8, 12,..360.
In one embodiment, i=4j, and j is a number no greater than 90.
Specifically, the values of i corresponding to two adjacent target pixel points are different, and the distance between the two target pixel points is determined. In the embodiment, i=4j is taken, so that the number of target pixel points and the distance between adjacent pixel points are considered while the traversal calculated amount is reduced, and the universality and the efficiency of traversal pixels can be shown.
In one embodiment, the deflection angle of the stamp image is calculated by the following formula (1):
(1)
Wherein A is a deflection angle,for the coordinates of the first target pixel,/-, for the first target pixel>And R is the radius of the circular seal for the coordinate of the last target pixel point.
Specifically, the coordinates of the first target pixel point and the coordinates of the last target pixel point are calculated by the above formula (2).
The quadrant of the first target pixel point and the last target pixel point relative to the central point of the circular seal can be judged through the coordinates of the first target pixel point and the coordinates of the last target pixel point. According to the coordinates of the first target pixel point and the coordinates of the last target pixel point, the inclination degree of the inclined circular seal can be judged compared with that of a circular seal without inclination.
The deflection angle may be expressed as 180/pi a.
After the center, the radius and the deflection angle of the circular seal are obtained, the three elements can be used for carrying out accurate polar coordinate transformation on the seal image cut out on the basis of the original image, so that a straight text line image is obtained, and the text content on the seal image is further recognized by OCR technology.
The embodiment of the application can acquire and process the related data based on the artificial intelligence technology. Among these, artificial intelligence (Artificial Intelligence, AI) is the theory, method, technique and application system that uses a digital computer or a digital computer-controlled machine to simulate, extend and extend human intelligence, sense the environment, acquire knowledge and use knowledge to obtain optimal results.
In one embodiment, step S200 specifically includes:
inputting a seal image into a trained pentagon detection model for angular region positioning to obtain a target detection result of an angular target in the seal image, wherein the target detection result of the angular target comprises an angular prediction frame of each angle of a pentagon in the seal image, and the pentagon detection model is constructed based on a YOLO model;
and mapping the angle prediction frame onto the seal image according to the proportional relation between the feature image and the original image in the pentagon detection model, and obtaining the angle region coordinates of each angle according to the region of the mapped angle prediction frame on the seal image.
Specifically, the pentagon detection model may be constructed based on the YOLO (YouLookOnlyOnce) model, and specifically may be constructed based on different versions of the YOLO model (e.g., versions of YOLO V1, YOLO V2, YOLO V3, YOLO V4, YOLO V5, etc.). The target detection result of the corner target comprises several parameter values (x, y, w, h, c) of the corner prediction frame of each corner. Where (x, y) represents the center coordinates of the angular prediction box, w and h represent the width and height of the angular prediction box, and c represents the confidence level confidence.
And mapping the angle prediction frame into the seal image to obtain the angle area and the angle area coordinates of each angle of the five-pointed star on the seal image.
According to the embodiment, through target detection based on the YOLO algorithm, the corner areas of five corners of the five-pointed star can be accurately identified and positioned.
In one embodiment, the pentagonal detection model is trained by:
acquiring a sample image containing five-pointed star;
carrying out data annotation on the sample image to generate an annotation file, wherein the annotation file stores annotation data, and the annotation data comprises coordinates, sizes and annotation categories of a real frame corresponding to each corner of the five-pointed star;
normalizing the selected sample image and inputting the sample image into a pre-trained pentagonal detection model;
extracting features of the input image by using a feature extraction layer contained in the pre-trained pentagonal detection model to obtain first feature images with different sizes;
sampling and feature fusion are carried out on the first feature images with different sizes by utilizing a feature fusion layer contained in the pre-trained pentagon detection model, so that second feature images with different sizes are obtained;
carrying out regression prediction on the input second feature images by using a prediction layer contained in the pre-trained pentagon detection model to obtain tensor data corresponding to the first feature images with different sizes, wherein the tensor data comprises the coordinate position, the size, the target category and the confidence coefficient of each predicted frame obtained by prediction;
Calculating a loss function according to tensor data and corresponding labeling data;
and obtaining a gradient through back propagation according to the loss function, updating model parameters by using a gradient descent method, repeating the normalization processing on the selected sample image, and inputting the sample image into a pre-trained pentagonal detection model and the following steps until the model converges to obtain the trained pentagonal detection model.
Specifically, during the data set construction process, each sample image contains one or more five-pointed star seals, and the sample images are stored under the same image folder. And marking the sample image by using an open source labelImg tool, namely framing out five corners of each five-pointed star, naming each corner, wherein each five-pointed star comprises which five corners, and storing the obtained label data in an xml file. Each xml file stores the data of one image; if an image has multiple five-pointed star seals, the data of the multiple five-pointed star seals are all stored in the same xml file.
Of course, the tag data can also be stored by json or other format files, and all the formats can be converted or read and resolved according to the formats during loading.
The xml contains the image object name of the sample image (the name of the image folder in which the sample image is located), the image file name (the name of the sample image), the image file path, the image size, the angular region coordinates of the five-pointed star, and the object names of the five angles contained in each five-pointed star. These xml files are placed under the same xml folder. The image files under the image folder and the xml files of the xml folder are in one-to-one correspondence through file names. For example, abc.jpg corresponds to abc.xml, and in addition, an image file name of the corresponding image, such as < filename > abc.jpg </filename >, is included in abc.xml. And storing the related data obtained after marking the same image in the same xml file.
And forming a data set after the sample image is marked. The data set division may be divided into a training set, a test set, and a validation set according to a certain division. For example: the training set, the verification set and the test set are randomly divided according to the preset proportions of 70%, 20% and 10% for training and testing of the pentagonal detection model. Alternatively, the data sets are partitioned into training sets (training and validation 9:1) and test sets (training and test sets 9:1). Of course, the specific partitioning strategy of the data set is set according to the actual application scenario, which is not limited by the present application.
After confirming the number of divisions, the xml file is taken to the image file name to remove the suffix such as jpg and then stored as an index into the txt file, for example, the xml file is stored in a single row form, namely, the xml file contains test. Txt, train. Txt and val. Txt finally, and therefore, the corresponding marking tag content of xml and the original image can be obtained simultaneously through the index in the txt file.
The pentagon detection model comprises an input layer, a feature extraction layer, namely a feature extraction backbone network back, a feature fusion layer, namely a neg network (neck feature fusion layer), and a prediction layer, namely a detection head.
The feature extraction layer is used for carrying out feature extraction on the input image to obtain first feature images with different sizes. For example, three different scale first feature maps are obtained, with minimum receptive field and maximum scale, moderate receptive field and medium scale, and maximum receptive field and minimum scale.
The feature fusion layer is used for sampling and feature fusion of the first feature images with different sizes to obtain second feature images with different sizes.
The prediction layer is used for carrying out regression prediction on the input second feature images to obtain tensor data corresponding to each first feature image. The tensor data for each first feature map includes the coordinate location and size of each predicted bounding box, confidence, i.e., five-tuple (x, y, w, h, c) and target class.
From the tensor data and the actual labeling data, a loss function can be calculated. If the model is determined not to be converged according to the loss function, obtaining a gradient according to the loss function, updating the model parameters of the pentagonal detection model through gradient descent and back propagation, and then training and verifying the pentagonal detection model with updated parameters by reusing the data set until the model is converged, so as to obtain the trained pentagonal detection model. The model convergence condition is that the loss function reaches a loss threshold value or the number of iterative training times of the model reaches a number threshold value.
The confidence coefficient reflects whether the grid contains the object or not, and the accuracy of the prediction frame when the object is contained, and the prediction frame lower than the confidence coefficient threshold value can be deleted, so that the prediction result of the whole network can be obtained through non-maximum value inhibition.
In addition, the trained pentagon detection model can be verified through a verification set, and the AP values of all the categories in the verification set are output after statistics; if the average value of the counted AP values of the various categories reaches a certain fixed value, verification is passed.
In one embodiment, acquiring a sample image includes:
carrying out data enhancement on the obtained original image;
and taking the original image and the image obtained after the data enhancement as sample images.
Specifically, the original image may be data-enhanced using techniques such as Mosaic data enhancement, cutMix data enhancement, self-countermeasure training data enhancement, and the like. The Mosaic data enhancement can enrich the data set, and 4 pictures are spliced in a random scaling, random cutting and random arrangement mode. CutMix data enhancement: two pictures were used for stitching.
The data enhancement can enrich the data set, adopts image geometric transformation to randomly use a plurality of pictures, randomly scales and then randomly distributes and splices, so that the detection data set is greatly enriched, and particularly, a plurality of small targets are added by random scaling, so that the robustness of the network is better. The training samples are subjected to data enhancement, so that the diversity of the training samples is increased, and the target detection accuracy is further improved.
In one embodiment, the sample tags may also be smoothed using Label Smoothing techniques.
In one embodiment, the training step of the pentagonal detection model further comprises, before the normalization of the selected sample image and the input to the pre-trained pentagonal detection model:
and clustering real frames of the sample images in the training set by using a first clustering algorithm, and taking the frame sizes of various centers as prior candidate frame sizes to obtain prior frames.
Predicting the second feature map by using a prediction layer contained in the pre-trained pentagon detection model to obtain tensor data corresponding to the first feature maps with different sizes, wherein the method comprises the following steps:
and distributing the prior frames to the second feature map in advance according to a preset rule, and adjusting the corresponding prior frames according to anchor point information on the second feature map to obtain tensor data of all predicted frames.
Specifically, the first clustering algorithm may be one of a K-means++ clustering algorithm, a K-means clustering algorithm, a DBSCAN density clustering algorithm and the like. And clustering the real frames (namely GT frames) of the sample image by using a clustering algorithm to obtain a plurality of prior frames (Anchor boxes are also called preselection frames) with different sizes. More specifically, a first clustering algorithm is used for clustering real frames of sample images in a data set or a training set, and the frame sizes of various centers are taken as models to obtain prior frame sizes, namely prior information, of predicted frames.
The input data for the first clustering algorithm is the width and height of ground truth bounding box (real bounding box). The size of each ground truth bounding box is different in scenes under different image sizes, it is very necessary to normalize the width and height of the bounding box and the width and height of the image, the IOU metric is used in the clustering process of the first clustering algorithm, each box is allocated to the anchor closest to the box, the size of the box is not required to be concerned when the IOU is calculated, the larger the IOU is when the boxes are similar to the anchor, and therefore the IOU can be calculated by using the width and height of the box after normalization.
The input image is scaled and divided into s×s grids, and a detection is made in each grid cell as to whether there is a five-pointed star corner. Each grid cell can predict a plurality of frames according to the prior frames, confidence scores, sizes and center coordinates of the predicted frames are given, and finally the predicted frames are screened through non-maximal inhibition. The YOLO network uses a non-maximal suppression method to select the best frame, i.e., the frame whose confidence meets the threshold.
In one embodiment, the pentagonal detection model further includes an SPP (spatial pyramid pooling (spatial pyramid pooling)) layer, which is located between the feature extraction layer and the feature fusion layer, which can increase the receptive field of the network. The feature extraction backbone network is a CSPDarknet53 network structure, the CSPDarknet53 network structure outputs four first feature graphs with the sizes of 152, 76, 38 and 19 respectively, the first feature graphs with the sizes of 19 are input into an SPP module, the third feature graphs are obtained by splicing after the maximum pooling of the SPP module, the first feature graphs with the sizes of 152, 76 and 38 output by the CSPDarknet53 network structure are input into a feature fusion layer, and the multi-classifier module carries out classification detection based on the second feature graphs with the sizes of 76, 38 and 19 output by the feature fusion layer, and outputs a final target detection result. The feature fusion layer realizes feature fusion through up-sampling, down-sampling and other operations on the basis of FPN.
In one embodiment, V100 four-card training may be employed to appropriately adapt the image size of the input depth network according to the video memory size.
In one embodiment, a learning rate cosine annealing decay strategy may be employed for model training.
In one embodiment, a Mish activation function may be employed.
In one embodiment, the general freezing training of the trunk feature extraction network feature in the training process can accelerate the training speed, and can also prevent the weight from being destroyed in the initial training stage. For example, 200 epochs were trained, the first 100 epochs had an initial learning rate set to le-3 and a batch_size of 8, and the last 100 epochs had been tried to speed up training and reduce memory usage to set the initial learning rate to le-4 and a batch_size of 4.
In one embodiment, the sample image comprises at least one five-pointed star stamp, and the annotation data further comprises the number of five-pointed star and the angle contained by each five-pointed star;
after obtaining the tensor data, the pentagonal detection model training step further includes:
clustering the obtained predicted frames to group every 5 predicted frames into one type, so as to obtain a clustering result;
calculating a loss function according to tensor data and corresponding labeling data, wherein the loss function comprises the following steps:
And calculating the cross-ratio loss, the classification loss, the confidence coefficient loss and the clustering loss according to the tensor data, the clustering result and the corresponding labeling data, and carrying out weighted summation on the cross-ratio loss, the classification loss, the confidence coefficient loss and the clustering loss according to a preset proportion to obtain the overall network loss.
Specifically, in order to enhance the diversity of data, the robustness of the network is made better. The sample image may contain one, two or more five-pointed star stamps. The middle of each five-pointed star seal comprises a five-pointed star.
After the predicted frames of the five-pointed star are obtained, the predicted frames are also required to be clustered, wherein the clustering strategy is that every five predicted frames are clustered into one type, and the clustered predicted boundaries are considered as the predicted frames of five angles of the same five-pointed star.
Clustering of the predicted borders may be implemented by a second clustering algorithm. The second clustering algorithm can be one of a K-means++ clustering algorithm, a K-means clustering algorithm, a DBSCAN density clustering algorithm and the like. The pentagonal detection model may have a second aggregation layer integrated therein.
If the second aggregation layer is integrated into the pentagonal detection model, the overall network loss of the pentagonal detection model includes cross-ratio loss, classification loss, confidence loss, and clustering loss. The clustering loss is the clustering loss of the predicted frame.
Optionally, the pentagonal detection model selects the CIOU strategy to calculate the loss.
Of course, if the second aggregation algorithm is not integrated in the pentagonal detection model, the network overall penalty of the pentagonal detection model includes the cross-ratio penalty, the classification penalty, and the confidence penalty. A clustering model may be connected to the rear of the pentagonal detection model for clustering the predicted bounding boxes, the pentagonal detection model and the clustering model being separately trained.
Clustering of predicted borders can be specifically achieved as follows: and clustering the predicted frames of all angles by adopting a second clustering algorithm, for example, clustering predicted frames within a range of 200 pixel points around one predicted frame, and setting 5 predicted frames in each search of the number of adjacent predicted frames to obtain a cluster. The number of clusters is the number of five stars, and five predicted frames contained in each cluster are considered as predicted frames of five angles of the same five stars.
The clustering result is used for indicating the number of the five-pointed star according to the clustering number and the prediction frame contained by each five-pointed star. Based on the clustering result and the true attribution of each corner in the input image (i.e., the corner actually contained by each five-pointed star in the input image), a clustering loss can be calculated. Model parameters of the cluster model may be updated based on the cluster loss until the cluster model converges.
In one embodiment, detecting and locating text regions for each character in a circular stamp includes:
inputting a seal image into a trained text detection model for character region positioning to obtain a target detection result of a character target in the seal image, wherein the target detection result of the character target comprises a character prediction frame of each character in the seal image, and the text detection model is constructed based on a YOLO model;
and mapping the character prediction frame onto the seal image according to the proportional relation between the feature image and the original image in the text detection model, and obtaining the text region coordinates of each character according to the region of the mapped character prediction frame on the seal image.
In particular, the text detection model may be built based on the YOLO (YouLookOnlyOnce) model, in particular may be built based on different versions of the YOLO model (e.g. versions of YOLO V1, YOLO V2, YOLO V3, YOLO V4, YOLO V5, etc.). The target detection result of the character target comprises several parameter values (x, y, w, h, c) of a character prediction frame of each character. Where (x, y) represents the center coordinates of the character prediction frame, w and h represent the width and height of the character prediction frame, and c represents confidence.
And mapping the character prediction frame into the seal image to obtain the text region and the text region coordinates of each character on the seal image.
According to the embodiment, through target detection based on the YOLO algorithm, the text region of the character can be accurately identified and positioned.
In one embodiment, the text detection model is trained by:
acquiring a sample image containing characters;
carrying out data annotation on the sample image to generate an annotation file, wherein the annotation file stores annotation data, and the annotation data comprises coordinates, sizes and annotation categories of real frames corresponding to each character;
normalizing the sample image and inputting the sample image into a pre-trained text detection model;
extracting features of the input image by using a feature extraction layer contained in the pre-trained text detection model to obtain first feature images with different sizes;
sampling and feature fusion are carried out on the first feature images with different sizes by utilizing a feature fusion layer contained in the pre-trained text detection model, so that second feature images with different sizes are obtained;
carrying out regression prediction on the input second feature images by using a prediction layer contained in the pre-trained text detection model to obtain tensor data corresponding to the first feature images with different sizes, wherein the tensor data comprises the coordinate position, the size, the target category and the confidence coefficient of each character prediction frame obtained by prediction;
Calculating a loss function according to tensor data and corresponding labeling data;
and obtaining a gradient through back propagation according to the loss function, updating model parameters by using a gradient descent method, repeating the normalization processing on the sample image, and then inputting the sample image into a pre-trained text detection model and the following steps until the model converges to obtain the trained text detection model.
The specific training process of the text detection model can be referred to the pentagonal detection model, and will not be described herein.
The method aims at solving the problem of obtaining the center coordinates, the radius and the angle of the seal, and is convenient for recognizing the text after the circular seal is straightened by using a polar coordinate method.
Referring to fig. 5, the present application also provides a device for acquiring circular seal data, which includes:
an image acquisition module 100 for acquiring a stamp image including a circular stamp;
the pentagonal detection module 200 is used for positioning each corner of the pentagon in the middle area of the circular seal to obtain the corner area coordinate of each corner;
the center point determining module 300 is configured to calculate the center point coordinates of the circular stamp according to the corner region coordinates of all the corners.
In one embodiment, the apparatus further comprises:
The distance calculating module is used for calculating the distance from the center point of the circular seal to any one corner of the five-pointed star according to the center point coordinates and the corner region coordinates;
the radius calculation module is used for calculating the radius of the circular seal according to preset seal design parameters, five-pointed star design parameters and the distance;
or ,
the apparatus further comprises:
the distance calculating module is used for calculating the distance from the center point of the circular seal to each corner of the five-pointed star according to the coordinates of the center point and the coordinates of the corner region;
the average value calculation module is used for calculating a distance average value of the obtained five distances;
the radius calculation module is used for calculating the radius of the circular seal according to preset seal design parameters, five-pointed star design parameters and a distance average value;
the seal design parameter is a round seal design diameter, and the five-pointed star design parameter is a design diameter of a minimum circumcircle of the five-pointed star; or the seal design parameter is a round seal design radius, and the five-pointed star design parameter is a design radius of the minimum circumcircle of the five-pointed star.
In one embodiment, the apparatus further comprises:
the text detection module is used for detecting and positioning the text area of each character in the circular seal;
The filling module is used for covering pixels of all text areas in the same color;
the cutting module is used for cutting the seal image to obtain a circular image containing all text areas, wherein the radius of the circular image is not larger than the radius of the circular seal;
the binarization module is used for converting the circular image into a gray image and then carrying out binarization processing to obtain a binarized image;
the traversing module is used for determining the target pixel point and the pixel value and the coordinate of the target pixel point on the circumference formed by the traversing radius by taking the central point as the center of a circle in the binarized image based on a preset traversing rule;
the grouping module is used for grouping the target pixel points according to the pixel values of the target pixel points to obtain pixel point grouping which is continuous and has the target pixel values, wherein the grouping number of the pixel point grouping is related to the type of the circular seal;
and the deflection angle calculation module is used for calculating the deflection angle of the seal image according to the coordinates of the first target pixel point and the last target pixel point in any pixel point group and the radius of the circular seal.
In one embodiment, the grouping module specifically includes:
The grouping unit is used for grouping the continuous target pixel points with the pixel values being the target pixel values according to the pixel values of the target pixel points to obtain candidate groups which all contain the target pixel points with the set number;
and the circulation unit is used for increasing the set number if the number of the candidate packets exceeds the packet threshold value, re-executing the steps until the number of the candidate packets obtained in the same round of packets is the packet threshold value, and grouping the candidate packets obtained in the last round of packets as pixel points, wherein the packet threshold value is determined according to the type of the round seal.
In one embodiment, the deflection angle calculation module calculates the deflection angle specifically by the following formula (1):
(1)
Wherein A is a deflection angle,is the coordinates of the first target pixel point,/>and R is the radius of the circular seal for the coordinate of the last target pixel point.
In one embodiment, any two adjacent target pixel points are equally spaced.
In one embodiment, the traversal module calculates the coordinates of any one target pixel point according to the following formula (2):
(2)
wherein ,for the coordinates of the target pixel point p, +.>For the center point coordinate, i is the angle of the target pixel point p relative to the radius corresponding to the initial pixel point on the circumference, i is a number not greater than 360, and +. >To traverse the radius.
In one embodiment, i=4j, and j is a number not greater than 90.
In one embodiment, the pentagon detection module 200 specifically includes:
the system comprises a seal image acquisition module, a corner target detection module and a corner detection module, wherein the seal image acquisition module is used for acquiring a seal image, and the corner target detection module is used for inputting the seal image into a trained pentagonal detection model for angular region positioning to obtain a target detection result of a corner target in the seal image, wherein the target detection result of the corner target comprises a corner prediction frame of each corner of a pentagon in the seal image, and the pentagonal detection model is constructed based on a YOLO model;
the first coordinate mapping conversion module is used for mapping the angle prediction frame onto the seal image according to the proportional relation between the feature image and the original image in the pentagon detection model, and obtaining the angle area coordinate of each angle according to the area of the mapped angle prediction frame on the seal image.
In one embodiment, the apparatus further comprises a model training module comprising:
the sample acquisition module is used for acquiring a sample image containing five-pointed star;
the labeling module is used for carrying out data labeling on the sample image to generate a labeling file, wherein the labeling file stores labeling data, and the labeling data comprises coordinates, sizes and labeling types of real frames corresponding to each corner of the five-pointed star;
The normalization module is used for normalizing the selected sample image and inputting the sample image into the pre-trained pentagonal detection model;
the feature extraction module is used for extracting features of the input image by utilizing a feature extraction layer contained in the pre-trained pentagonal detection model to obtain first feature images with different sizes;
the feature fusion module is used for sampling and feature fusion of the first feature images with different sizes by utilizing a feature fusion layer contained in the pre-trained pentagonal detection model to obtain second feature images with different sizes;
the prediction module is used for carrying out regression prediction on the input second feature images by using a prediction layer contained in the pre-trained pentagon detection model to obtain tensor data corresponding to the first feature images with different sizes, wherein the tensor data comprises the coordinate position, the size, the target category and the confidence coefficient of each predicted frame obtained by prediction;
the loss function calculation module is used for calculating a loss function according to tensor data and corresponding labeling data;
and the model iteration module is used for obtaining a gradient through back propagation according to the loss function, updating the model parameters by using a gradient descent method, and jumping to the normalization module and executing the steps of the later modules until the model converges to obtain a trained pentagonal detection model.
In one embodiment, the model training module further comprises:
the first clustering module is used for clustering real frames of sample images in the training set by using a first clustering algorithm, and taking the frame sizes of various centers as prior candidate frame sizes to obtain prior frames;
the prediction module is specifically configured to pre-distribute the prior frames to the second feature map according to a preset rule, and adjust the corresponding prior frames according to anchor point information on the second feature map, so as to obtain tensor data of all the predicted frames.
In one embodiment, the sample image comprises at least one five-pointed star stamp, and the annotation data further comprises the number of five-pointed star and the angle contained by each five-pointed star;
the model training module further includes:
the second clustering module is used for clustering the obtained predicted frames to group every 5 predicted frames into one type, so as to obtain a clustering result;
the loss function calculation module is specifically configured to calculate a cross-ratio loss, a classification loss, a confidence coefficient loss and a clustering loss according to tensor data, a clustering result and corresponding labeling data, and weight and sum the cross-ratio loss, the classification loss, the confidence coefficient loss and the clustering loss according to a preset proportion to obtain the overall network loss.
In one embodiment, the text detection module specifically includes:
the character detection module is used for inputting the seal image into the trained text detection model to perform character region positioning to obtain a target detection result of a character target in the seal image, wherein the target detection result of the character target comprises a character prediction frame of each character in the seal image, and the text detection model is constructed based on the YOLO model;
and the second coordinate mapping conversion module is used for mapping the character prediction frame onto the seal image according to the proportional relation between the feature image and the original image in the text detection model, and obtaining the text region coordinate of each character according to the region of the mapped character prediction frame on the seal image.
According to the application, through more elements of accurate positioning of the center point and the radius of the circular seal and accurate pixel-level accurate coverage of each character area in the seal and accurate judgment of the initial character position and the end position, the deflection angle or the inclination angle of the seal is further calculated, and a solid and accurate foundation is laid for follow-up accurate polar coordinate transformation and text recognition. The text accurate recognition can be applied to various fields, such as approval links in financial fields of banking systems, insurance systems and the like, but is not limited to the fields.
FIG. 6 illustrates an internal block diagram of a computer device in one embodiment. The computer device may specifically be a terminal or a server. As shown in fig. 6, the computer device includes a processor, a memory, and a network interface connected by a system bus. The memory includes a nonvolatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system, and may also store a computer program which, when executed by a processor, causes the processor to implement the steps of the method embodiments described above. The internal memory may also have stored therein a computer program which, when executed by a processor, causes the processor to perform the steps of the method embodiments described above. It will be appreciated by those skilled in the art that the structure shown in FIG. 6 is merely a block diagram of some of the structures associated with the present inventive arrangements and is not limiting of the computer device to which the present inventive arrangements may be applied, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In one embodiment, a computer device is provided comprising a memory and a processor, the memory storing a computer program that, when executed by the processor, causes the processor to perform the steps of:
Acquiring a seal image containing a circular seal;
positioning each corner of the five-pointed star positioned in the middle area of the circular seal to obtain the corner area coordinate of each corner;
and calculating the coordinates of the central point of the circular seal according to the coordinates of the corner areas of all corners.
In one embodiment, a computer readable storage medium is provided, storing a computer program which, when executed by a processor, causes the processor to perform the steps of:
acquiring a seal image containing a circular seal;
positioning each corner of the five-pointed star positioned in the middle area of the circular seal to obtain the corner area coordinate of each corner;
and calculating the coordinates of the central point of the circular seal according to the coordinates of the corner areas of all corners.
Those skilled in the art will appreciate that the processes implementing all or part of the methods of the above embodiments may be implemented by a computer program for instructing relevant hardware, and the program may be stored in a non-volatile computer readable storage medium, and the program may include the processes of the embodiments of the methods as above when executed. Any reference to memory, storage, database, or other medium used in embodiments provided herein may include non-volatile and/or volatile memory. The nonvolatile memory can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), memory bus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The foregoing examples illustrate only a few embodiments of the application, which are described in detail and are not to be construed as limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of protection of the present application is to be determined by the appended claims.

Claims (16)

1. A method for acquiring circular seal data, the method comprising:
acquiring a seal image containing a circular seal;
positioning each corner of the five-pointed star positioned in the middle area of the circular seal to obtain the corner area coordinate of each corner;
calculating the central point coordinates of the circular seal according to the corner region coordinates of all corners;
calculating the radius of the circular seal according to the coordinates of the central point and the coordinates of the angular area of the circular seal, and preset seal design parameters and five-pointed star design parameters;
Detecting and positioning a text region of each character in the circular seal;
the pixels of all the text areas are covered in the same color;
cutting the seal image to obtain a circular image containing all text areas, wherein the radius of the circular image is not larger than the radius of the circular seal;
converting the circular image into a gray image, and then performing binarization processing to obtain a binarized image;
determining a target pixel point and pixel values and coordinates of the target pixel point on a circle formed by the center point of the circular seal and the traversing radius in the binarized image based on a preset traversing rule;
grouping the target pixel points according to the pixel values of the target pixel points to obtain pixel point grouping which is continuous and has the target pixel values, wherein the grouping number of the pixel point grouping is related to the type of the circular seal;
and calculating the deflection angle of the seal image according to the coordinates of the first target pixel point and the last target pixel point in any one pixel point group and the radius of the circular seal.
2. The method according to claim 1, wherein calculating the radius of the circular stamp according to the coordinates of the center point and the coordinates of the corner areas of the circular stamp and the preset stamp design parameters and five-pointed star design parameters comprises:
Calculating the distance from the center point of the circular seal to any one corner of the five-pointed star according to the center point coordinate and the corner region coordinate of the circular seal; calculating the radius of the circular seal according to preset seal design parameters, five-pointed star design parameters and the distance;
or ,
calculating the distance from the center point of the circular seal to each corner of the five-pointed star according to the center point coordinates and the corner region coordinates of the circular seal; solving a distance average value of the obtained five distances; calculating the radius of the circular seal according to preset seal design parameters, five-pointed star design parameters and the distance average value;
the seal design parameter is a round seal design diameter, and the five-pointed star design parameter is a design diameter of a minimum circumcircle of the five-pointed star; or the seal design parameter is a round seal design radius, and the five-pointed star design parameter is the design radius of the minimum circumcircle of the five-pointed star.
3. The method according to claim 1, wherein the center point coordinates of the circular stamp are calculated by the following formula (3):
(3)
Wherein, (x 0, y 0) is the center point coordinate of the circular seal, (x 1, y 1), (x 2, y 2), (x 3, y 3), (x 4, y 4), (x 5, y 5) is the center point coordinate of the five corner areas.
4. The method according to claim 1, wherein the grouping the target pixels according to the pixel values of the target pixels to obtain the pixel groups with continuous target pixels and all the pixel groups being the target pixel values includes:
grouping the continuous target pixel points with the pixel value being the target pixel value according to the pixel value of the target pixel point to obtain candidate groups which all contain the target pixel points with the set number;
if the number of the candidate packets exceeds a packet threshold, increasing the set number, and re-executing the steps until the number of the candidate packets obtained in the same round of packets is the packet threshold, and grouping the candidate packets obtained in the last round of packets as pixel points, wherein the packet threshold is determined according to the type of the circular seal.
5. The method according to claim 1, wherein the deflection angle of the stamp image is calculated by the following formula (1):
(1)
Wherein A is a deflection angle,for the coordinates of the first target pixel,/-, for the first target pixel>And R is the radius of the circular seal for the coordinate of the last target pixel point.
6. The method of claim 1, wherein any two adjacent target pixels are equally spaced.
7. The method according to claim 1, wherein the coordinates of any one target pixel point are calculated by the following formula (2):
(2)
wherein ,for the coordinates of the target pixel point p, +.>The coordinate of the central point of the circular seal is that i is the angle of the target pixel point p to the radius corresponding to the initial pixel point on the circumference, i is a number not more than 360, and%>For the traversal radius.
8. The method of claim 7, wherein i = 4j, and j is a number no greater than 90.
9. The method of claim 1, wherein said locating each corner of a five-pointed star located in a middle region of said circular stamp, obtaining a corner region coordinate for each corner, comprises:
inputting the seal image into a trained pentagon detection model for angular region positioning to obtain a target detection result of an angular target in the seal image, wherein the target detection result of the angular target comprises an angular prediction frame of each angle of a pentagon in the seal image, and the pentagon detection model is constructed based on a YOLO model;
and mapping the angle prediction frame onto the seal image according to the proportional relation between the feature image and the original image in the pentagon detection model, and obtaining the angle region coordinates of each angle according to the region of the mapped angle prediction frame on the seal image.
10. The method according to claim 9, wherein the pentagonal detection model is trained by:
acquiring a sample image containing five-pointed star;
carrying out data annotation on the sample image to generate an annotation file, wherein the annotation file stores annotation data, and the annotation data comprises coordinates, sizes and annotation categories of a real frame corresponding to each corner of the five-pointed star;
normalizing the selected sample image and inputting the sample image into a pre-trained pentagonal detection model;
extracting features of the input image by using a feature extraction layer contained in the pre-trained pentagonal detection model to obtain first feature images with different sizes;
sampling and feature fusion are carried out on the first feature images with different sizes by utilizing a feature fusion layer contained in the pre-trained pentagon detection model, so that second feature images with different sizes are obtained;
carrying out regression prediction on the input second feature images by using a prediction layer contained in the pre-trained pentagon detection model to obtain tensor data corresponding to the first feature images with different sizes, wherein the tensor data comprises the coordinate position, the size, the target category and the confidence coefficient of each predicted frame obtained by prediction;
Calculating a loss function according to the tensor data and the corresponding labeling data;
and obtaining a gradient through back propagation according to the loss function, updating model parameters by using a gradient descent method, repeating the normalization processing on the selected sample image, and inputting the sample image into a pre-trained pentagonal detection model and the following steps until the model converges to obtain the trained pentagonal detection model.
11. The method of claim 10, wherein the training step of the pentagonal detection model further comprises, prior to the normalizing the selected sample image and inputting the normalized sample image to the pre-trained pentagonal detection model:
clustering real frames of sample images in a training set by using a first clustering algorithm, and taking the frame sizes of various centers as prior candidate frame sizes to obtain prior frames;
the regression prediction is performed on the input second feature map by using a prediction layer contained in the pre-trained pentagon detection model to obtain tensor data corresponding to the first feature map with different sizes, including:
and distributing the prior frames to the second feature map in advance according to a preset rule, and adjusting the corresponding prior frames according to anchor point information on the second feature map to obtain tensor data of all predicted frames.
12. The method of claim 10, wherein the sample image comprises at least one five-pointed star stamp, and the annotation data further comprises the number of five-pointed star and the angle contained by each five-pointed star;
after obtaining the tensor data, the pentagonal detection model training step further includes:
clustering the obtained predicted frames to group every 5 predicted frames into one type, so as to obtain a clustering result;
the calculating a loss function according to the tensor data and the corresponding labeling data comprises the following steps:
and calculating the cross-ratio loss, the classification loss, the confidence coefficient loss and the clustering loss according to the tensor data, the clustering result and the corresponding labeling data, and carrying out weighted summation on the cross-ratio loss, the classification loss, the confidence coefficient loss and the clustering loss according to a preset proportion to obtain the overall network loss.
13. The method of claim 1, wherein said detecting and locating text regions for each character in said circular seal comprises:
inputting the seal image into a trained text detection model for character region positioning to obtain a target detection result of a character target in the seal image, wherein the target detection result of the character target comprises a character prediction frame of each character in the seal image, and the text detection model is constructed based on a YOLO model;
And mapping the character prediction frame onto the seal image according to the proportional relation between the feature image and the original image in the text detection model, and obtaining the text region coordinates of each character according to the region of the mapped character prediction frame on the seal image.
14. A circular stamp data acquisition apparatus, the apparatus comprising:
the image acquisition module is used for acquiring a seal image containing a circular seal;
the pentagonal detection module is used for positioning each corner of the pentagon positioned in the middle area of the circular seal to obtain the corner area coordinate of each corner;
the center point determining module is used for calculating the center point coordinates of the circular seal according to the corner region coordinates of all corners;
the circular seal radius calculation module is used for calculating the radius of the circular seal according to the center point coordinates and the corner area coordinates of the circular seal, preset seal design parameters and five-pointed star design parameters;
the text detection module is used for detecting and positioning the text area of each character in the circular seal;
the filling module is used for covering pixels of all text areas in the same color;
the cutting module is used for cutting the seal image to obtain a circular image containing all text areas, wherein the radius of the circular image is not larger than the radius of the circular seal;
The binarization module is used for converting the circular image into a gray image and then carrying out binarization processing to obtain a binarized image;
the traversing module is used for determining a target pixel point and a pixel value and a coordinate of the target pixel point on a circle formed by traversing the radius by taking the central point of the circular seal as the circle center in the binarized image based on a preset traversing rule;
the grouping module is used for grouping the target pixel points according to the pixel values of the target pixel points to obtain pixel point grouping with continuous target pixel points and target pixel values, wherein the grouping number of the pixel point grouping is related to the type of the circular seal;
and the deflection angle calculation module is used for calculating the deflection angle of the seal image according to the coordinates of the first target pixel point and the last target pixel point in any one pixel point group and the radius of the circular seal.
15. A computer readable storage medium storing a computer program, which when executed by a processor causes the processor to perform the steps of the method according to any one of claims 1 to 13.
16. A computer device comprising a memory and a processor, wherein the memory stores a computer program which, when executed by the processor, causes the processor to perform the steps of the method of any of claims 1 to 13.
CN202310684211.0A 2023-06-12 2023-06-12 Method, device, equipment and storage medium for acquiring circular seal data Active CN116416626B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310684211.0A CN116416626B (en) 2023-06-12 2023-06-12 Method, device, equipment and storage medium for acquiring circular seal data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310684211.0A CN116416626B (en) 2023-06-12 2023-06-12 Method, device, equipment and storage medium for acquiring circular seal data

Publications (2)

Publication Number Publication Date
CN116416626A CN116416626A (en) 2023-07-11
CN116416626B true CN116416626B (en) 2023-08-29

Family

ID=87054700

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310684211.0A Active CN116416626B (en) 2023-06-12 2023-06-12 Method, device, equipment and storage medium for acquiring circular seal data

Country Status (1)

Country Link
CN (1) CN116416626B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116704541B (en) * 2023-08-09 2023-10-27 易签链(深圳)科技有限公司 Method for manufacturing and using controlled signed electronic official seal
CN117671694B (en) * 2023-12-04 2024-06-14 合肥大智慧财汇数据科技有限公司 Document seal preprocessing method based on detection and fusion

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111814716A (en) * 2020-07-17 2020-10-23 上海眼控科技股份有限公司 Seal removing method, computer device and readable storage medium
WO2021115490A1 (en) * 2020-06-22 2021-06-17 平安科技(深圳)有限公司 Seal character detection and recognition method, device, and medium for complex environments
CN113012014A (en) * 2021-02-19 2021-06-22 上海益高信息技术有限公司 Electronic decoding method for optical watermark anti-counterfeiting seal
CN113469888A (en) * 2021-07-08 2021-10-01 江西金格科技股份有限公司 Method and device for correcting inclination angle of circular electronic seal
CN113673509A (en) * 2021-07-28 2021-11-19 华南理工大学 Instrument detection and classification method based on image text
CN113887337A (en) * 2021-09-15 2022-01-04 浪潮云信息技术股份公司 Seal identification method and system with bent text and storage medium
CN114782953A (en) * 2022-04-13 2022-07-22 易签链(深圳)科技有限公司 Seal intelligent identification method
CN114898083A (en) * 2021-12-02 2022-08-12 上海通办信息服务有限公司 Method, device and equipment for intelligently aligning circular red official seal
WO2022198969A1 (en) * 2021-03-25 2022-09-29 深圳市商汤科技有限公司 Method, apparatus, and device for recognizing seal text, and computer readable storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112380921A (en) * 2020-10-23 2021-02-19 西安科锐盛创新科技有限公司 Road detection method based on Internet of vehicles

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2021115490A1 (en) * 2020-06-22 2021-06-17 平安科技(深圳)有限公司 Seal character detection and recognition method, device, and medium for complex environments
CN111814716A (en) * 2020-07-17 2020-10-23 上海眼控科技股份有限公司 Seal removing method, computer device and readable storage medium
CN113012014A (en) * 2021-02-19 2021-06-22 上海益高信息技术有限公司 Electronic decoding method for optical watermark anti-counterfeiting seal
WO2022198969A1 (en) * 2021-03-25 2022-09-29 深圳市商汤科技有限公司 Method, apparatus, and device for recognizing seal text, and computer readable storage medium
CN113469888A (en) * 2021-07-08 2021-10-01 江西金格科技股份有限公司 Method and device for correcting inclination angle of circular electronic seal
CN113673509A (en) * 2021-07-28 2021-11-19 华南理工大学 Instrument detection and classification method based on image text
CN113887337A (en) * 2021-09-15 2022-01-04 浪潮云信息技术股份公司 Seal identification method and system with bent text and storage medium
CN114898083A (en) * 2021-12-02 2022-08-12 上海通办信息服务有限公司 Method, device and equipment for intelligently aligning circular red official seal
CN114782953A (en) * 2022-04-13 2022-07-22 易签链(深圳)科技有限公司 Seal intelligent identification method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
You Only Look Once: Unified, Real-Time Object Detection;Joseph Redmon等;《arXiv:1506.02640v5》;第1-10页 *

Also Published As

Publication number Publication date
CN116416626A (en) 2023-07-11

Similar Documents

Publication Publication Date Title
CN111723860B (en) Target detection method and device
CN116416626B (en) Method, device, equipment and storage medium for acquiring circular seal data
CN112084869B (en) Compact quadrilateral representation-based building target detection method
US11042742B1 (en) Apparatus and method for detecting road based on convolutional neural network
CN109815997A (en) The method and relevant apparatus of identification vehicle damage based on deep learning
CN112418278A (en) Multi-class object detection method, terminal device and storage medium
CN110781882A (en) License plate positioning and identifying method based on YOLO model
CN111191649A (en) Method and equipment for identifying bent multi-line text image
CN111178290A (en) Signature verification method and device
CN111126243B (en) Image data detection method and device and computer readable storage medium
CN115457408A (en) Land monitoring method and device, electronic equipment and medium
CN110580507B (en) City texture classification and identification method
CN107578003A (en) A kind of remote sensing images transfer learning method based on GEOGRAPHICAL INDICATION image
CN114155285A (en) Image registration method based on gray level histogram
Voelsen et al. Investigations on feature similarity and the impact of training data for land cover classification
CN112418262A (en) Vehicle re-identification method, client and system
CN116958221A (en) Cell data analysis method, device, equipment and storage medium
CN116612272A (en) Intelligent digital detection system for image processing and detection method thereof
CN114882490B (en) Unlimited scene license plate detection and classification method based on point-guided positioning
CN115953371A (en) Insulator defect detection method, device, equipment and storage medium
CN110895849A (en) Method and device for cutting and positioning crown word number, computer equipment and storage medium
CN112328913A (en) Task processing method and device
CN110458070A (en) Method and system based on motor vehicle annual test check table picture recognition amount of testing
Kong et al. A Mountain Summit Recognition Method Based on Improved Faster R‐CNN
CN116385818B (en) Training method, device and equipment of cloud detection model

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant