Text determination method and device, computer device, and storage medium

By determining the distance between the center of gravity of the text box in the image and the reference position, the target text box is automatically identified, solving the problem of time-consuming and labor-intensive manual screening in existing technologies, and realizing fast and efficient text extraction.

CN114120344BActive Publication Date: 2025-11-25SHANGHAI SHUHE INFORMATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111477893.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-06
Publication Date
2025-11-25
Estimated Expiration
2041-12-06

AI Technical Summary

Technical Problem

When extracting target text from images, existing technologies require a lot of manpower and time for manual screening, making it difficult to efficiently obtain comprehensive and complete target text, especially in scenarios with a large amount of text.

Method used

By determining the position of each text box on the target image and using the distance between the center of gravity of the text box and the reference position, the target text box is automatically identified and determined, enabling rapid extraction of the target text.

Benefits of technology

Eliminating the need for manual rule filtering saves manpower and time, improves the speed and accuracy of target text identification, and avoids text omissions caused by manual rule filtering.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114120344B_ABST
    Figure CN114120344B_ABST
Patent Text Reader

Abstract

The application relates to a text determination method, a device, computer equipment and a storage medium. The text determination method comprises the following steps: obtaining a target picture; determining the text box positions of each text on the target picture; determining a target text box on the target picture according to the distances between the text box positions and a reference position; and determining the text of the target text box as a target text. By using the method, manual screening rules do not need to be set after the target picture is obtained each time, and the situation that the target text cannot be comprehensively and completely obtained due to the keyword limitation of the manual screening rules does not occur. In addition, the method provided by the application does not need manual processing of the text extracted from the target picture, manpower and time are saved, and the speed of determining the target text is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of text extraction, and in particular to a text determination method and device, a computer device and a storage medium. BACKGROUND

[0002] Extracting the required text from a picture for subsequent information entry or analysis is increasingly widely used in the financial industry. For example, in the judgment of anti-fraud behavior in the financial industry, the picture uploaded by the customer can be recognized by the OCR (Optical Character Recognition) technology to obtain text, and the recognized text can be compared with the existing customer information to determine the possibility of customer fraud.

[0003] In this process, the traditional technology is to recognize all the text in the picture uploaded by the customer, and then filter the text in the picture by determining the screening rules manually, such as determining the keywords and synonyms, to obtain the required target text. In the scenario where there are many texts in the picture and many texts to be extracted, a large amount of manpower and time is required to filter the target text from the mass of picture texts. SUMMARY

[0004] Therefore, it is necessary to provide a text determination method, device, computer device and storage medium capable of efficiently determining the target text to solve the above technical problems.

[0005] The text determination method provided by the present application comprises:

[0006] obtaining a target picture;

[0007] determining the text box positions of each text on the target picture;

[0008] determining a target text box on the target picture according to the distances between the text box positions and a reference position;

[0009] determining the text of the target text box as the target text.

[0010] In one embodiment, the target text box on the target picture is determined according to the distances between the text box positions and the reference position, comprising:

[0011] determining the center of gravity of each text box according to the text box positions;

[0012] determining the target text box according to the distances between the center of gravity of each text box and the reference position.

[0013] In one embodiment, the target text box is determined according to the distances between the center of gravity of each text box and the reference position, comprising:

[0014] determining the gravity center of the text box with the smallest distance from the reference position;

[0015] determining the text box corresponding to the gravity center of the text box with the smallest distance from the reference position as the target text box.

[0016] In one embodiment, the text box positions include vertex coordinates of the text boxes;

[0017] determining the gravity center of each text box according to the text box positions, including:

[0018] determining the gravity center of each text box according to the vertex coordinates of the text boxes.

[0019] In one embodiment, determining the target text box on the target picture according to the distances between the text box positions and the reference position includes:

[0020] determining the target text box with the preset text type on the target picture according to the distances between the text box positions and the reference position.

[0021] In one embodiment, the text recognition method further includes: determining a standard picture with the same page type as the target picture, and obtaining the position of a specified text box on the standard picture as the reference position; or

[0022] determining the page type of the target picture, and determining the reference position corresponding to the page type of the target picture according to a preset relationship between the page type and the reference position.

