General square seal identification method, device and system for any character arrangement direction

CN117727042BActive Publication Date: 2026-09-15BEIJING YIDAO BOSHI TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410003542.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-01-02
Publication Date
2026-09-15
Estimated Expiration
2044-01-02

AI Technical Summary

Technical Problem

[0008]当前方章识别方法均为专用型方章识别,主要为针对某一固定排列顺序的或针对某一固定类型的方章识别方法,暂无可支持任意版式、任意字符排列方向的方形印章文字识别和排序方法

Benefits of technology

[0079] 1. By adopting a dual-task text segmentation module, it can adaptively combine the prediction results of text line masks and character masks to flexibly handle various layouts, thus possessing strong versatility and supporting the recognition and sorting of square seal characters in any layout and with any character arrangement direction;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117727042B_ABST
    Figure CN117727042B_ABST
Patent Text Reader

Abstract

The application discloses a general square seal recognition method, device and system of any character arrangement direction, and belongs to the field of computer vision. The method comprises the following steps: receiving a square seal image; performing text segmentation on the square seal image to obtain a text line mask and a character mask; determining all text line contours according to the text line mask, calculating and determining the quality score and direction of each text line contour, and thus performing text line direct recognition or character combination into text line recognition; performing text line direct recognition or character combination into text line recognition; and outputting an optimal square seal recognition result. The application can recognize square seals of various formats of any character arrangement direction in the order of characters, and has the characteristics of high universality, high robustness and high precision.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision, and in particular to a universal square seal recognition method, apparatus and system for recognizing characters in any orientation. Background Technology

[0002] Square seal recognition (square stamp) is of great value in many image information extraction applications. The technical challenges of square seal recognition are its varied layout and inconsistent character arrangement.

[0003] Square seals come in various styles, the most common being square financial seals, legal representative seals, other name seals, special-purpose seals, and other types of seals. Some examples are shown below. Figure 1 As shown (the uncoded stamps are artificially generated fake stamps).

[0004] There are three different possible arrangements of the characters in the seal:

[0005] 1. Text lines are arranged horizontally from top to bottom, such as... Figure 2 As shown;

[0006] 2. Text lines are arranged vertically from left to right, such as... Figure 3 As shown;

[0007] 3. Text lines are arranged vertically from right to left, such as... Figure 4 As shown.

[0008] Currently, all seal recognition methods are specialized seal recognition methods, mainly targeting a fixed arrangement or a fixed type of seal. There are currently no methods that support the recognition and sorting of square seal characters in any format or with any character arrangement direction. Summary of the Invention

[0009] To address the above problems, this invention relates to a universal square seal recognition method, apparatus, and system for any character arrangement direction. It can recognize square seals of various formats with any character arrangement direction according to the text order, and has the characteristics of high versatility, high robustness, and high precision.

[0010] According to a first aspect of the present invention, a universal square seal recognition method is provided, wherein the square seal has multiple lines of seal text, and the universal square seal recognition method includes the following steps:

[0011] S1 Image Reception Steps: Receive the image of the square seal;

[0012] S2 Text Segmentation Step: Perform text segmentation on the square seal image to obtain text line masks and character masks;

[0013] S3 recognition method selection steps: Determine the outlines of all text lines based on the text line mask, calculate and determine the quality score and direction of each text line outline, and then perform direct text line recognition or character combination into text line recognition.

[0014] S4 recognition method execution steps: Perform direct recognition of text lines or recognition of text lines composed of character combinations;

[0015] S5 recognition result output steps: Output the optimal square seal recognition result.

[0016] Furthermore, in the S2 text segmentation step, the Real-time Scene Text Detection with Differentiable Binarization (DBNet) algorithm model is used for text segmentation.

[0017] Furthermore, in the S2 text segmentation step, the real-time scene text detection algorithm model includes two prediction heads with identical structures, which are used to output the text line mask and the character mask, respectively.

[0018] Furthermore, the S2 text segmentation step also includes: expanding the processed and shrunken text line mask and character mask back to the original instance size.

[0019] Furthermore, in step S3, if the quality score of all text line contours is greater than the quality score threshold and the direction is horizontal, then the text line is directly recognized; otherwise, the text line is recognized by combining characters.

[0020] Furthermore, the quality score of the text line contour is equal to the area of ​​the text line contour divided by the area of ​​the minimum bounding rectangle of the text line contour.

[0021] Furthermore, the quality score threshold is 0.7.

[0022] Furthermore, the direction of the text line outline is determined as follows: if the width of the smallest bounding rectangle of the text line outline is greater than its height, then the text line outline is horizontal; otherwise, it is vertical.

[0023] Furthermore, in S3, if there is no character at the character mask position corresponding to the outline of a certain text line, then the text line is the anti-counterfeiting number of the seal. The smallest bounding rectangle of the anti-counterfeiting number text line is stored separately and appended to the text line for recognition.

[0024] Furthermore, in step S4, the direct recognition of the text line includes:

[0025] For all text line outlines, the smallest bounding rectangle and its coordinates are obtained. The text lines are then recognized in order from top to bottom according to their coordinates, thus obtaining the square-shaped text recognition results arranged in sequence.

[0026] Furthermore, in step S4, the character combination into text line recognition includes:

[0027] S41: Determine all character outlines based on the character mask, determine the smallest bounding rectangle of the character as the character frame based on the character outline, and determine the midpoint of each character frame;

[0028] S42: Determine the number of character boxes. If the number of character boxes is 3, sort the three character boxes and perform perspective transformations in sequence. Arrange the results into text lines from left to right for recognition. If the number of character boxes is ≥4, proceed to the next step.

[0029] S43: Determine the list of all characters;

[0030] S44: Perform a perspective transformation on all character lists in order to obtain a horizontally arranged list of text lines hLines, a vertically arranged list of text lines from left to right vLines1 and / or a vertically arranged list of text lines from right to left vLines2;

[0031] S45: Perform text line recognition on hLines, vLines1 and / or vLines2, and select the recognition result with the seal keyword at the end as the optimal square seal recognition result.

[0032] Furthermore, in step S42, the area of ​​each character box is calculated, the character with the largest area is the third character, and the character above the other two characters is the first character, and the character below the other character is the second character, thereby sorting the three character boxes.

[0033] Furthermore, in S43, the list of all characters includes the list of characters for all horizontal text lines, the list of characters for all vertical text lines, or the list of characters for the direction to be confirmed.

[0034] Furthermore, S43 specifically includes:

[0035] S431: Calculate the minimum height of all character boxes, denoted as hMin;