[0023] In one embodiment, determining the text box positions of each text on the target picture includes:

[0024] performing optical character recognition on the target picture to obtain text boxes of multiple texts on the target picture;

[0025] determining an origin on the target picture;

[0026] determining the text box positions according to the distances between the text boxes of each text and the origin.

[0027] A text determination apparatus provided by the present application includes:

[0028] a picture acquisition module configured to acquire a target picture;

[0029] a text box position determination module configured to determine text box positions of each text on the target picture;

[0030] a target text box determination module configured to determine a target text box on the target picture according to distances between the text box positions and a reference position;

[0031] The target text determination module is configured to determine the text of the target text box as the target text.

[0032] The computer device provided in the present application comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the following steps when executing the computer program:

[0033] obtaining a target picture;

[0034] determining the text box positions of each text on the target picture;

[0035] determining a target text box on the target picture according to the distances between the text box positions of each text and the reference position;

[0036] determining the text of the target text box as the target text.

[0037] The computer readable storage medium provided in the present application has a computer program stored thereon, and the computer program is executable on the processor to implement the following steps:

[0038] obtaining a target picture;

[0039] determining the text box positions of each text on the target picture;

[0040] determining a target text box on the target picture according to the distances between the text box positions of each text and the reference position;

[0041] determining the text of the target text box as the target text.

[0042] The text determination method, device, computer device, and storage medium described above can quickly determine the target text box by comparing the distances between the text box positions of each text on the target picture and the reference position, and thus quickly determine the target text. In this way, it is not necessary to set a manual screening rule after obtaining the target picture each time, and the situation that the target text cannot be obtained comprehensively and completely due to the limitation of the keywords of the manual screening rule will not occur. In addition, the method provided in the present application does not need to process the text extracted from the target picture manually, which saves manpower and time and improves the speed of determining the target text. BRIEF DESCRIPTION OF DRAWINGS

[0043] Figure 1 a diagram of an application environment of a text determination method of an embodiment;

[0044] Figure 2 a flowchart of a text determination method of some embodiments;

[0045] Figure 3 a flowchart of a text box position determination step in some embodiments;

[0046] Figure 4 Flowchart for some embodiments involving reference position determining step;

[0047] Figure 5 Flowchart for some embodiments involving target text box determining step;

[0048] Figure 6 Structure block diagram of text determining apparatus for one embodiment;

[0049] Figure 7 Internal structure diagram of computer device for one embodiment. DETAILED DESCRIPTION

[0050] In order to make the purposes, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application.

[0051] The steps of the text determining method provided by the present application can be executed by a server or a terminal, and are not particularly limited.

[0052] For the convenience of understanding, Figure 1 A kind of application environment is shown, wherein server 101 is used to execute the steps of text determining method, in execution process, server 101 can communicate with terminal 102 through network to obtain target picture sent by terminal 102. Server 101 can be realized by independent server or server cluster formed by multiple servers, terminal 102 can be but not limited to various personal computers, notebook computers, smart phones, tablet computers and portable wearable devices.

[0053] In some embodiments, as Figure 2 shown, the present application provides a text determining method, to the method applied to Figure 1 server 101 example is described, including steps S201, step S202, step S203 and step S204 that server 101 can execute. The steps will be described one by one below.

[0054] Step S201, obtaining target picture.

[0055] Target picture refers to the picture from which the target text needs to be extracted.

[0056] Generally, the content of the target picture can be different in different industries and in different application scenarios. The content of the target picture is determined according to business requirements, analysis requirements or information input requirements, and is not particularly limited herein. For example, the target picture can be a webpage screenshot about user information, can be a photo of a user's certificate, or can be a picture generated by some website or software about user credit limit, credit score or commercial behavior record, etc. These different pictures illustrate that the content of the target picture can be diverse.