[0036] S432: Calculate the distance of each character box from the top left, top right, bottom left, and bottom right corners of the image, and determine the top left corner character box A, top right corner character box B, bottom left corner character box C, and bottom right corner character box D based on the closest distance;

[0037] S433: Calculate the distance from each point in each character box (excluding corner character boxes) to the midpoints of A, B, C, and D in a straight line, in order from left to right and from top to bottom. This determines the characters in the first row, the m-th row, the first column, and the n-th column, where m is the total number of rows and n is the total number of columns.

[0038] S434: Compare the number of characters in the first row and the m-th row, and the number of characters in the first column and the n-th column to see if they are the same.

[0039] If the number of characters in the first row is different from the number of characters in the m-th row, then the square seal text lines are arranged horizontally, determining the characters in the second row to the (m-1)-th row, and forming a character list for all horizontal text lines from the characters in the first row to the m-th row;

[0040] If the number of characters in column 1 is different from the number of characters in column n, then the square seal text lines are arranged vertically, and the characters in columns 2 to n-1 are determined. The characters in columns 1 to n form a character list of all vertical text lines.

[0041] If the number of characters in the first row and the m-th row, and the number of characters in the first column and the n-th column are all the same, then determine the characters in the second row to the (m-1)-th column and the characters in the second column to the (n-1)-th column, and save the characters in the first row to the m-th row and the characters in the first column and the n-th column as a list of characters to be confirmed for the direction.

[0042] Furthermore, S43 specifically includes:

[0043] S431: Calculate the minimum height of all character boxes, denoted as hMin;

[0044] S432: Calculate the distance of each character box from the top left, top right, bottom left, and bottom right corners of the image, and determine the top left corner character box A, top right corner character box B, bottom left corner character box C, and bottom right corner character box D based on the closest distance;

[0045] S433: Calculate the distance from each point in each character box (excluding corner character boxes) to the midpoints of A, B, C, and D using a straight line, in order from left to right and from top to bottom. This determines the characters in the 1st row, mth row, 1st column, and nth column, along with their respective offsets charOffsetH1 and charOffsetH2. m charOffsetV1 and charOffsetV n Where m is the total number of rows and n is the total number of columns;

[0046] S434: Compare the number of characters in the first row and the m-th row, and the number of characters in the first column and the n-th column to see if they are the same.

[0047] If the number of characters in the first row is different from the number of characters in the m-th row, then the square seal text lines are arranged horizontally, and the characters in the second row to the (m-1)-th row are determined, thus obtaining a list of characters for all horizontal text lines;

[0048] If the number of characters in column 1 is different from the number of characters in column n, then the square seal text lines are arranged vertically, and the characters in columns 2 to n-1 are determined, thus obtaining a list of characters for all vertical text lines;

[0049] If the number of characters in the first row is the same as the number of characters in the m-th row, and the number of characters in the first column is the same as the number of characters in the n-th column, then proceed to the next step;

[0050] S435: Determine the characters in lines 2 through m-1 and calculate their respective offsets charOffsetH2 to charOffsetH. m-1 Transfer charOffsetH1 to charOffsetH m Add them together to get the total horizontal misalignment offset charOffsetH; determine the characters in columns 2 to (n-1) and calculate their respective offsets charOffsetV2 to charOffsetV. n-1 Transfer charOffsetV1 to charOffsetV n The sum of these values ​​gives the total vertical misalignment offset charOffsetV;

[0051] S436: Compare charOffsetsV and charOffsetsH:

[0052] If charOffsetsV > charOffsetsH*5, then the text lines of the seal are arranged horizontally, and the characters of all horizontal text lines are composed of characters from the first line to the mth line.

[0053] If charOffsetsH > charOffsetsV * 5, then the text lines of the stamp are arranged vertically, and the characters of all vertical text lines are composed of the characters in the first column and the characters in the nth column.

[0054] Otherwise, save the characters from row 1 to row m and the characters from column 1 to column n as a list of characters to be confirmed for the direction.

[0055] Further, in S433, the characters in the first row, the m-th row, the first column, and the n-th column are determined, along with their respective offsets charOffsetH1 and charOffsetH2. m charOffsetV1 and charOffsetVn Specifically, it includes:

[0056] Calculate the distance from each character box (excluding corner character boxes) to the straight line connecting the midpoints of A and B in order from left to right and from top to bottom. Take the character boxes with a distance less than 0.5 hMin and arrange them in order to get the first row. Then, take the sum of the distances between all the characters added to the first row and the straight line as the offset charOffsetH1 of the first row.

[0057] Following a left-to-right, top-to-bottom order, calculate the distance from each character box (excluding corner character boxes) to the straight line connecting the midpoints of C and D. Select character boxes with a distance less than 0.5 hMin and arrange them sequentially to obtain the m-th row. Use the sum of the distances between all characters added to the m-th row and this straight line as the offset charOffsetH for the m-th row. m ;

[0058] Calculate the distance from each character box (excluding corner character boxes) to the straight line connecting the midpoints of A and C in order from left to right and from top to bottom. Take the character boxes with a distance less than 0.5 hMin and arrange them in order to get the first column. Then, take the sum of the distances between all the characters added to the first column and the straight line as the offset charOffsetV1 of the first column.

[0059] Following a left-to-right, top-to-bottom order, calculate the distance from each character box (excluding corner character boxes) to the straight line connecting the midpoints of B and D. Select character boxes with a distance less than 0.5 hMin and arrange them sequentially to obtain the nth column. Use the sum of the distances between all characters added to the nth column and this straight line as the offset of the nth column: charOffsetV n .

[0060] Further, in S435, the characters in rows 2 to m-1 are determined and their respective offsets charOffsetH2 to charOffsetH are calculated. m-1 Specifically, it includes:

[0061] Following the order from left to right and top to bottom, calculate the distance from each remaining character frame point to the straight line connecting the first character frame point in the first column and the first character frame point in the nth column. Select character frames with a distance less than 0.5 hMin and arrange them sequentially to obtain the second row of characters. Use the sum of the distances between all characters added to the second row and this straight line as the offset charOffsetH2 for the second row, and so on, until the (m-1)th row of characters and its offset charOffsetH2 are obtained sequentially. m-1 .

[0062] Further, in S435, the characters in columns 2 to (n-1) are determined and their respective offsets charOffsetV2 to charOffsetV are calculated. n-1 Specifically, it includes:

[0063] Following the order from left to right and top to bottom, calculate the distance from each remaining character box point to the straight line connecting the first character box point in the first row and the first character box point in the m-th row. Select character boxes with a distance less than 0.5 hMin and arrange them sequentially to obtain the second column of characters. Use the sum of the distances between all characters added to the second column and this straight line as the offset of the second column (charOffsetV2), and so on, until the (n-1)th column of characters and its offset (charOffsetV2) are obtained sequentially. n-1 .

[0064] Furthermore, S44 specifically includes:

[0065] For the character list of all horizontal text lines, perform perspective transformation in order to obtain a horizontally arranged list of text lines, hLines;

[0066] For the character list of all vertical text lines, perform perspective transformation in order to obtain the vertical text line list vLines1 arranged from left to right and the vertical text line list vLines2 arranged from right to left.

[0067] For the list of characters to be confirmed in the direction, perform perspective transformation in sequence, transforming the saved characters from the first line to the mth line into a horizontally arranged text line list hLines, and transforming the saved characters in the first column and the nth column into vertically arranged text line lists vLines1 and vLines2, respectively, arranged from left to right.

[0068] Furthermore, in S45, the key words for the seal include "seal" and "print".

[0069] Furthermore, in step S45, if no seal keyword is identified, the recognition result of the vertically arranged text line list vLines2 from right to left is selected as the optimal square seal recognition result.

[0070] According to a second aspect of the technical solution of the present invention, a universal square seal recognition device with arbitrary character arrangement direction is provided. The universal square seal recognition device operates based on the universal square seal recognition method according to any of the above aspects, including:

[0071] An image receiving unit is used to receive images of square seals.

[0072] The text segmentation unit is used to perform text segmentation on the square seal image to obtain a text line mask and a character mask;

[0073] The recognition method selection unit is used to determine all text line contours based on the text line mask, calculate and determine the quality score and direction of each text line contour, thereby performing direct text line recognition or character combination into text line recognition.

[0074] The recognition method execution unit is used to perform direct recognition of text lines or recognition of text lines composed of character combinations.

[0075] The recognition result output unit is used to output the optimal square seal recognition result.

[0076] According to a third aspect of the present invention, a universal square seal recognition system with arbitrary character arrangement direction is provided, the system comprising: a processor and a memory for storing executable instructions; wherein the processor is configured to execute the executable instructions to perform the universal square seal recognition method as described in any of the preceding aspects.

[0077] According to a fourth aspect of the present invention, a computer-readable storage medium is provided, characterized in that a computer program is stored thereon, which, when executed by a processor, implements the general square seal recognition method as described in any of the preceding aspects.

[0078] The beneficial effects of this invention are:

[0079] 1. By adopting a dual-task text segmentation module, it can adaptively combine the prediction results of text line masks and character masks to flexibly handle various layouts, thus possessing strong versatility and supporting the recognition and sorting of square seal characters in any layout and with any character arrangement direction;

[0080] 2. By cutting and combining vertical text lines in the seal into horizontal text lines, the vertical text lines can be directly recognized using the horizontal text line recognition model, which greatly simplifies the recognition process and significantly improves the recognition accuracy (usually, the accuracy of the vertical text line recognition model is far inferior to that of the horizontal text line recognition model). Attached Figure Description

[0081] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the structures shown in these drawings without creative effort.

[0082] Figure 1 Examples of various types of diagrams in the prior art are shown.

[0083] Figure 2 An example diagram of the first character arrangement order in the prior art is shown.

[0084] Figure 3 An example diagram of a second character arrangement order in the prior art is shown.

[0085] Figure 4 This diagram illustrates a third character arrangement order in the prior art.

[0086] Figure 5 A flowchart illustrating a method according to an embodiment of the technical solution of the present invention is shown.

[0087] Figure 6 A schematic diagram of the program structure according to an embodiment of the technical solution of the present invention is shown.

[0088] Figure 7 This diagram illustrates a text line mask and a character mask for a seal image according to an embodiment of the present invention.

[0089] Figure 8 A schematic diagram of a text line mask and a character mask for another stamp image according to an embodiment of the technical solution of the present invention is shown.

[0090] Figure 9 A schematic diagram of a seal with three character frames is shown according to an embodiment of the technical solution of the present invention.

[0091] Figure 10 This diagram illustrates the recognition effect of a seal image according to an embodiment of the technical solution of the present invention.

[0092] Figure 11 This diagram illustrates the recognition effect of a seal image according to an embodiment of the technical solution of the present invention.

[0093] Figure 12 This diagram illustrates the recognition effect of a seal image according to an embodiment of the technical solution of the present invention.

[0094] Figure 13 This diagram illustrates the recognition effect of a seal image according to an embodiment of the technical solution of the present invention.

[0095] Figure 14 This diagram illustrates the recognition effect of a seal image according to an embodiment of the technical solution of the present invention.

[0096] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0097] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.

[0098] The terms "first," "second," etc., used in this disclosure are for distinguishing similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented, for example, in orders other than those illustrated or described herein.

[0099] Furthermore, the terms “comprising” and “having”, and any variations thereof, are intended to cover non-exclusive inclusion, such that a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units that are explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to such process, method, product, or apparatus.

[0100] Multiple, including two or more.

[0101] And / or, it should be understood that, for the purposes of this disclosure, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone.

[0102] The present invention first provides a universal square seal recognition method with arbitrary character arrangement direction, wherein the square seal has multiple lines of seal text, and the universal square seal recognition method includes the following steps:

[0103] S1 Image Reception Steps: Receive the image of the square seal.

[0104] S2 Text Segmentation Step: Perform text segmentation on the square seal image to obtain text line masks and character masks.

[0105] In a preferred embodiment, the DBNet algorithm model is used for text segmentation.

[0106] In a preferred embodiment, the real-time scene text detection algorithm model includes two identical prediction heads, which are used to output the text line mask and the character mask, respectively.

[0107] In a preferred embodiment, S2 further includes: expanding the processed and shrunken text line mask and character mask back to their original instance size.

[0108] S3 recognition method selection steps: Determine the outlines of all text lines based on the text line mask, calculate and determine the quality score and direction of each text line outline, and then perform direct text line recognition or character combination into text line recognition.

[0109] In a preferred embodiment, if the quality score of all text line contours is greater than the quality score threshold and the direction is horizontal, then the text line is directly recognized; otherwise, the text line is recognized by combining characters.

[0110] In a preferred embodiment, the quality score of the text line contour is equal to the area of ​​the text line contour divided by the area of ​​the minimum bounding rectangle of the text line contour.

[0111] In a preferred embodiment, the quality score threshold is 0.7.

[0112] In a preferred embodiment, the direction of the text line outline is determined as follows: if the width of the minimum bounding rectangle of the text line outline is greater than its height, then the text line outline is horizontal; otherwise, it is vertical.