[0057] In addition, the way of obtaining the target picture can be diverse. Generally, the terminal 102 can generate the target picture in various ways such as screen capture or shooting, and then send the target picture to the server 101, which is one of the ways for the server 101 to obtain the target picture. Taking the financial industry as an example, the server 101 can be a server of a service-type enterprise in the financial industry, and the terminal 102 can be a terminal of a customer of the service-type enterprise in the financial industry. At this time, the terminal 102 can send the target picture with customer information to the server 101, and the server 101 can determine the target text according to the obtained target picture, so as to extract the target text for archiving for verification or commercial risk analysis for improving transaction security. In addition, the terminal 102 can also obtain the target picture from other devices without generating the target picture, which depends on the actual application requirements. Figure 1 In other application environments, the server 101 can also obtain the target picture by reading the memory or other storage.

[0058] Step S202, determining the text box positions of each text on the target picture.

[0059] Generally, the optical character recognition method can be used to recognize each text on the target picture and obtain the text box of each text. The text box can be a polygon or other closed curve surrounding the text on the target picture, or can be a series of points on the target picture tightly surrounding the text. The text box position can be a coordinate representing the position of the text box in a certain coordinate system, or can be a relative position representing the relative distance and / or relative direction between the text box and a reference position.

[0060] In some embodiments, as shown in FIG. 2A, step S202 can include the following steps: Figure 3

[0061] Step S301, performing optical character recognition on the target picture to obtain the text boxes of a plurality of texts on the target picture;

[0062] Step S302, determining the origin on the target picture;

[0063] ​In step S303, the positions of the text boxes are determined according to the origin and the distances between the origin and the text boxes.

[0064] In step S302, a point on the edge of the target picture can be selected as the origin on the target picture, or a point on the center or other position of the target picture can be selected as the origin on the target picture. The position of the origin on the target picture can be represented by coordinates.

[0065] In step S303, according to the coordinates of the origin and the distances between the origin and the text boxes, the coordinates of each point of the text box can be obtained, so as to determine the position of the text box. The coordinate system involved can be a rectangular coordinate system, a polar coordinate system or other coordinate systems, which are not particularly limited.

[0066] After the processor 101 determines the positions of the text boxes in step S202, the processor 101 can perform step S203: determining the target text box on the target picture according to the distances between the positions of the text boxes and the reference position.

[0067] The aforementioned reference position is a prior position, which can be obtained by prior data analysis. When the target text is multiple, the reference position also has multiple.

[0068] Generally, before step S203 is performed, the page type involved in the target picture to be obtained in the future can be classified, and for each page type, a corresponding reference position is designed. As mentioned above, the content of the target picture can be diverse, and therefore, the page type can be determined in advance. For example, the page type to which a photo of a certain certificate belongs can be determined as page type A, and the photos (target pictures) of this certificate uploaded by different customers in the future all belong to page type A, and if the content of the obtained target picture belongs to another certificate, it can be considered as another page type, i.e., page type B.

[0069] After determining multiple page types, standard pictures corresponding to various page types can be collected in advance. The standard picture refers to a picture belonging to a certain page type and having a size and resolution within a set range. After collecting the standard pictures, the standard pictures can be subjected to text recognition by using an optical character recognition technology to obtain the text boxes of each text on the standard pictures, and then the position of the text box of the text to be extracted is determined, and the position is taken as the reference position.

[0070] More specifically, for example, for the application scenario of needing to extract the name of a customer on a target picture of a C certificate in the future, the page type to which the picture or photo of the C certificate belongs can be set as "C certificate", and then the C certificate is photographed in advance. Different angles or distances can be adopted when photographing to obtain multiple photos of the C certificate with different qualities, so that one or multiple appropriate photos are selected as standard pictures. The positions where the name of the person appears in these standard pictures are determined, and the reference positions are obtained. If the name of the customer needs to be extracted on a target picture of a D certificate in the future, the page type to which the picture or photo of the D certificate belongs can be set as "D certificate", and then the standard pictures of the "D certificate" page type are collected, and the reference positions corresponding to the "D certificate" page type are determined. Of course, in addition to classifying the page types according to the types of certificates, the page types can also be classified according to other information such as web page content, and the specific design can be made according to actual needs.

[0071] The relative positions of the texts in the standard pictures can reflect the relative positions of the texts in the target picture, and thus the positions of the target texts in the target picture (i.e., the positions of the target text boxes) can be determined by means of the positions of the text boxes of the texts to be extracted in the standard pictures (i.e., the reference positions). If the sizes of the same type of things in the standard picture and the sizes of the same type of things in the target picture are very close, and the same coordinate system is adopted for the standard picture and the target picture, the reference positions and the positions of the target text boxes will also be very close. Usually, the target picture can be cropped, scaled, rotated, or the like, so that the specifications of the target picture and the standard picture are comparable, or the target picture meets the requirements of text recognition.

[0072] For the staff, only the texts to be extracted are confirmed after the texts in the standard pictures are recognized, and thus the text box positions corresponding to the texts to be extracted, i.e., the reference positions, can be determined. Therefore, before step S203 is performed, the server 101 can also perform the following steps, as shown in FIG. 4. Figure 4

[0073] Step S401: acquiring a standard picture;

[0074] Step S402: performing optical character recognition on the standard picture to obtain the texts on the standard picture;

[0075] Step S403: determining the texts to be extracted on the standard picture according to a selection instruction, wherein the selection instruction is an instruction for selecting the texts to be extracted on the standard picture that is input by the staff on the terminal used by the staff, and the server 101 can receive the selection instruction;

[0076] Step S404: determining the text box positions corresponding to the texts to be extracted on the standard picture as the reference positions. ​

[0077] In this way, the reference position can be determined without setting complex screening rules manually, and after the target picture is obtained, the target text can be quickly determined according to the reference position.

[0078] The foregoing describes the design manner of the reference position. With the design manner, the server 101 can directly read the reference position from the memory when performing the text determination method, or can determine the reference position corresponding to the current target picture according to any of the following manners:

[0079] (1) determining a standard picture having the same page type as the target picture, and obtaining the position of a specified text box on the standard picture as the reference position. In this manner, the target picture can be matched with the standard picture to determine the same page type. The number of standard pictures having the same page type can be multiple.

[0080] (2) determining the page type of the target picture, and determining the reference position corresponding to the page type of the target picture according to a preset relationship between the page type and the reference position. In this manner, the corresponding reference position can be quickly determined by recognizing the page type of the target picture, without implementing the matching in the (1) manner.

[0081] After the server 101 determines the reference position, the distances between the positions of the text boxes of the target picture and the reference position need to be calculated, and then the target text box is determined. In some embodiments, as shown in FIG. 2B, step S203 includes: Figure 5

[0082] Step S501: determining the gravity centers of the text boxes according to the positions of the text boxes.

[0083] Step S502: determining the target text box according to the distances between the gravity centers of the text boxes and the reference position.

[0084] In this manner, the reference position is the position of the gravity center of the text box of the required extracted text on the standard picture.

[0085] After the gravity centers of the text boxes on the target picture are determined, the gravity center of the text box having the smallest distance to the reference position can be determined from the gravity centers of the text boxes, and the text box corresponding to the gravity center of the text box having the smallest distance to the reference position is determined as the target text box.

[0086] In the manner of determining the gravity center of the text box, the position of the gravity center of the text box can be different due to different shapes of the text box, and can be determined according to corresponding geometric knowledge. Generally, the gravity center of each text box can be determined according to the vertex coordinates of the text box. The following examples are given for illustration.

[0087] ​Assuming that the target picture is a rectangle, a vertex of the target picture is selected as the origin, and the coordinates of the origin are (0, 0). A text box on the target picture is a rectangle, and the coordinates of the four adjacent vertices of the text box are (x1, y1), (x2, y1), (x2, y2) and (x1, y2) according to the distances between the four vertices and the origin. At this time, the barycentric coordinates (x, y) of the text box can be determined according to formula (1) and formula (2).

[0088] x = x1 + (x2 - x1) / 2 (1)

[0089] y = y1 + (y2 - y1) / 2 (2)

[0090] After the barycentric coordinates (x, y) of the text box are calculated, the distance between (x, y) and the reference position can be further calculated.

[0091] It should be noted that when the distance between points, the distance between coordinates or the distance between positions is described in this paper, the term "distance" refers to the Euclidean distance (or Euclidean Distance).