[0113] In a preferred embodiment, in step S3, if there is no character at the character mask position corresponding to the outline of a certain text line, then the text line is a stamp anti-counterfeiting number. The smallest bounding rectangle of the anti-counterfeiting number text line is stored separately and appended to the text line for identification.

[0114] S4 recognition method execution steps: Perform direct recognition of text lines or recognition of text lines composed of character combinations.

[0115] In a preferred embodiment, in step S4, the direct recognition of the text line includes:

[0116] For all text line outlines, the smallest bounding rectangle and its coordinates are obtained. The text lines are then recognized in order from top to bottom according to their coordinates, thus obtaining the square-shaped text recognition results arranged in sequence.

[0117] In a preferred embodiment, in step S4, the character combination into text line recognition includes:

[0118] S41: Determine all character outlines based on the character mask, determine the smallest bounding rectangle of the character as the character frame based on the character outline, and determine the midpoint of each character frame;

[0119] S42: Determine the number of character boxes. If the number of character boxes is 3, sort the three character boxes and perform perspective transformations in sequence. Arrange the results into text lines from left to right for recognition. If the number of character boxes is ≥4, proceed to the next step.

[0120] S43: Determine the list of all characters;

[0121] S44: Perform a perspective transformation on all character lists in order to obtain a horizontally arranged list of text lines hLines, a vertically arranged list of text lines from left to right vLines1 and / or a vertically arranged list of text lines from right to left vLines2;

[0122] S45: Perform text line recognition on hLines, vLines1 and / or vLines2, and select the recognition result with the seal keyword at the end as the optimal square seal recognition result.

[0123] In a preferred embodiment, in step S42, the area of ​​each character box is calculated, the character with the largest area is the third character, and the character above the other two characters is the first character, and the character below the other character is the second character, thereby sorting the three character boxes.

[0124] In a preferred embodiment, in S43, the list of all characters includes a list of characters for all horizontal text lines, a list of characters for all vertical text lines, or a list of characters for the direction to be confirmed.

[0125] In a preferred embodiment, S43 specifically includes:

[0126] S431: Calculate the minimum height of all character boxes, denoted as hMin;

[0127] S432: Calculate the distance of each character box from the top left, top right, bottom left, and bottom right corners of the image, and determine the top left corner character box A, top right corner character box B, bottom left corner character box C, and bottom right corner character box D based on the closest distance;

[0128] S433: Calculate the distance from each point in each character box (excluding corner character boxes) to the midpoints of A, B, C, and D in a straight line, in order from left to right and from top to bottom. This determines the characters in the first row, the m-th row, the first column, and the n-th column, where m is the total number of rows and n is the total number of columns.

[0129] S434: Compare the number of characters in the first row and the m-th row, and the number of characters in the first column and the n-th column to see if they are the same.

[0130] If the number of characters in the first row is different from the number of characters in the m-th row, then the square seal text lines are arranged horizontally, determining the characters in the second row to the (m-1)-th row, and forming a character list for all horizontal text lines from the characters in the first row to the m-th row;

[0131] If the number of characters in column 1 is different from the number of characters in column n, then the square seal text lines are arranged vertically, and the characters in columns 2 to n-1 are determined. The characters in columns 1 to n form a character list of all vertical text lines.

[0132] If the number of characters in the first row and the m-th row, and the number of characters in the first column and the n-th column are all the same, then determine the characters in the second row to the (m-1)-th column and the characters in the second column to the (n-1)-th column, and save the characters in the first row to the m-th row and the characters in the first column and the n-th column as a list of characters to be confirmed for the direction.

[0133] In a preferred embodiment, S43 specifically includes:

[0134] S431: Calculate the minimum height of all character boxes, denoted as hMin;

[0135] S432: Calculate the distance of each character box from the top left, top right, bottom left, and bottom right corners of the image, and determine the top left corner character box A, top right corner character box B, bottom left corner character box C, and bottom right corner character box D based on the closest distance;

[0136] S433: Calculate the distance from each point in each character box (excluding corner character boxes) to the midpoints of A, B, C, and D using a straight line, in order from left to right and from top to bottom. This determines the characters in the 1st row, mth row, 1st column, and nth column, along with their respective offsets charOffsetH1 and charOffsetH2. m charOffsetV1 and charOffsetV n Where m is the total number of rows and n is the total number of columns;

[0137] S434: Compare the number of characters in the first row and the m-th row, and the number of characters in the first column and the n-th column to see if they are the same.

[0138] If the number of characters in the first row is different from the number of characters in the m-th row, then the square seal text lines are arranged horizontally, and the characters in the second row to the (m-1)-th row are determined, thus obtaining a list of characters for all horizontal text lines;

[0139] If the number of characters in column 1 is different from the number of characters in column n, then the square seal text lines are arranged vertically, and the characters in columns 2 to n-1 are determined, thus obtaining a list of characters for all vertical text lines;

[0140] If the number of characters in the first row is the same as the number of characters in the m-th row, and the number of characters in the first column is the same as the number of characters in the n-th column, then proceed to the next step;

[0141] S435: Determine the characters in lines 2 through m-1 and calculate their respective offsets charOffsetH2 to charOffsetH. m-1 Transfer charOffsetH1 to charOffsetH m Add them together to get the total horizontal misalignment offset charOffsetH; determine the characters in columns 2 to (n-1) and calculate their respective offsets charOffsetV2 to charOffsetV. n-1 Transfer charOffsetV1 to charOffsetV n The sum of these values ​​gives the total vertical misalignment offset charOffsetV;

[0142] S436: Compare charOffsetsV and charOffsetsH:

[0143] If charOffsetsV > charOffsetsH*5, then the text lines of the seal are arranged horizontally, and the characters of all horizontal text lines are composed of characters from the first line to the mth line.

[0144] If charOffsetsH > charOffsetsV * 5, then the text lines of the stamp are arranged vertically, and the characters of all vertical text lines are composed of the characters in the first column and the characters in the nth column.

[0145] Otherwise, save the characters from row 1 to row m and the characters from column 1 to column n as a list of characters to be confirmed for the direction.

[0146] In a preferred embodiment, in S433, the characters in the first row, the m-th row, the first column, and the n-th column, along with their respective offsets charOffsetH1 and charOffsetH2, are determined. m charOffsetV1 and charOffsetV n Specifically, it includes:

[0147] Calculate the distance from each character box (excluding corner character boxes) to the straight line connecting the midpoints of A and B in order from left to right and from top to bottom. Take the character boxes with a distance less than 0.5 hMin and arrange them in order to get the first row. Then, take the sum of the distances between all the characters added to the first row and the straight line as the offset charOffsetH1 of the first row.

[0148] Following a left-to-right, top-to-bottom order, calculate the distance from each character box (excluding corner character boxes) to the straight line connecting the midpoints of C and D. Select character boxes with a distance less than 0.5 hMin and arrange them sequentially to obtain the m-th row. Use the sum of the distances between all characters added to the m-th row and this straight line as the offset charOffsetH for the m-th row. m ;

[0149] Calculate the distance from each character box (excluding corner character boxes) to the straight line connecting the midpoints of A and C in order from left to right and from top to bottom. Take the character boxes with a distance less than 0.5 hMin and arrange them in order to get the first column. Then, take the sum of the distances between all the characters added to the first column and the straight line as the offset charOffsetV1 of the first column.

[0150] Following a left-to-right, top-to-bottom order, calculate the distance from each character box (excluding corner character boxes) to the straight line connecting the midpoints of B and D. Select character boxes with a distance less than 0.5 hMin and arrange them sequentially to obtain the nth column. Use the sum of the distances between all characters added to the nth column and this straight line as the offset of the nth column: charOffsetV n .

[0151] In a preferred embodiment, in S435, the characters in rows 2 to m-1 are determined and their respective offsets charOffsetH2 to charOffsetH are calculated. m-1 Specifically, it includes:

[0152] Following the order from left to right and top to bottom, calculate the distance from each remaining character frame point to the straight line connecting the first character frame point in the first column and the first character frame point in the nth column. Select character frames with a distance less than 0.5 hMin and arrange them sequentially to obtain the second row of characters. Use the sum of the distances between all characters added to the second row and this straight line as the offset charOffsetH2 for the second row, and so on, until the (m-1)th row of characters and its offset charOffsetH2 are obtained sequentially. m-1 .

[0153] In a preferred embodiment, in S435, the characters in columns 2 to (n-1) are determined and their respective offsets charOffsetV2 to charOffsetV are calculated. n-1 Specifically, it includes:

[0154] Following the order from left to right and top to bottom, calculate the distance from each remaining character box point to the straight line connecting the first character box point in the first row and the first character box point in the m-th row. Select character boxes with a distance less than 0.5 hMin and arrange them sequentially to obtain the second column of characters. Use the sum of the distances between all characters added to the second column and this straight line as the offset of the second column (charOffsetV2), and so on, until the (n-1)th column of characters and its offset (charOffsetV2) are obtained sequentially. n-1 .

[0155] In a preferred embodiment, S44 specifically includes:

[0156] For the character list of all horizontal text lines, perform perspective transformation in order to obtain a horizontally arranged list of text lines, hLines;

[0157] For the character list of all vertical text lines, perform perspective transformation in order to obtain the vertical text line list vLines1 arranged from left to right and the vertical text line list vLines2 arranged from right to left.

[0158] For the list of characters to be confirmed in the direction, perform perspective transformation in sequence, transforming the saved characters from the first line to the mth line into a horizontally arranged text line list hLines, and transforming the saved characters in the first column and the nth column into vertically arranged text line lists vLines1 and vLines2, respectively, arranged from left to right.

[0159] In a preferred embodiment, in step S45, the seal keywords include "seal" and "print".

[0160] In a preferred embodiment, in step S45, if no seal keyword is identified, the recognition result of the vertically arranged text line list vLines2 from right to left is selected as the optimal square seal recognition result.

[0161] S5 recognition result output steps: Output the optimal square seal recognition result.

[0162] The present invention also provides a universal square seal recognition device with arbitrary character arrangement direction. The universal square seal recognition device operates based on the universal square seal recognition method described above, including:

[0163] An image receiving unit is used to receive images of square seals.

[0164] The text segmentation unit is used to perform text segmentation on the square seal image to obtain a text line mask and a character mask;

[0165] The recognition method selection unit is used to determine all text line contours based on the text line mask, calculate and determine the quality score and direction of each text line contour, thereby performing direct text line recognition or character combination into text line recognition.

[0166] The recognition method execution unit is used to perform direct recognition of text lines or recognition of text lines composed of character combinations.

[0167] The recognition result output unit is used to output the optimal square seal recognition result.

[0168] The present invention provides a universal square seal recognition system with arbitrary character arrangement direction. The system includes a processor and a memory for storing executable instructions. The processor is configured to execute the executable instructions to perform the universal square seal recognition method as described in any of the above aspects.

[0169] The present invention also provides a computer-readable storage medium, characterized in that it stores a computer program thereon, which, when executed by a processor, implements the general square seal recognition method as described in any of the above aspects.

[0170] Example

[0171] This embodiment receives a square seal image. First, the seal image is input into the text segmentation module to obtain a text line mask and a character mask. Then, the two masks are sent to the recognition scheme selection module. Based on the selection result, either the direct text line recognition scheme or the character combination text line recognition scheme is used to obtain the seal recognition result.

[0172] Text Segmentation

[0173] This embodiment uses the industry-leading DBNet algorithm model to perform this text segmentation task. Other text segmentation algorithms, such as Pixellink, can also achieve similar results. The native DBNet algorithm has only one prediction head, outputting a text line mask. This embodiment adds an additional prediction head with an identical structure to this algorithm, used to output a character mask. The text line mask is used to predict instance pixels of text lines, and the character mask is used to predict instance pixels of each character in the image (for seals with anti-counterfeiting serial numbers, the character mask ignores the anti-counterfeiting serial number characters, e.g., ...). Figure 7 ). Schematic diagram as follows Figure 7 , Figure 8 As shown. Because DBNet's segmentation results have a shrinkage coefficient, the instance mask output by the model becomes small. In DBNet's post-processing stage, the mask is expanded to the original instance size.

[0174] This embodiment adds a character mask prediction head for three purposes:

[0175] 1. In many square-shaped text lines, the horizontal and vertical visual features are not clearly distinguishable, which easily leads to segmentation ambiguity and uncertainty when the segmentation model performs text line mask prediction. Adding a character mask prediction head will make the model backbone pay attention to the features of each character arrangement during training, and the features of character arrangement will help with text line mask prediction, which significantly improves the quality of text line mask prediction;

[0176] 2. If the model still cannot distinguish between horizontal and vertical text lines, the text line mask prediction quality is poor. In this case, switching to a character mask can be used. Based on the analysis of the recognition scheme selection module, a scheme can be chosen to arrange and combine characters into text lines for recognition, which can also achieve good recognition results. There are three combination schemes, as listed in the background technology section: text lines arranged horizontally from top to bottom, text lines arranged vertically from left to right, and text lines arranged vertically from right to left. The method for selecting the most reasonable combination scheme is described in the following sections.