[0092] Of course, other ways can also be used to calculate the distance between the positions of the text boxes on the target picture and the reference position. For example, the four vertices of the text box on the standard picture from which the text needs to be extracted are selected as the reference position. At this time, the four vertices of the text box on the target picture can be selected to calculate the distance, compare the position deviation of the text box on the standard picture and the text box on the target picture, and select the text box on the target picture with the smallest position deviation as the target text box. Other calculation methods are not expanded.

[0093] In some embodiments, in addition to considering the requirement of the distance between the positions of the text boxes on the target picture and the reference position, the requirement of whether the text type matches can also be considered. At this time, if the text type of the text in the target text box in the target picture matches the preset text type, it can be determined that the text of the target text box is the target text. At this time, step S203 comprises: determining the target text box with the preset text type on the target picture according to the distance between the positions of the text boxes and the reference position. The preset text type refers to the type of the text in the text box of the standard picture corresponding to the reference position. The preset text type includes but is not limited to int, float or string commonly used in the field of computer, and can be set according to actual needs.

[0094] It is supplemented that when there are multiple texts that need to be extracted on the standard picture, the reference position can be multiple, and the processor 101 will also determine multiple target text boxes from the target picture when performing step S203.

[0095] After the processor executes step S203, step S204 can be executed: determining the text of the target text box as the target text. The target text refers to the text that needs to be extracted on the target picture.

[0096] The above describes the relationship between steps S201, S202, S203 and S204 and the implementation of the main steps. The text determination method provided in the present application can quickly determine the target text box by comparing the distance between the text box position of each text on the target picture and the reference position, thereby quickly determining the target text. In this way, it is not necessary to set artificial screening rules after obtaining the target picture each time, and the situation that the target text cannot be obtained comprehensively and completely due to the limitation of the keywords of the artificial screening rules will not occur. In addition, the method provided in the present application does not need to process the text extracted from the target picture manually, thereby saving manpower and time and improving the speed of determining the target text.

[0097] In some embodiments, in order to improve the accuracy of target text determination, the parameters of the target picture can be detected, if the parameters of the target picture meet the preset conditions, steps S202-S204 are executed, if the parameters of the target picture do not meet the preset conditions, the target picture is preprocessed, and then steps S202-S204 are executed on the preprocessed target picture. The parameters of the target picture include the overall size, resolution, orientation of a specific element or size of a specific element of the target picture, and correspondingly, the preset conditions are that the parameters of the target picture are within the preset parameter range, which can be designed according to actual needs. The specific element refers to an element recognized in the target picture and also existing in the standard picture, for example, the specific element can be a certificate, a portrait or a table, etc. The way of recognizing the specific element can be various, for example, deep learning can be used for recognition. Generally, the size of the specific element in the target picture needs to be consistent with the size of the specific element in the standard picture, and the orientation of the specific element in the target picture needs to be consistent with the orientation of the specific element in the standard picture, so that when comparing the position of the text box in the target picture with the position of the text box in the standard picture (i.e. the reference position), higher accuracy can be achieved. When the size of the specific element of the target picture does not meet the preset conditions, the pre-processing of the target picture can be performed in the following way: first, the target picture is reduced or enlarged so that the size of the specific element of the target picture is consistent with the size of the specific element of the standard picture of the same page type, then the enlarged target picture is cropped according to the relative position of the specific element of the standard picture and the edge of the standard picture, so that the overall size of the cropped target picture is consistent with the size of the standard picture, and the relative position of the specific element in the cropped target picture and the edge of the target picture is consistent with the relative position of the specific element in the standard picture and the edge of the standard picture; or a certain size of background is supplemented around the reduced target picture, so that the overall size of the target picture after supplementing the background is consistent with the size of the standard picture, and the relative position of the specific element in the target picture after supplementing the background and the edge of the target picture is consistent with the relative position of the specific element in the standard picture and the edge of the standard picture. If the overall size of the target picture does not meet the preset conditions, but the size of the specific element of the target picture meets the preset conditions, the pre-processing of the target picture is to crop the target picture or supplement a certain size of background, so that the overall size of the pre-processed target picture is consistent with the size of the standard picture. When the orientation of the specific element of the target picture does not meet the preset conditions, i.e. the orientation of the specific element of the target picture is inconsistent with the orientation of the specific element of the standard picture, the pre-processing of the target picture is to rotate the target picture so that the orientation of the specific element of the target picture meets the preset conditions.