[0177] 3. For vertical text lines, character masks are used to cut and combine the characters of the vertical text lines into horizontal text lines for recognition. This eliminates the need for a vertical text line recognition model and achieves higher recognition accuracy.

[0178] Identification scheme selection

[0179] First, based on the text line mask, find all text line outlines. If there is no character at the character mask position corresponding to a certain text line outline, it means that the text line is the anti-counterfeiting number of the seal (as described in the text segmentation module, for the anti-counterfeiting number of the seal, the text line mask predicts normally, while the character mask ignores it). Store the smallest outer rectangle of the anti-counterfeiting number text line separately for subsequent direct input into the text line recognition module for recognition.

[0180] Obtain and calculate the quality score and orientation of each text line outline, excluding the anti-counterfeiting seal number. The quality score of the outline is the ratio of the outline area to the area of ​​its smallest bounding rectangle. If the quality score is greater than the threshold of 0.7, the text line outline is considered to be of high quality; otherwise, it is considered to be of low quality. The shape of the outline is either horizontal or vertical. If the width of the smallest bounding rectangle of the outline is greater than its height, the text line outline is considered to be horizontal; otherwise, it is considered to be vertical.

[0181] If, apart from the anti-counterfeiting number, all text lines in the text line mask have high outline quality and are all horizontal, it indicates that the seal consists of horizontal text lines, and there is only one possible reading order. In this case, the direct text line recognition scheme should be used.

[0182] Otherwise, if one or more text lines in the text mask besides the anti-counterfeiting number have low outline quality, it indicates that the horizontal or vertical arrangement of the seal may be ambiguous, and a character combination text line recognition scheme should be used; if one or more text lines in the text mask have a vertical outline, it indicates that the seal may have vertical text lines, and there are multiple possible reading orders, and a character combination text line recognition scheme should be used.

[0183] Direct recognition of text lines

[0184] The recognition scheme selection module obtains the outlines of all text lines, calculates the minimum bounding rectangle, and sends them to the text line recognition module in descending order of text line coordinates for recognition. This yields the sequentially arranged seal text recognition results. If the recognition scheme selection module detects a seal anti-counterfeiting number text line, it arranges it after all other text lines and sends it to the recognition module for recognition together.

[0185] Character combination into text line recognition

[0186] First, set the target character height after perspective transformation, such as the commonly used 32 pixels or 48 pixels; this will be the target height for all perspective transformations of characters described below; the target width will be calculated based on the aspect ratio of each character box.

[0187] Based on the character mask obtained by the text segmentation module, the minimum bounding rectangle of each character outline is calculated.

[0188] Because text masking works very well for single-line text stamps, they will definitely be processed by the direct text line recognition module. Therefore, stamps that enter this scheme must be multi-line text with at least 3 characters (at least 3 characters are needed to form multi-line stamp text).

[0189] If the number of character boxes is 3 and the text is multi-line, then the seal will look like this: Figure 9 The two arrangements shown are shown.

[0190] In this case, the area of ​​each character box is calculated, and the character with the largest area is the last character. Of the remaining two characters, the one above is the first character, and the one below is the second character. Following the order of the first, second, and third characters, the characters are sequentially transformed using perspective based on their respective character boxes. The results are then arranged into a text line from left to right. If the recognition scheme selection module detects a text line containing a seal anti-counterfeiting number, it is appended to that text line and sent to the recognition module for processing.

[0191] If the number of characters is greater than or equal to 4, calculate the minimum height of all character boxes, denoted as hMin. Calculate the distance of each character box from the top-left corner of the image; the closest is the top-left corner character box, denoted as A. Similarly, calculate the top-right corner character box, denoted as B; the bottom-left corner character box, denoted as C; and the bottom-right corner character box, denoted as D. Calculate the distance from each character box's point to the line connecting the midpoints of A and B. If the distance is less than 0.5 hMin, add it to the first horizontal text line character list (excluding corner character boxes) from left to right, denoted as topLineChars. The sum of the distances between the points of all character boxes added to this list and the line is denoted as charOffsetH, serving as the horizontal misalignment offset. Similarly, calculate the last horizontal text line character list, denoted as bottomLineChars, and add the sum of the distances between the points of all character boxes added to this list and the line to charOffsetH. Similarly, extract the character list of the leftmost vertical text line, denoted as leftLineChars; extract the character list of the rightmost vertical text line, denoted as rightLineChars, and extract the vertical misalignment offset charOffsetV.

[0192] If the number of characters in `leftLineChars` is not equal to the number in `rightLineChars`, then a horizontal arrangement is impossible. If the number of characters is equal, then a straight line is formed by the first character frame point in `leftLineChars` and the first character frame point in `rightLineChars`. The distance from each character frame point to this line is calculated. If the distance is less than 0.5 `hMin`, it is added to the character list of the second horizontal text line in left-to-right order. The sum of the distances from all character frame points added to this list to their respective lines is added to `charOffsetH`. This process is repeated to sequentially calculate the character lists for all horizontal text lines and the total unaligned offset `charOffsetH` for the horizontal arrangement.

[0193] Similarly, if the number of characters contained in topLineChars is not equal to the number of characters in bottomLineChars, then a vertical arrangement is impossible. If the number of characters is equal, then the character list for all vertical text lines and the total unaligned offset charOffsetV for vertical arrangement are calculated sequentially.

[0194] If charOffsetsV > charOffsetsH * 5, it means the total misalignment offset in the vertical direction is too large, and the text on the stamp will be arranged horizontally. If charOffsetsH > charOffsetsV * 5, it means the total misalignment offset in the horizontal direction is too large, and the text on the stamp will be arranged vertically. Otherwise, the text line arrangement cannot be determined at this stage.

[0195] Therefore, the seal can have a maximum of three arrangements: text lines arranged horizontally from top to bottom, text lines arranged vertically from left to right, and text lines arranged vertically from right to left. For each text line in the character list of all obtained horizontal text lines (the text line order is already from top to bottom), the characters in that text line are transformed in perspective on the original seal image in order, and then stitched together to form a text line image; the list of text lines combined based on this arrangement is denoted as hLines. Similarly, the list of text lines arranged vertically from left to right is denoted as vLines1, and the list of text lines arranged vertically from right to left is denoted as vLines2.