[0098] In some embodiments, after step S204 is performed, i.e., the target text is determined, the target text can be extracted and stored, and other texts on the target picture can be discarded.

[0099] It should be understood that, although Figures 2-5 the steps in the flowcharts are shown in sequence according to the arrows, the steps are not necessarily performed in the order shown by the arrows. Figures 2-5 The steps shown and the steps involved in other embodiments do not have strict order restrictions unless explicitly stated herein, and the steps can be performed in other orders. Moreover, at least a part of the steps of the foregoing embodiments can include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but can be performed at different times, and the order of the sub-steps or stages is not necessarily sequential, but can be performed in rotation or alternation with at least a part of other steps or sub-steps or stages of other steps.

[0100] In some embodiments, as Figure 6 shown, the present application provides a text determination apparatus 600, comprising:

[0101] a picture acquisition module 601, configured to acquire a target picture;

[0102] a text box position determination module 602, configured to determine text box positions of texts on the target picture;

[0103] a target text box determination module 603, configured to determine a target text box on the target picture according to distances between the text box positions and a reference position;

[0104] a target text determination module 604, configured to determine a text of the target text box as a target text.

[0105] In some embodiments, the target text box determination module 603 comprises:

[0106] a gravity center determination unit (not shown), configured to determine gravity centers of the text boxes according to the text box positions;

[0107] a distance calculation unit (not shown), configured to determine the target text box according to distances between the gravity centers of the text boxes and the reference position.

[0108] In some embodiments, the distance calculation unit determines, among the gravity centers of the text boxes, a gravity center of a text box with the smallest distance to the reference position, and determines the text box corresponding to the gravity center of the text box with the smallest distance to the reference position as the target text box.

[0109] In some embodiments, each text box position comprises a vertex coordinate of each text box; and the distance calculation unit determines the barycenter of each text box according to the vertex coordinate of each text box.

[0110] In some embodiments, the target text box determination module 603 determines the target text box with the preset text type on the target picture according to the distance between each text box position and the reference position.

[0111] In some embodiments, the text determination apparatus 600 further comprises:

[0112] a standard picture determination module (not shown) configured to determine a standard picture with a same page type as the target picture;

[0113] a reference position acquisition module (not shown) configured to acquire a position of a designated text box on the standard picture as the reference position.

[0114] In some embodiments, the text determination apparatus 600 further comprises:

[0115] a type determination module (not shown) configured to determine the page type of the target picture;

[0116] a reference position determination module (not shown) configured to determine the reference position corresponding to the page type of the target picture according to a preset relationship between the page type and the reference position.

[0117] In some embodiments, the text box position determination module 602 comprises:

[0118] an identification unit (not shown) configured to perform optical character recognition on the target picture to obtain text boxes of multiple texts on the target picture;

[0119] an origin determination unit (not shown) configured to determine an origin on the target picture;

[0120] a text box position determination unit (not shown) configured to determine each text box position according to the distance between each text box and the origin.

[0121] For specific limitations of the text determination apparatus 600, refer to the limitations of the text determination method described above, which will not be repeated here. Each module in the text determination apparatus 600 described above can be realized by software, hardware and combinations thereof in whole or in part. Each module described above can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory in the computer device in software form, so as to be called and executed by the processor to perform the operations corresponding to each module.

[0122] In some embodiments, the present application provides a computer device, which can be a server, and the internal structure diagram thereof can be as shown in Figure 7As shown in the figure. The computer device includes a processor, a memory, a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium, an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The network interface of the computer device is used to communicate with the external terminal through the network connection. The computer program is executed by the processor to implement the aforementioned text determination method.

[0123] Those skilled in the art can understand that, Figure 7 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement. Figure 7 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement.

[0124] In some embodiments, the computer device provided by the present application comprises a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented:

[0125] Obtaining a target picture;

[0126] Determining the text box positions of each text on the target picture;

[0127] According to the distance between each text box position and the reference position, determining the target text box on the target picture;

[0128] Determining the text of the target text box as the target text.

[0129] In some embodiments, when the processor executes the computer program, the step of determining the target text box on the target picture according to the distance between each text box position and the reference position comprises:

[0130] According to the position of each text box, determining the center of gravity of each text box;

[0131] According to the distance between the center of gravity of each text box and the reference position, determining the target text box.

[0132] In some embodiments, when the processor executes the computer program, the step of determining the target text box according to the distance between the center of gravity of each text box and the reference position comprises:

[0133] Among the centers of gravity of each text box, determining the center of gravity of the text box with the smallest distance from the reference position;

[0134] The text box corresponding to the center of the text box with the smallest distance from the reference position is determined as the target text box.

[0135] In some embodiments, each text box position comprises a vertex coordinate of each text box; and when the processor executes the computer program, the step of determining the center of gravity of each text box according to each text box position comprises:

[0136] The center of gravity of each text box is determined according to the vertex coordinate of each text box.

[0137] In some embodiments, when the processor executes the computer program, the step of determining the target text box on the target picture according to the distance between each text box position and the reference position comprises:

[0138] The target text box with a preset text type on the target picture is determined according to the distance between each text box position and the reference position.

[0139] In some embodiments, when the processor executes the computer program, the following steps are further implemented:

[0140] A standard picture with the same page type as the target picture is determined, and the position of a specified text box on the standard picture is obtained as the reference position; or

[0141] The page type of the target picture is determined, and the reference position corresponding to the page type of the target picture is determined according to a preset relationship between the page type and the reference position.

[0142] In some embodiments, when the processor executes the computer program, the step of determining the text box position of each text on the target picture comprises:

[0143] Optical character recognition is performed on the target picture to obtain text boxes of multiple texts on the target picture;

[0144] An origin on the target picture is determined;

[0145] Each text box position is determined according to the distance between the text box of each text and the origin.

[0146] In some embodiments, the present application further provides a computer readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the following steps are implemented:

[0147] A target picture is obtained;

[0148] Text box positions of each text on the target picture are determined;

[0149] A target text box on the target picture is determined according to the distance between each text box position and a reference position;

[0150] Determine the text of the target text box as the target text.

[0151] In some embodiments, the computer program, when executed by the processor, implements the step of determining the target text box on the target picture according to the distance between the position of each text box and the reference position, comprising:

[0152] According to the position of each text box, determine the gravity center of each text box;

[0153] According to the distance between the gravity center of each text box and the reference position, determine the target text box.

[0154] In some embodiments, the computer program, when executed by the processor, implements the step of determining the target text box according to the distance between the gravity center of each text box and the reference position, comprising:

[0155] Among the gravity centers of each text box, determine the gravity center of the text box with the smallest distance from the reference position;

[0156] Determine the text box corresponding to the gravity center of the text box with the smallest distance from the reference position as the target text box.

[0157] In some embodiments, the position of each text box comprises the vertex coordinates of each text box; in some embodiments, the computer program, when executed by the processor, implements the step of determining the gravity center of each text box according to the position of each text box, comprising:

[0158] According to the vertex coordinates of each text box, determine the gravity center of each text box.

[0159] In some embodiments, the computer program, when executed by the processor, implements the step of determining the target text box on the target picture according to the distance between the position of each text box and the reference position, comprising:

[0160] According to the distance between the position of each text box and the reference position, determine the target text box with a preset text type on the target picture.

[0161] In some embodiments, the computer program, when executed by the processor, further implements the following steps:

[0162] Determine a standard picture with the same page type as the target picture, and obtain the position of a specified text box on the standard picture as the reference position; or

[0163] Determine the page type of the target picture, and according to the relationship between the preset page type and the reference position, determine the reference position corresponding to the page type of the target picture.

[0164] In some embodiments, the computer program, when executed by the processor, implements the step of determining the position of each text box on the target picture, comprising:

[0165] Performing optical character recognition on the target picture to obtain text boxes of multiple texts on the target picture;