[0196] hLines, vLines1, and vLines2 are each fed into the text line recognition module for recognition. Then, the following selection criteria are applied sequentially: If "Special Seal" appears at the end of one of the recognition results, that combination is selected. Otherwise, if "Seal" appears at the end of one of the recognition results, that combination is selected. Otherwise, if "Seal" appears at the end of one of the recognition results, that combination is selected. Otherwise, the most common vLines2 combination is selected.

[0197] If the identification scheme selection module finds a text line containing a seal anti-counterfeiting number, it sends that text line to the identification module for identification and inserts the identification result at the end.

[0198] Text line recognition

[0199] This embodiment uses the most mainstream CRNN text line recognition model in the industry. Only a conventional horizontal text line recognition model is used, without a vertical text line recognition model. This is because this embodiment converts vertical text lines in the seal into horizontal text lines through a character combination scheme. This avoids adding a vertical text line recognition model, simplifies the recognition process, and improves the recognition accuracy (since the number of vertical text line samples is much smaller than that of horizontal text lines, the accuracy of the trained vertical text line recognition model is far lower than that of the horizontal text line recognition model). Figures 10 to 14The diagram illustrates the recognition effect of multiple seal images according to this embodiment. It is evident that this embodiment can recognize square seals of various formats with arbitrary character arrangement directions according to the text order, exhibiting high versatility, high robustness, and high accuracy.

[0200] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0201] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0202] Through the above description of the embodiments, those skilled in the art can clearly understand that the above implementation methods can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0203] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims. All of these forms are within the protection scope of the present invention.

Claims

1. A universal square seal recognition method with arbitrary character arrangement direction, wherein the square seal has multiple lines of seal text, characterized in that, The general square seal recognition method includes the following steps: S1 Image Reception Steps: Receive the image of the square seal; S2 Text Segmentation Step: Perform text segmentation on the square seal image to obtain text line masks and character masks; S3 recognition method selection steps: Determine the outlines of all text lines based on the text line mask, calculate and determine the quality score and direction of each text line outline, and then perform direct text line recognition or character combination into text line recognition. S4 recognition method execution steps: Perform direct recognition of text lines or recognition of text lines composed of character combinations; S5 recognition result output steps: Output the optimal square seal recognition result; In the S2 text segmentation step, a real-time scene text detection algorithm model with differential binarization is used for text segmentation. The real-time scene text detection algorithm model contains two prediction heads with the same structure, which are used to output the text line mask and the character mask, respectively. The S2 text segmentation step also includes: expanding the processed and shrunken text line mask and character mask to the original instance size. In step S3, if the quality score of all text line contours is greater than the quality score threshold and the direction is horizontal, then the text line is directly recognized; otherwise, the text line is recognized by combining characters. The quality score of the text line contour is equal to the area of ​​the text line contour / the area of ​​the minimum bounding rectangle of the text line contour. The direction of the text line contour is determined as follows: if the width of the minimum bounding rectangle of the text line contour is greater than the height, then the text line contour is horizontal; otherwise, it is vertical.

2. The universal square seal recognition method according to claim 1, characterized in that, In S3, the quality score threshold is 0.

7.

3. The universal square seal recognition method according to claim 1, characterized in that, In step S4, the direct recognition of text lines includes: For all text line outlines, the smallest bounding rectangle and its coordinates are obtained. The text lines are then recognized in order from top to bottom according to their coordinates, thus obtaining the square-shaped text recognition results arranged in sequence.

4. The universal square seal recognition method according to claim 1, characterized in that, In step S4, the character combination into text line recognition includes: S41: Determine all character outlines based on the character mask, determine the smallest bounding rectangle of the character as the character frame based on the character outline, and determine the midpoint of each character frame; S42: Determine the number of character boxes. If the number of character boxes is 3, sort the three character boxes and perform perspective transformations in sequence. Arrange the results into text lines from left to right for recognition. If the number of character boxes is ≥4, proceed to the next step. S43: Determine the list of all characters; S44: Perform a perspective transformation on all character lists in order to obtain a horizontally arranged list of text lines hLines, a vertically arranged list of text lines from left to right vLines1 and / or a vertically arranged list of text lines from right to left vLines2; S45: Perform text line recognition on hLines, vLines1 and / or vLines2, and select the recognition result with the seal keyword at the end as the optimal square seal recognition result.

5. The universal square seal recognition method according to claim 4, characterized in that, In S43, the list of all characters includes the list of characters for all horizontal text lines, the list of characters for all vertical text lines, or the list of characters for the direction to be confirmed.

6. The universal square seal recognition method according to claim 4, characterized in that, Specifically, S43 includes: S431: Calculate the minimum height of all character boxes, denoted as hMin; S432: Calculate the distance of each character box from the top left, top right, bottom left, and bottom right corners of the image, and determine the top left corner character box A, top right corner character box B, bottom left corner character box C, and bottom right corner character box D based on the closest distance; S433: Calculate the distance from each point in each character box (excluding corner character boxes) to the midpoints of A, B, C, and D in a straight line, in order from left to right and from top to bottom. This determines the characters in the first row, the m-th row, the first column, and the n-th column, where m is the total number of rows and n is the total number of columns. S434: Compare the number of characters in the first row and the m-th row, and the number of characters in the first column and the n-th column to see if they are the same. If the number of characters in the first row is different from the number of characters in the m-th row, then the square seal text lines are arranged horizontally, determining the characters in the second row to the (m-1)-th row, and forming a character list for all horizontal text lines from the characters in the first row to the m-th row; If the number of characters in column 1 is different from the number of characters in column n, then the square seal text lines are arranged vertically, and the characters in columns 2 to n-1 are determined. The characters in columns 1 to n form a character list of all vertical text lines. If the number of characters in the first row and the m-th row, and the number of characters in the first column and the n-th column are all the same, then determine the characters in the second row to the (m-1)-th column and the characters in the second column to the (n-1)-th column, and save the characters in the first row to the m-th row and the characters in the first column and the n-th column as a list of characters to be confirmed for the direction.