[0166] Determining an origin point on the target picture;

[0167] Determining positions of the text boxes according to distances between the text boxes and the origin point.

[0168] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer readable storage medium. When the computer program is executed, the computer program can include the processes of the above-mentioned embodiments. Any reference to a memory, storage, database or other medium in the embodiments provided by the present application can include a non-volatile and / or volatile memory. The non-volatile memory can include a read-only memory (ROM), a programmable ROM (PROM), an electrically programmable ROM (EPROM), an electrically erasable programmable ROM (EEPROM) or a flash memory. The volatile memory can include a random access memory (RAM) or an external cache memory. As an illustration but not limitation, the RAM is available in various forms, such as a static RAM (SRAM), a dynamic RAM (DRAM), a synchronous DRAM (SDRAM), a double data rate SDRAM (DDR SDRAM), an enhanced SDRAM (ESDRAM), a synchronous link (Synchlink) DRAM (SLDRAM), a memory bus (Rambus) direct RAM (RDRAM), a direct memory bus dynamic RAM (DRDRAM) and a memory bus dynamic RAM (RDRAM).

[0169] Any combination of the technical features in the above embodiments can be combined. To make the description simple, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combination of the technical features does not exist, it should be considered as the scope of the present application.

[0170] The above embodiments only express several implementation manners of the present application, the description is specific and detailed, but it should not be understood as a limitation on the patent scope of the present application. It should be noted that, for a person of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can be made, which are all within the protection scope of the present application. Therefore, the patent protection scope of the present application should be subject to the appended claims.

Claims

1. A method for determining text, characterized in that, The method includes: Obtain the target image; The target image is preprocessed so that the size of the preprocessed target image is consistent with the size of the standard image, and the relative positions of specific elements and edges in the preprocessed target image are consistent with the relative positions of specific elements and edges in the standard image. Determine the text box positions of each text in the preprocessed target image; Determine the page type of the target image, and based on the preset relationship between page type and reference position, determine multiple reference positions corresponding to the page type of the target image; Based on the distance between each text box position and the corresponding reference position, a target text box with a preset text type is determined on the target image; Determine the center of gravity of each text box based on its position; Among the centroids of each of the text boxes, determine the centroid of the text box that is closest to the corresponding reference position; The text box corresponding to the centroid of the text box that is closest to the corresponding reference position is identified as the target text box. The text in the target text box is determined as the target text.

2. The method according to claim 1, characterized in that, The position of each text box includes the vertex coordinates of each text box; Determining the center of gravity of each text box based on its position includes: The centroid of each text box is determined based on the vertex coordinates of each text box.

3. The method according to claim 1, characterized in that, The method further includes: A standard image with the same page type as the target image is identified, and the position of a specified text box on the standard image is obtained as the reference position.

4. The method according to claim 1, characterized in that, Determining the text box positions of each text in the preprocessed target image includes: Optical character recognition is performed on the preprocessed target image to obtain text boxes containing multiple texts on the preprocessed target image; Determine the origin point on the preprocessed target image; The position of each text box is determined based on the distance between each text box and the origin.

5. A text determining device, characterized in that, The device includes: The image acquisition module is used to acquire a target image; preprocess the target image so that the size of the preprocessed target image is consistent with the size of the standard image, and the relative positions of specific elements and edges in the preprocessed target image are consistent with the relative positions of specific elements and edges in the standard image. The text box position determination module is used to determine the text box position of each text in the target image; The target text box determination module is used to determine the page type of the target image, determine multiple reference positions corresponding to the page type of the target image based on a preset relationship between the page type and reference positions, determine target text boxes with preset text types on the target image based on the distance between each text box position and its corresponding reference position, determine the center of gravity of each text box based on the position of each text box, determine the center of gravity of the text box with the smallest distance from its corresponding reference position among the center of gravity of each text box, and determine the text box corresponding to the center of gravity of the text box with the smallest distance from its corresponding reference position as the target text box. The target text determination module is used to determine the text in the target text box as the target text.

6. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 4.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Text recognition method, device and equipment and storage medium

    CN112580499A