7. The universal square seal recognition method according to claim 4, characterized in that, Specifically, S43 includes: S431: Calculate the minimum height of all character boxes, denoted as hMin; S432: Calculate the distance of each character box from the top left, top right, bottom left, and bottom right corners of the image, and determine the top left corner character box A, top right corner character box B, bottom left corner character box C, and bottom right corner character box D based on the closest distance; S433: Calculate the distance from each point in each character box (excluding corner character boxes) to the midpoints of A, B, C, and D using a straight line, in order from left to right and from top to bottom. This determines the characters in the 1st row, mth row, 1st column, and nth column, along with their respective offsets charOffsetH1 and charOffsetH2. m charOffsetV1 and charOffsetV n Where m is the total number of rows and n is the total number of columns; S434: Compare the number of characters in the first row and the m-th row, and the number of characters in the first column and the n-th column to see if they are the same. If the number of characters in the first row is different from the number of characters in the m-th row, then the square seal text lines are arranged horizontally, and the characters in the second row to the (m-1)-th row are determined, thus obtaining a list of characters for all horizontal text lines; If the number of characters in column 1 is different from the number of characters in column n, then the square seal text lines are arranged vertically, and the characters in columns 2 to n-1 are determined, thus obtaining a list of characters for all vertical text lines; If the number of characters in the first row is the same as the number of characters in the m-th row, and the number of characters in the first column is the same as the number of characters in the n-th column, then proceed to the next step; S435: Determine the characters in lines 2 through m-1 and calculate their respective offsets charOffsetH2 to charOffsetH m-1 Transfer charOffsetH1 to charOffsetH m Add them together to get the total horizontal misalignment offset charOffsetH; determine the characters in columns 2 to (n-1) and calculate their respective offsets charOffsetV2 to charOffsetV. n-1 Transfer charOffsetV1 to charOffsetV n The sum of these values ​​gives the total vertical misalignment offset charOffsetV; S436: Compare charOffsetsV and charOffsetsH: If charOffsetsV > charOffsetsH * 5, then the seal text lines are arranged horizontally, and the characters of all horizontal text lines are composed of characters from the first line to the mth line. If charOffsetsH > charOffsetsV * 5, then the text lines of the stamp are arranged vertically, and the characters of all vertical text lines are composed of the characters in the first column and the characters in the nth column. Otherwise, save the characters from row 1 to row m and the characters from column 1 to column n as a list of characters to be confirmed for the direction.

8. The universal square seal recognition method according to claim 7, characterized in that, In step S433, the characters in the first row, the m-th row, the first column, and the n-th column are determined, along with their respective offsets charOffsetH1 and charOffsetH2. m charOffsetV1 and charOffsetV n Specifically, it includes: Calculate the distance from each character box (excluding corner character boxes) to the straight line connecting the midpoints of A and B in order from left to right and from top to bottom. Take the character boxes with a distance less than 0.5 hMin and arrange them in order to get the first row. Then, take the sum of the distances between all the characters added to the first row and the straight line as the offset charOffsetH1 of the first row. Following a left-to-right, top-to-bottom order, calculate the distance from each character box (excluding corner character boxes) to the straight line connecting the midpoints of C and D. Select character boxes with a distance less than 0.5 hMin and arrange them sequentially to obtain the m-th row. Use the sum of the distances between all characters added to the m-th row and this straight line as the offset charOffsetH for the m-th row. m ; Calculate the distance from each character box (excluding corner character boxes) to the straight line connecting the midpoints of A and C in order from left to right and from top to bottom. Take the character boxes with a distance less than 0.5 hMin and arrange them in order to get the first column. Then, take the sum of the distances between all the characters added to the first column and the straight line as the offset charOffsetV1 of the first column. Following a left-to-right, top-to-bottom order, calculate the distance from each character box (excluding corner character boxes) to the straight line connecting the midpoints of B and D. Select character boxes with a distance less than 0.5 hMin and arrange them sequentially to obtain the nth column. Use the sum of the distances between all characters added to the nth column and this straight line as the offset of the nth column: charOffsetV n .

9. The universal square seal recognition method according to claim 7, characterized in that, In step S435, the characters in rows 2 to m-1 are determined and their respective offsets charOffsetH2 to charOffsetH are calculated. m-1 Specifically, it includes: Following the order from left to right and top to bottom, calculate the distance from each remaining character frame point to the straight line connecting the first character frame point in the first column and the first character frame point in the nth column. Select character frames with a distance less than 0.5 hMin and arrange them sequentially to obtain the second row of characters. Use the sum of the distances between all characters added to the second row and this straight line as the offset charOffsetH2 for the second row, and so on, until the (m-1)th row of characters and its offset charOffsetH2 are obtained sequentially. m-1 .

10. The universal square seal recognition method according to claim 7, characterized in that, In step S435, the characters in columns 2 through (n-1) are determined and their respective offsets charOffsetV2 to charOffsetV are calculated. n-1 Specifically, it includes: Following the order from left to right and top to bottom, calculate the distance from each remaining character box point to the straight line connecting the first character box point in the first row and the first character box point in the m-th row. Select character boxes with a distance less than 0.5 hMin and arrange them sequentially to obtain the characters in the second column. Use the sum of the distances between all characters added to the second column and this straight line as the offset of the second column (charOffsetV2), and so on, until the characters in the (n-1)-th column and their offsets (charOffsetV2) are obtained sequentially. n-1 .

11. The universal square seal recognition method according to claim 4, characterized in that, S44 specifically includes: For the character list of all horizontal text lines, perform perspective transformation in order to obtain a horizontally arranged list of text lines, hLines; For the character list of all vertical text lines, perform perspective transformation in order to obtain the vertical text line list vLines1 arranged from left to right and the vertical text line list vLines2 arranged from right to left. For the list of characters to be confirmed in the direction, perform perspective transformation in sequence, transforming the saved characters from the first line to the mth line into a horizontally arranged text line list hLines, and transforming the saved characters in the first column and the nth column into vertically arranged text line lists vLines1 and vLines2, respectively, arranged from left to right.

12. A universal square seal recognition device with arbitrary character arrangement direction, the universal square seal recognition device operating based on the universal square seal recognition method according to any one of claims 1 to 11, comprising: An image receiving unit is used to receive images of square seals. The text segmentation unit is used to perform text segmentation on the square seal image to obtain a text line mask and a character mask; The recognition method selection unit is used to determine all text line contours based on the text line mask, calculate and determine the quality score and direction of each text line contour, thereby performing direct text line recognition or character combination into text line recognition. The recognition method execution unit is used to perform direct recognition of text lines or recognition of text lines composed of character combinations. The recognition result output unit is used to output the optimal square seal recognition result.

13. A universal square seal recognition system with arbitrary character arrangement direction, the system comprising: A processor and a memory for storing executable instructions; wherein the processor is configured to execute the executable instructions to perform the general square seal recognition method according to any one of claims 1 to 11.

14. A computer-readable storage medium, characterized in that, It stores a computer program, which, when executed by a processor, implements the general square seal recognition method according to any one of claims 1 to 11.

Citation Information

Patent Citations

  • Seal text recognition method and device and equipment

    CN113903046A

  • Optical character reader

    JP1996190610A