Text coordinate determination method and apparatus
By extracting the text outline from the text line image and using a vertical segmentation method, the coordinates of the segmentation interval of the text line are determined, solving the problem of inaccurate calculation of single character coordinates in existing technologies and achieving a higher text recognition accuracy.
Patent Information
- Application Number
- CN202310108392.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-02
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2043-02-02
AI Technical Summary
In existing technologies, the calculation results of single-character coordinates are inaccurate, making it impossible to accurately locate the position of single characters in a text line, resulting in low text recognition accuracy.
By extracting the text outline from the text line image, determining the text box coordinates, and performing vertical segmentation on the text line, updating the segmentation interval coordinates, and calculating the text coordinates based on the text box and segmentation interval coordinates, the reliance on the text recognition model is reduced.
It improves the accuracy of single-character coordinate detection, reduces the dependence on the output of the recognition model, and enhances the accuracy of character coordinate calculation.
Smart Images

Figure CN116030472B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to a method for determining text coordinates. This application also relates to a text coordinate determining apparatus, a computing device, and a computer-readable storage medium. Background Technology
[0002] With the rapid development of science and technology, text recognition technology has also continuously evolved and is widely used in various industries, such as information extraction from images and contract comparison. In text recognition technology, single-character coordinate calculation is extremely important. In information extraction scenarios, accurate single-character coordinate calculation can precisely present the extracted information to the user. Currently, single-character coordinate calculation often uses OCR text detection models combined with text recognition algorithms to detect single-character coordinates. However, existing technologies rely too heavily on model output results and cannot accurately locate the position of individual characters within a text line, leading to inaccurate single-character coordinate calculation results. Therefore, improving the accuracy of single-character coordinate detection is a pressing issue that needs to be addressed. Summary of the Invention
[0003] In view of this, embodiments of this application provide a method for determining text coordinates, used to identify the specific location of text in an image and calculate the coordinates of the text in the image. This application also relates to a text coordinate determination device, a computing device, and a computer-readable storage medium, to solve the problem of low accuracy in text coordinate recognition in the prior art.
[0004] According to a first aspect of the embodiments of this application, a method for determining text coordinates is provided, including:
[0005] Extract the text outline of the target text line from the text line image, and determine the text box coordinates of the target text line in the text line image based on the text outline;
[0006] Determine the position information corresponding to the initial text in the target text line, perform vertical segmentation on the target text line, and determine the coordinates of the segmentation interval corresponding to the target text line based on the processing result;
[0007] Update the coordinates of the segmented interval based on the location information, and determine the coordinates of the target segmented interval corresponding to the initial text based on the update result;
[0008] The text coordinates corresponding to the initial text are calculated based on the text box coordinates and the target segmentation interval coordinates.
[0009] According to a second aspect of the embodiments of this application, a text coordinate determining device is provided, comprising:
[0010] The extraction module is configured to extract the text outline of a target text line in a text line image, and determine the text box coordinates of the target text line in the text line image based on the text outline;
[0011] The segmentation module is configured to determine the position information corresponding to the initial text in the target text line, perform vertical segmentation on the target text line, and determine the coordinates of the segmentation interval corresponding to the target text line based on the processing result;
[0012] The determination module is configured to update the coordinates of the segmented interval based on the location information, and determine the coordinates of the target segmented interval corresponding to the initial text based on the update result;
[0013] The calculation module is configured to calculate the text coordinates corresponding to the initial text based on the text box coordinates and the target segmentation interval coordinates.
[0014] According to a third aspect of the embodiments of this application, a computing device is provided, including a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the processor executes the computer instructions to implement the steps of the text coordinate determination method.
[0015] According to a fourth aspect of the embodiments of this application, a computer-readable storage medium is provided that stores computer instructions, which, when executed by a processor, implement the steps of the text coordinate determination method.
[0016] The text coordinate determination method provided in this application includes: extracting the text outline of a target text line in a text line image; determining the text box coordinates of the target text line in the text line image based on the text outline; determining the position information corresponding to the initial text in the target text line; performing vertical segmentation processing on the target text line; determining the segmentation interval coordinates corresponding to the target text line based on the processing result; updating the segmentation interval coordinates based on the position information; determining the target segmentation interval coordinates corresponding to the initial text based on the update result; and calculating the text coordinates corresponding to the initial text based on the text box coordinates and the target segmentation interval coordinates.
[0017] One embodiment of this application implements a method to extract the coordinates of text boxes in a text line image, determine the segmentation interval coordinates of the target text line using a vertical segmentation method, and update the segmentation interval based on the position information of the initial text in the target text line. This makes the vertical segmentation result of the target text line more accurate, and allows for more accurate acquisition of the target segmentation interval coordinates corresponding to the initial text. Finally, based on the extracted text box coordinates and the target segmentation interval coordinates, the text coordinates of the initial text in the text line image are accurately calculated, thereby improving the accuracy of coordinate recognition of each initial text in the text line image. Attached Figure Description
[0018] Figure 1 This is a schematic diagram illustrating the effect of a text coordinate determination method provided in an embodiment of this application;
[0019] Figure 2 This is a flowchart of a text coordinate determination method provided in an embodiment of this application;
[0020] Figure 3 This is a schematic diagram illustrating a text coordinate determination method provided in an embodiment of this application;
[0021] Figure 4 This is a flowchart illustrating a text coordinate determination method for information extraction provided in an embodiment of this application;
[0022] Figure 5 This is a schematic diagram of the structure of a text coordinate determining device provided in an embodiment of this application;
[0023] Figure 6 This is a structural block diagram of a computing device provided in one embodiment of this application. Detailed Implementation
[0024] Many specific details are set forth in the following description to provide a full understanding of this application. However, this application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this application; therefore, this application is not limited to the specific embodiments disclosed below.
[0025] The terminology used in one or more embodiments of this application is for the purpose of describing particular embodiments only and is not intended to limit the scope of one or more embodiments of this application. The singular forms “a,” “the,” and “the” used in one or more embodiments of this application and in the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” used in one or more embodiments of this application refers to and includes any or all possible combinations of one or more associated listed items.
[0026] It should be understood that although the terms first, second, etc., may be used to describe various information in one or more embodiments of this application, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first may also be referred to as second without departing from the scope of one or more embodiments of this application, and similarly, second may also be referred to as first. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."
[0027] First, the terms and concepts involved in one or more embodiments of this application will be explained.
[0028] Vertical projection: In computer vision, vertical projection is frequently used for image segmentation. It allows for precise projection of the target image, facilitating subsequent segmentation. Horizontal projection is another commonly used method. The algorithm for vertical projection works as follows: Project the image along a corresponding direction, draw a straight line along that direction, count the number of black pixels perpendicular to that line (axis), and sum these counts as the value at that position on that axis. Image projection-based segmentation maps the image to this feature, determines the segmentation location based on this feature, and thus obtains the segmented target image.
[0029] OCR: OCR is a technology that uses computer vision to extract characters from electronic documents and convert them into computer-readable text data.
[0030] Currently, in applications such as image-based information extraction and contract comparison, it is often necessary to recognize images and accurately obtain the text content and coordinates within them to acquire image information or perform information comparison. In this process, the accuracy of the text coordinates is particularly important. Currently, commonly used text coordinate recognition methods include the following three:
[0031] (1) Training a single-character detection model: Most mainstream OCR text detection models use line-by-line text detection, and the output of the model is the coordinates of the text line, which cannot obtain the coordinate information of individual characters. Therefore, training a single-character coordinate detection model can output the coordinates of individual characters. However, the training data of this model needs to be labeled according to individual characters, which is extremely costly and consumes a lot of manpower and resources. In addition, the single-character detection model has high requirements for the operating environment and requires equipment with certain configurations to be used normally, otherwise the processing efficiency will be reduced.
[0032] (2) Character extraction methods: Traditional character extraction methods include connected component analysis, maximum stable extremum region, projection analysis, etc. However, these methods will reduce the accuracy of character extraction and cannot obtain accurate single character coordinates when the image background is complex, the characters are distorted, stuck together, or there is noise interference.
[0033] (3) Estimate the coordinates of single characters based on the output result of the text recognition model: This method can obtain the coordinates of single characters without training a single character detection model. At the same time, due to the combination of the output of the recognition model, it can alleviate the problem of low robustness of traditional methods to a certain extent. However, since this method only utilizes the output of the recognition model, the finally obtained coordinates of single characters are all estimated results, including the height and width of characters and the center points of characters. Therefore, there is a problem of low accuracy of the output coordinate values. If there are situations such as different widths and heights of characters or characters not being adjacent to the edge, the error of the output coordinate values will be relatively large. At the same time, this method heavily depends on the output of the recognition model. Therefore, if the recognition model is iteratively updated or replaced, it will lead to a significant decline in the output effect of the original single character coordinate calculation, and the iterative cost is high.
[0034] Based on this, in the present application, a method for determining text coordinates is provided to solve the technical problems existing in the prior art. And the present application also relates to a device for determining text coordinates, a computing device, and a computer-readable storage medium, which will be described in detail one by one in the following embodiments.
[0035] Figure 1 The effect diagram of a method for determining text coordinates provided according to an embodiment of the present application is shown. Among them, the text line image includes four characters "I love China". Now it is necessary to identify the specific positions of these characters in the text line image. Taking the lower left corner of the text line image as the origin of the coordinate system, first identify the text line in the text line image, extract the text contour of the target text line "I love China", such as Figure 1 the solid line box around the text line "I love China" in, and calculate the text box coordinates of the target text line in the text line image according to the side lengths of the text box, that is, obtain the coordinates of the text box of "I love China" in the text line image, and determine the position information of these four characters in the text line image, that is Figure 1 the dotted lines on each character in, such as the position information 1 on "I". Perform vertical projection and segmentation on "I love China", and the segmentation intervals between each character can be obtained. The segmentation intervals are Figure 1 the intervals of black pixel points between characters in, such as Figure 1 the segmentation interval 1 between "I" and "love" in, so as to know the segmentation interval coordinates corresponding to the segmentation interval 1. Update the segmentation interval coordinates based on the position information. That is, when some segmentation intervals are recognized incorrectly, they can be modified according to the position information. After determining that the segmentation intervals are okay, the target segmentation interval coordinates corresponding to each initial character can be determined, that is, the segmentation interval coordinates on both sides of each character, such as Figure 1The segmentation interval 1 on the left side and the segmentation interval 2 on the right side of "love" in the text are the target segmentation intervals of "love". If it is the first or last character of a text line, the coordinate of the target segmentation interval on the left or right side can be the starting point x1 or the ending point x2 of the text box coordinate. After determining the coordinate of the target segmentation interval corresponding to each character, the text coordinate of each character in the text line image can be calculated based on the text box coordinate and the target segmentation interval coordinate. Through the above method, the dependence on the output result of the text recognition model can be reduced, and the vertical projection segmentation result can be further adjusted and updated according to the position information corresponding to the text, so that the coordinate of the target segmentation interval corresponding to each initial text can be determined more accurately subsequently, and the accurate text coordinate can be calculated.
[0036] Figure 2 FIG. shows a flowchart of a method for determining text coordinates according to an embodiment of the present application, which specifically includes the following steps:
[0037] Step 202: Extract the text contour of the target text line in the text line image, and determine the text box coordinate of the target text line in the text line image based on the text contour.
[0038] Among them, the text line image can be understood as an image containing text. The text line image can be a photocopy of a paper document obtained by a scanner, or a photograph of a paper document obtained by a photographing device such as a camera or a mobile phone, or an electronic document. The text line image can include multiple lines of text, and each line of text can be processed during processing. After determining the target text line to be processed, the text contour of the target text line can be extracted, that is, the surrounding contour of the target text line in the text line image is determined, and the text box coordinate of the target text line in the text line image can be determined according to the side length information of the text contour. Refer to Figure 3 , Figure 3 is a processing schematic diagram of a method for determining text coordinates according to an embodiment of the present application. In Figure 3 A, the text contour of the target text line in the text line image is extracted. The text contour is the text box contour around the target text line, and the text box coordinates are determined according to the side length information of the text contour, which are (x1, x2, y1, y2) respectively.
[0039] In practical applications, if a text recognition model is used to determine the position of each character in a target text line, the first step is to perform content recognition and character segmentation on the target text line, and then calculate the text coordinates of each character based on the segmentation results. During this process, due to recognition errors in the model, accurate text coordinates cannot be obtained. However, by extracting the text outline from the text line image and calculating the text box coordinates based on the text outline, the text box coordinates can be used as the ordinate of each character, improving the accuracy of subsequent text coordinate calculations. It should be noted that the text box coordinates are based on the image coordinate system of the text line image; the subsequently calculated text coordinates are located in the same coordinate system as the text box coordinates, i.e., both are within the image coordinate system.
[0040] In a specific embodiment of this application, such as Figure 3 As shown in Figure A, the text outline of the target text line "I love China" is extracted, and the text box coordinates of the target text line in the text line image are determined based on the text outline. The text box coordinates are (x1, x2, y1, y2). Subsequently, the ordinate of each character in the target text line can be determined as (y1, y2).
[0041] Furthermore, since the text line image can be obtained through line text detection, there may be various interfering factors in the text line image that affect the calculation of text coordinates. Therefore, some preprocessing methods can be used to reduce noise interference. Specifically, before extracting the text outline of the target text line in the text line image, the method further includes: determining an initial text line image; performing color inversion processing, noise reduction processing, and / or line removal processing on the initial text line image to obtain the text line image.
[0042] The initial text line image can be understood as a text line image with noise interference, that is, a text line image before preprocessing. Preprocessing can include color inversion, noise reduction, and line removal of the text line image. By combining one or more of the above processing methods, the interference noise in the initial text line image can be removed, thereby obtaining a clear text line image.
[0043] In practical applications, for document processing scenarios, the initial text line image obtained through line text detection may contain the following noise interference factors: text lines not aligned with edges, table line interference, inconsistent text colors, noise interference, inconsistent font sizes, etc. These noise interference factors will affect the accuracy of subsequent text coordinate calculations. To address these issues, various preprocessing methods can be used, such as text line edge extraction, table line removal, and text inversion (black and white), thereby improving the accuracy of the final output text coordinates. Therefore, after obtaining the initial text line image, it can be detected to identify the types of noise interference factors present, and then preprocessed accordingly to obtain the final text line image. Specifically, the initial text line image can also be resized to facilitate subsequent preprocessing operations. It is important to note that the aspect ratio of the image must be maintained during resizing.
[0044] In one specific embodiment of this application, if the initial text line image is detected to be a white background with black text, then it is inverted; if noise is detected in the initial text line image, then it is denoised; if table lines are detected in the initial text line image, then the lines are removed.
[0045] In summary, after obtaining the initial text line image, preprocessing operations such as color inversion, noise reduction, and line removal are performed on the initial text line image to obtain a preprocessed text line image. This ensures that the text in the text line image is clear, reduces interference factors, and improves the accuracy of subsequent text coordinate calculation.
[0046] Furthermore, in order to eliminate interference factors caused by different font colors in the initial text line image, which prevent the subsequent vertical projection segmentation from being used properly, the initial text line image can be inverted. Specifically, the initial text line image inversion process includes: extracting the pixel values of the pixels in the initial text line image; determining a set of black pixels and a set of white pixels based on the pixel values; and if the number of pixels in the black pixel set is greater than the number of pixels in the white pixel set, inverting the pixel values to obtain the inverted text line image.
[0047] In this context, the pixel values of each pixel in the initial text line image can be understood as the pixel value corresponding to each individual pixel in the initial text line image. For example, the pixel value of a black pixel is 0, and the pixel value of a white pixel is 255. By determining the pixel value of each pixel, the black and white pixels in the initial text line image can be identified. The set of black pixels can be understood as the set of all black pixels in the initial text line image, and the set of white pixels can be understood as the set of all white pixels in the initial text line image. By comparing the number of pixels in the black pixel set with the number of pixels in the white pixel set, it can be determined whether the current initial text line image needs to be inverted. If inversion is required, the pixel value of each pixel is reversed. For example, if the pixel value of a black pixel is 0, after inversion, the pixel value of a black pixel is 255, so the black pixel is inverted to a white pixel. This process is performed on each pixel in the initial text line image to obtain the inverted text line image.
[0048] In practical applications, if the number of pixels in the black pixel set is greater than the number of pixels in the white pixel set, it indicates that the image background is black and the text color is white. To facilitate subsequent use of the vertical projection analysis method, the initial text line image needs to be inverted. Specifically, to avoid the presence of pixels with other pixel values in the initial text line image, it can be first converted to grayscale. Then, the black and white pixel sets are determined based on the grayscale initial text line image. When determining the black and white pixel sets, a preset pixel threshold can be used. For example, pixels greater than the preset pixel threshold of 200 are considered white pixels, and pixels less than the preset pixel threshold of 200 are considered black pixels. Then, the inversion process is performed to obtain the inverted text line image.
[0049] In a specific embodiment of this application, the initial text line image is determined to be a black background with white text. First, the initial text line image is converted to grayscale, and the pixel value of each pixel in the initial text line image is extracted. Based on a preset pixel threshold and the pixel value of each pixel, all pixels in the initial text line image are divided into black pixels and white pixels, and combined into a black pixel set and a white pixel set. If the number of black pixels is greater than the number of white pixels, the pixel value of each pixel is reversed to obtain a white background with black text text.
[0050] Based on this, by inverting the colors of the initial text line image, the font color can be adjusted to white, which facilitates subsequent vertical projection segmentation and improves the accuracy of text coordinate calculation.
[0051] Furthermore, to avoid the influence of noise in the initial text line image on subsequent text coordinate calculations, the initial text line image can be denoised. Specifically, the denoising process for the initial text line image includes: binarizing the initial text line image; and performing denoising calculations on the initial text line image and the binarized initial text line image to obtain a denoised text line image.
[0052] The binarization process can be understood as using the OTSU thresholding method to convert the initial text line image into a binary image with only black and white colors. The denoising calculation can be understood as performing an AND operation between the initial text line image and the binary text line image to obtain the denoised initial text line image, i.e., the denoised text line image.
[0053] In practical applications, after binarizing the initial text line image, a binarized initial text line image is obtained. Then, a denoising operation (AND operation) is performed between the binarized initial text line image and the original initial text line image. This means that the values of the white parts in the binarized initial text line image are retained, while the values of the black parts are directly reduced to 0. Consequently, the pixel values of some noise points also become 0, thus filtering out noise. It should be noted that denoising can be performed on the result of color inversion, i.e., denoising can be performed on the inverted text line image.
[0054] In a specific embodiment of this application, if it is determined that there are noise points in the initial text line image, then the initial text line image is subjected to denoising processing. First, the initial text line image is binarized to obtain a binarized text line image. Then, the binarized text line image is ANDed with the original initial text line image to filter out the noise points in the initial text line image, thereby obtaining a denoised text line image.
[0055] Based on this, by denoising the initial text line image, noise in the initial text line image can be filtered out, eliminating the influence of noise in the image on subsequent text recognition and text coordinate calculation, thereby improving the accuracy of text coordinate calculation.
[0056] Furthermore, to avoid the influence of table lines in the initial text line image on the recognition of text in the text line image, the initial text line image can be processed to remove lines. Specifically, the initial text line image can be processed to remove lines, including: projecting the initial text line image to determine the lines to be deleted in the initial text line image; deleting the lines to be deleted to obtain a line-removed text line image.
[0057] The projection process can be understood as either vertical or horizontal projection. After projecting the initial text line image, the vertical or horizontal lines in the initial text line image can be determined. The lines to be deleted can be understood as the lines determined in the initial text line image. By deleting the lines, the text line image after line removal can be obtained.
[0058] In practical applications, line removal processing includes vertically projecting the initial text line image, and then calculating the ratio of non-zero pixel values to the height after vertical projection. A:{p ij >0, i∈(0,1,...,w),j∈(0,1,...,h)},p ij This represents the pixel value at position j on the y-axis and position i on the x-axis. If r i If the hyperparameter value exceeds a preset threshold, then position i is considered a vertical line. The line is removed using an opening operation. This process can be understood as first performing an erosion operation on the image and then a dilation operation. Similarly, by horizontally projecting the initial text line image, horizontal lines can be determined using the above method, and then the horizontal lines can be removed using an opening operation to obtain the de-lined text line image. It should be noted that line removal can be performed on either inverted color text line images or denoised text line images.
[0059] In a specific embodiment of this application, the initial text line image is subjected to vertical projection processing and horizontal projection processing respectively to determine the vertical lines and horizontal lines in the initial text line image. Opening operation is performed on both types of lines to delete the lines to be deleted, thereby obtaining a text line image with lines removed.
[0060] In summary, by removing lines from the initial text line image, redundant lines can be deleted, preventing them from affecting subsequent text content extraction and improving the accuracy of text coordinate calculation. It should be noted that the text line image can be an inverted text line image, a denoised text line image, a line-removed text line image, or a text line image obtained after performing the above three preprocessing operations on the initial text line image.
[0061] Furthermore, to prevent inaccurate extracted text contours, edge-padding can be used for text contour extraction. Specifically, extracting the text contour of the target text line in the text line image and determining the text box coordinates of the target text line in the text line image based on the text contour includes: performing edge-padding processing on the text line image based on a preset rectangle, and determining the target text line in the edge-padding text line image; determining the text contour of the target text line based on the preset rectangle in the edge-padding text line image; determining the image coordinate system corresponding to the text line image, and calculating the text box coordinates of the target text line in the image coordinate system based on the side length information of the text contour.
[0062] The preset rectangle can be understood as a pre-defined rectangle. It is used to perform edge-padding processing on the text line image, thereby determining the target text line and its corresponding text outline within the image. Figure 3 B, Figure 3 In step B, preset rectangles are used to fill in the blank areas of the text line image. The shaded areas are represented by these preset rectangles, where the height of the larger rectangle is 'a' and the width of the smaller rectangle is 'a'. After this filling process, the target text line in the image can be determined; that is, the text line within the inscribed rectangle of the four preset rectangles is the target text line. Furthermore, based on the four preset rectangles, the text outline of the target text line can also be determined; that is, the inscribed rectangle formed by the four preset rectangles serves as the text outline of the target text line. Figure 3 The text box surrounding the target text line in A.
[0063] In practical applications, to ensure that the coordinate system of the text box coordinates and the coordinates of subsequent text is consistent, the corresponding image coordinate system can be determined based on the text line image. That is, the pixel at the bottom left corner of the text line image is used as the origin of the coordinate system, with the horizontal x-axis and the vertical y-axis. After determining the text outline of the target text line, the coordinates of the corresponding text box can be calculated based on the side length information of the text outline, such as... Figure 3 (x1, x2, y1, y2) in A.
[0064] Based on this, by using a preset rectangle to fill in the edges of the text line image, the target text line and the text outline corresponding to the target text line can be determined. The coordinates of the text box corresponding to the target text line can be calculated based on the text outline. Subsequently, the text coordinates can be calculated based on the text box coordinates, thereby improving the accuracy of the text coordinate calculation.
[0065] Step 204: Determine the position information corresponding to the initial text in the target text line, and perform vertical segmentation on the target text line. Based on the processing result, determine the coordinates of the segmentation interval corresponding to the target text line.
[0066] In this context, the initial text can be understood as each single character in the target text line, and the positional information of the initial text can be understood as the coordinate information of the initial text in the text line image. Vertical segmentation of the target text line can be understood as vertically projecting the target text line and determining the segmentation intervals between characters. After determining the segmentation intervals, the corresponding coordinates of the segmentation intervals can be determined. For details on segmentation intervals, please refer to... Figure 1 In the middle, the black areas between the characters.
[0067] In practical applications, the positional information corresponding to the initial text can be obtained with the help of a character recognition model (CRNN). Specifically, determining the positional information corresponding to the initial text in the target text line includes: inputting the text line image into the character recognition model and obtaining the positional information corresponding to the initial text in the target text line output by the character recognition model.
[0068] In this process, after outputting the text line image to the character recognition model, the output of the character recognition model includes information such as the position of the text on the x-axis, the text content, and the confidence score. The position information corresponding to the initial text in the target text line is obtained from the model output. Since the position information output by the character recognition model may be inaccurate due to image quality issues (e.g., the output position information is not exactly in the center of the text), this application does not rely on position information to calculate the text coordinates in the text line image. Instead, it uses position information to assist in determining the segmentation interval by vertically segmenting the target text line, thereby improving the accuracy of text coordinate calculation.
[0069] In a specific embodiment of this application, a text line image is input into a character recognition model to obtain the position information corresponding to each initial character in the target text line output by the character recognition model, and the target text line is vertically segmented to obtain the segmentation intervals between characters and the coordinates of the segmentation intervals.
[0070] In summary, by using a character recognition model to identify target text lines, we can obtain the positional information corresponding to each initial character in the target text line. Subsequently, the positional information can be used to determine the segmentation intervals, thereby improving the accuracy of segmentation interval determination.
[0071] Furthermore, since the positional information output by the model may contain errors, it is impossible to calculate the text coordinates corresponding to the initial text based on the positional information output by the model. Therefore, the target text line can be vertically segmented to obtain the segmentation intervals between texts. Subsequently, the text coordinates are calculated based on the segmentation intervals to improve the accuracy of text coordinate calculation. Specifically, the vertical segmentation of the target text line and the determination of the segmentation interval coordinates corresponding to the target text line based on the processing result include: performing binarization processing on the text line image and vertical segmentation processing on the binarized text line image; determining the initial segmentation interval in the vertically segmented text line image; determining the initial segmentation interval as the segmentation interval corresponding to the target text line if all pixels in the initial segmentation interval are black pixels; determining the image coordinate system corresponding to the text line image and calculating the segmentation interval coordinates in the image coordinate system, wherein the segmentation interval coordinates and the text box coordinates are located in the same coordinate system.
[0072] The process involves binarizing the text line image to obtain a binary text line image containing only black and white pixels. Then, the binary text line image undergoes vertical projection segmentation. An initial segmentation interval is determined within the vertically segmented text line image. This initial segmentation interval can be understood as the initial segmentation interval obtained from the vertical segmentation process. The initial segmentation interval may contain stroke images of the text, therefore further judgment is needed. When all pixels in the initial segmentation interval are black pixels, it indicates that the initial segmentation interval corresponds to the target text line.
[0073] In practical applications, after binarizing the image using the OTSU thresholding method to obtain a binarized text line image, vertical projection is then performed to calculate the initial segmentation interval S = {S0, S1, ..., S...}. n}. Count the number of pixels with a value of 255 in the initial segmentation interval. exist If all pixels in the initial segmentation interval are black, then position i represents the segmentation interval s between characters. i Then, this initial segmentation interval can be used as the segmentation interval corresponding to the target text line. It should be noted that there may be two consecutive initial segmentation intervals. In this case, when obtaining the segmentation interval s... i Next, it is necessary to further determine whether it is continuous with the previous segmentation interval. If it is continuous, the two segmentation intervals are merged, and the next initial segmentation interval is determined.
[0074] In a specific embodiment of this application, the text line image is binarized, and the binarized text line image is vertically segmented to determine the initial segmentation interval in the text line image. The initial segmentation interval in which all pixels are black is selected as the segmentation interval of the target text line. The coordinates of the segmentation interval are calculated in the text line image based on the start and end points of the segmentation interval.
[0075] Based on this, by performing vertical segmentation on the text line image, the segmentation intervals between characters in the target text line can be obtained. Subsequently, the text coordinates can be calculated based on the segmentation intervals, thereby improving the accuracy of text coordinate calculation.
[0076] Step 206: Update the coordinates of the segmented interval according to the location information, and determine the coordinates of the target segmented interval corresponding to the initial text based on the update result.
[0077] Updating the coordinates of the segmented intervals based on location information can be understood as filtering the segmented intervals based on location information. In practical applications, due to the left-right structure of Chinese characters and interference from background factors, vertical segmentation often results in oversegmentation, such as dividing left-right structured Chinese characters into two parts. Therefore, the segmented intervals can be further judged based on location information, thereby updating the coordinates of the segmented intervals.
[0078] In practice, each initial character can be processed individually. First, it's determined that there's a dividing interval between initial characters a and b, and the position information of initial character a is... The initial position information of the character 'b' is (Position information of the preceding character). In In this case, it means that there is a dividing interval between the initial character a and the initial character b, j start Let j be the coordinates of the starting point of the interval. end These are the coordinates of the endpoint of the divided interval.
[0079] To further eliminate interference from the left-right structure of Chinese characters that leads to oversegmentation, it is necessary to determine the segmentation intervals based on hyperparameters. Specifically, the coordinates of the segmentation intervals are updated based on the position information, and the target segmentation interval coordinates corresponding to the initial text are determined based on the update result. This includes: identifying the target text and reference text in the target text line; determining the candidate segmentation intervals of the target text and their corresponding coordinates based on the target position information of the target text and the reference position information of the reference text; obtaining the calculation parameters corresponding to the text line image and calculating the verification interval coordinates based on the calculation parameters and the target position information; verifying the coordinates of the candidate segmentation intervals based on the verification interval coordinates; and, if the coordinate verification passes, using the candidate segmentation intervals and their coordinates as the target segmentation intervals and target segmentation interval coordinates of the target text.
[0080] Here, the target text can be understood as the text whose two sides need to be divided, i.e., the initial text 'a' in the example above. The reference text can be understood as the character before or after the target text; continuing the example, the reference text is the initial text 'b'. Based on the target position information corresponding to the target text... The reference position information corresponding to the reference text is... Determine the candidate segmentation intervals of the target text and the coordinates of the corresponding candidate segmentation intervals, i.e. (j start ,j end In practical applications, since each initial character corresponds to two segmented intervals, this embodiment only describes the segmented interval on the left side of the target character. Similarly, the segmented interval on the right side of the target character can also be judged and selected using the above method. The calculation parameters corresponding to the text line image can be understood as pre-set and calculated hyperparameters, including the first calculation parameter and the second calculation parameter. By using the calculation parameters and target position information, the approximate position of the segmented interval on the left side of the target character, i.e., the verification segmented interval, can be estimated. Based on the comparison between the coordinates of the verification segmented interval and the coordinates of the candidate segmented interval, the candidate segmented interval can be verified to determine whether the candidate segmented interval is the left segmented interval of the target character. If not, the verification segmented interval is directly used as the left segmented interval of the target character.
[0081] In practice, the characters are first categorized into Chinese characters, numbers, English letters, punctuation marks, and other categories. Each category includes the aspect ratio P of the character itself. char_ratio And the approximate position P of the character recognition model's output position within the width of the Chinese character. left_ratioThe aspect ratio is used as the first calculation parameter, and position as the second. When setting the first parameter, the ratio of Chinese characters to other classes is set to 1, and the ratio of numbers, English letters, and punctuation marks is set to 0.5. The second hyperparameter is obtained through the following steps: A pre-defined dataset of labeled text line images is prepared. The annotation information for each text line image includes the text content and the coordinates of each character. The text recognition model outputs the position information of each character on the width axis, and the ratio of the distance from the left boundary of the labeled text coordinates to the width of the text itself is calculated, i.e., h. left_ratio =(pred x -gt xmin ) / w, here pred x The gt represents the positional information output by the text recognition model (converted to the coordinate system of the text line image). xmin This indicates the x-axis coordinate of the top-left corner of the text coordinate frame, where w represents the width of the text itself (gt). xmax -gt xmin Determine the category of each character (Chinese, numbers, English, punctuation, and other categories), and count h for each category. left_ratio The value is used to perform 5-class clustering using k-means, obtaining the cluster center values for each of the 5 classes; then, the cluster center values for each class are iterated through, and h values within the top 20% of each cluster center value are selected. left_ratio The hyperparameter selected is the class center with the highest number of occurrences. In summary, after determining the calculation parameters using the above method, the coordinates of the verification interval can be calculated based on the calculation parameters and target location information, thereby determining whether the candidate segmentation interval is the left segmentation interval of the target text. In this case, it means that the candidate segmentation interval is the left segmentation interval of the target text, where h m The height of the text box is calculated based on the text box's coordinates.
[0082] In a specific embodiment of this application, target text 'a' and reference text 'b' are determined in the target text line. Based on the target position information corresponding to target text 'a' and the reference position information corresponding to reference text 'b', candidate segmentation intervals between the texts and their corresponding coordinates are determined. Previously calculated parameters are obtained, and the coordinates of the candidate verification intervals are verified based on the calculation parameters and the target position information. If the verification passes, the candidate verification interval is determined to be the left segmentation interval of target text 'a'. Similarly, target text 'a' and reference text 'c' are determined, and the right segmentation interval of target text 'a' is determined based on their position information.
[0083] In summary, by calculating parameters and the initial text position information, the segmented intervals obtained by vertical segmentation can be further judged and determined, eliminating segmented intervals that are over-segmented due to vertical projection, and further improving the accuracy of subsequent text coordinate calculations.
[0084] Furthermore, if the candidate verification interval fails verification, the estimated verification segmentation interval can be directly used as the target segmentation interval for the target text. Specifically, the method also includes: if coordinate verification fails, using the coordinates of the verification interval as the coordinates of the target segmentation interval corresponding to the initial text.
[0085] In practical applications, if the candidate segmentation interval is determined to be an oversegmented interval after verification, the previously calculated verification segmentation interval is used as the segmentation interval of the target text, and the coordinates of the segmentation interval corresponding to the verification segmentation interval are used as the coordinates of the target segmentation interval corresponding to the initial text.
[0086] In a specific embodiment of this application, if the coordinate verification fails, the verification interval coordinates are used as the target segmentation interval corresponding to the initial text. That is, the verification segmentation interval coordinates are used as the target segmentation interval coordinates corresponding to the initial text, and the text coordinates corresponding to the initial text are subsequently calculated based on the target segmentation interval coordinates and the text box coordinates.
[0087] Based on this, by performing vertical projection segmentation on the text line image, the segmentation interval corresponding to the target text line can be obtained. The segmentation interval can be further filtered by calculating the parameters and the position information corresponding to the initial text to determine the target segmentation intervals on both sides of each initial text. Subsequently, the text coordinates of each initial text can be calculated based on the target segmentation intervals, thereby improving the accuracy of text coordinate calculation.
[0088] Step 208: Calculate the text coordinates corresponding to the initial text based on the text box coordinates and the target segmentation interval coordinates.
[0089] The ordinate of the initial text can be obtained from the coordinates of the text box, and the abscissa of the initial text can be obtained from the coordinates of the target segmentation intervals on both sides of the initial text. Therefore, the text coordinates of the initial text can be calculated based on the coordinates of the text box and the coordinates of the target segmentation intervals.
[0090] In a specific embodiment of this application, the vertical coordinate of the initial text is determined to be (y1, y2) based on the text box coordinates (x1, x2, y1, y2). The horizontal coordinate of the initial text is determined to be (a2, b1) based on the coordinates of the left segment (a1, a2) and the right segment (b1, b2). Therefore, the text coordinates corresponding to the initial text are (a2, b1, y1, y2).
[0091] This application provides a method for determining text coordinates, including extracting the text outline of a target text line from a text line image; determining the text box coordinates of the target text line in the text line image based on the text outline; determining the position information corresponding to an initial character in the target text line; performing vertical segmentation on the target text line; determining the segmentation interval coordinates corresponding to the target text line based on the processing result; updating the segmentation interval coordinates based on the position information; determining the target segmentation interval coordinates corresponding to the initial character based on the update result; and calculating the text coordinates corresponding to the initial character based on the text box coordinates and the target segmentation interval coordinates. By extracting the text box coordinates from the text line image, using a vertical segmentation method to determine the segmentation interval coordinates of the target text line, and updating the segmentation interval based on the position information of the initial character in the target text line, the vertical segmentation result of the target text line is made more accurate. This allows for more accurate acquisition of the target segmentation interval coordinates corresponding to the initial character. Finally, based on the extracted text box coordinates and the target segmentation interval coordinates, the text coordinates of the initial character in the text line image are accurately calculated, improving the accuracy of coordinate recognition for each initial character in the text line image.
[0092] The following is in conjunction with the appendix Figure 4 Taking the text coordinate determination method provided in this application as an example in information extraction, the text coordinate determination method will be further explained. Figure 4 This application provides a flowchart of a text coordinate determination method for information extraction according to an embodiment of the present application, which specifically includes the following steps:
[0093] Step 402: Perform edge-padding processing on the text line image based on the preset rectangle, and determine the target text line in the edge-padding text line image.
[0094] In one feasible approach, information needs to be extracted from the content of a paper document. After performing text recognition on the paper document, an initial text line image is obtained. Preprocessing operations such as color inversion, noise reduction, and line removal are performed on the initial text line image to obtain a text line image. Then, edge-padding is performed on the text line image to determine the target text line in the text line image.
[0095] Step 404: Determine the text outline of the target text line based on the preset rectangle in the text line image after edge patching.
[0096] In one feasible approach, the text outline around the target text line is determined in the padded text line image based on a preset rectangle.
[0097] Step 406: Determine the image coordinate system corresponding to the text line image, and calculate the text box coordinates of the target text line in the image coordinate system based on the side length information of the text outline.
[0098] In one feasible approach, the lower left corner of the text line image is used as the origin of the image coordinate system. The coordinates of the text outline are calculated based on the side length information of the text outline, and used as the text box coordinates of the target text line in the image coordinate system.
[0099] Step 408: Input the text line image into the character recognition model to obtain the position information of the initial characters in the target text line output by the character recognition model.
[0100] In one feasible approach, a text line image is input into a character recognition model to obtain the position information corresponding to each initial character in the target text line output by the character recognition model.
[0101] Step 410: Binarize the text line image and then perform vertical segmentation on the binarized text line image.
[0102] In one feasible approach, the text line image is binarized to obtain a binarized text line image, and then the binarized text line image is subjected to vertical projection segmentation.
[0103] Step 412: Determine the initial segmentation interval in the vertically segmented text line image; if all pixels in the initial segmentation interval are black pixels, determine the initial segmentation interval as the segmentation interval corresponding to the target text line.
[0104] In one feasible approach, after performing vertical projection segmentation, the initial segmentation interval corresponding to the target text line is determined. Based on the pixels in each initial segmentation interval, if all pixels are black, the initial segmentation interval is determined to be the segmentation interval corresponding to the target text line.
[0105] Step 414: Calculate the coordinates of the segmentation interval in the image coordinate system, where the coordinates of the segmentation interval and the coordinates of the text box are in the same coordinate system.
[0106] In one feasible approach, the coordinates of each segmented interval in the image's map are calculated.
[0107] Step 416: Update the coordinates of the segmented interval according to the location information, and determine the coordinates of the target segmented interval corresponding to the initial text based on the update result.
[0108] In one feasible approach, target text and reference text are identified within the target text line. Based on the target position information of the target text and the reference position information of the reference text, candidate segmentation intervals and their corresponding coordinates are determined between the two texts. Calculation parameters corresponding to the text line image are obtained. Verification interval coordinates are calculated based on the calculation parameters and the target position information. The verification interval coordinates are compared with the candidate segmentation interval coordinates. If verification passes, the candidate segmentation interval is determined to be the target segmentation interval of the target text, and its coordinates are used as the target segmentation interval coordinates of the target text. If verification fails, the verified segmentation interval is used as the target segmentation interval of the target text, and its coordinates are used as the target segmentation interval coordinates of the target text.
[0109] Step 418: Calculate the text coordinates corresponding to the initial text based on the text box coordinates and the target segmentation interval coordinates.
[0110] In one feasible approach, after determining the target segmentation interval coordinates of each initial character in the target text line using the method described above, the text coordinates corresponding to each initial character are calculated based on the text box coordinates and the target segmentation interval coordinates, and the text coordinates and text content are output as the information extraction results.
[0111] This application provides a method for determining text coordinates in information extraction. By extracting the coordinates of text boxes in a text line image, a vertical segmentation method is used to determine the segmentation interval coordinates of the target text line. The segmentation interval is updated based on the position information of the initial text in the target text line, making the vertical segmentation result of the target text line more accurate. Subsequently, the target segmentation interval coordinates corresponding to the initial text can be obtained more accurately. Finally, the text coordinates of the initial text in the text line image are accurately calculated based on the extracted text box coordinates and the target segmentation interval coordinates, thereby improving the accuracy of coordinate recognition of each initial text in the text line image.
[0112] Corresponding to the above method embodiments, this application also provides embodiments of a text coordinate determination device. Figure 5 A schematic diagram of a text coordinate determination device according to an embodiment of this application is shown. Figure 5 As shown, the device includes:
[0113] Extraction module 502 is configured to extract the text outline of a target text line in a text line image, and determine the text box coordinates of the target text line in the text line image based on the text outline;
[0114] The segmentation module 504 is configured to determine the position information corresponding to the initial text in the target text line, perform vertical segmentation processing on the target text line, and determine the coordinates of the segmentation interval corresponding to the target text line based on the processing result;
[0115] The determination module 506 is configured to update the coordinates of the segmented interval according to the location information, and determine the coordinates of the target segmented interval corresponding to the initial text based on the update result.
[0116] The calculation module 508 is configured to calculate the text coordinates corresponding to the initial text based on the text box coordinates and the target segmentation interval coordinates.
[0117] Optionally, the apparatus further includes a processing module configured to: determine an initial text line image; perform color inversion processing, noise reduction processing, and / or line removal processing on the initial text line image to obtain a text line image.
[0118] Optionally, the processing module is further configured to: extract pixel values of pixels in the initial text line image; determine a set of black pixels and a set of white pixels based on the pixel values; and, if the number of pixels in the black pixel set is greater than the number of pixels in the white pixel set, invert the pixel values to obtain an inverted text line image.
[0119] Optionally, the processing module is further configured to: perform binarization processing on the initial text line image; and perform denoising calculation on the initial text line image and the binarized initial text line image to obtain a denoised text line image.
[0120] Optionally, the processing module is further configured to: perform projection processing on the initial text line image to determine the lines to be deleted in the initial text line image; and perform deletion processing on the lines to be deleted to obtain a text line image with lines removed.
[0121] Optionally, the extraction module 502 is further configured to: perform edge-padding processing on the text line image based on a preset rectangle, and determine the target text line in the edge-padding text line image; determine the text outline of the target text line based on the preset rectangle in the edge-padding text line image; determine the image coordinate system corresponding to the text line image, and calculate the text box coordinates of the target text line in the image coordinate system according to the side length information of the text outline.
[0122] Optionally, the segmentation module 504 is further configured to: input the text line image into the character recognition model to obtain the position information corresponding to the initial characters in the target text line output by the character recognition model.
[0123] Optionally, the segmentation module 504 is further configured to: perform binarization processing on the text line image, and perform vertical segmentation processing on the binarized text line image; determine an initial segmentation interval in the vertically segmented text line image; if all pixels in the initial segmentation interval are black pixels, determine that the initial segmentation interval is the segmentation interval corresponding to the target text line; determine the image coordinate system corresponding to the text line image, and calculate the segmentation interval coordinates in the image coordinate system, wherein the segmentation interval coordinates and the text box coordinates are located in the same coordinate system.
[0124] Optionally, the determining module 506 is further configured to: determine target text and reference text in the target text line; determine the candidate segmentation interval of the target text and the coordinates of the candidate segmentation interval corresponding to the candidate segmentation interval based on the target position information corresponding to the target text and the reference position information corresponding to the reference text; obtain the calculation parameters corresponding to the text line image, and calculate the verification interval coordinates based on the calculation parameters and the target position information; perform coordinate verification on the coordinates of the candidate segmentation interval based on the verification interval coordinates; and if the coordinate verification is successful, use the candidate segmentation interval and the coordinates of the candidate segmentation interval as the target segmentation interval and the target segmentation interval coordinates of the target text.
[0125] Optionally, the determining module 506 is further configured to: if the coordinate verification fails, use the verification interval coordinates as the target segmentation interval coordinates corresponding to the initial text.
[0126] This application provides a text coordinate determination device, comprising: an extraction module configured to extract the text outline of a target text line in a text line image and determine the text box coordinates of the target text line in the text line image based on the text outline; a segmentation module configured to determine the position information corresponding to an initial character in the target text line and perform vertical segmentation processing on the target text line, and determine the segmentation interval coordinates corresponding to the target text line based on the processing result; a determination module configured to update the segmentation interval coordinates based on the position information and determine the target segmentation interval coordinates corresponding to the initial character based on the update result; and a calculation module configured to calculate the text coordinates corresponding to the initial character based on the text box coordinates and the target segmentation interval coordinates. By extracting the text box coordinates in the text line image, using a vertical segmentation method to determine the segmentation interval coordinates of the target text line, and updating the segmentation interval based on the position information of the initial character in the target text line, the vertical segmentation result of the target text line is made more accurate, and the target segmentation interval coordinates corresponding to the initial character can be obtained more accurately subsequently. Finally, the text coordinates of the initial character in the text line image are accurately calculated based on the extracted text box coordinates and the target segmentation interval coordinates, thereby improving the coordinate recognition accuracy of each initial character in the text line image.
[0127] The above is a schematic scheme of a text coordinate determination device according to this embodiment. It should be noted that the technical solution of this text coordinate determination device and the technical solution of the text coordinate determination method described above belong to the same concept. For details not described in detail in the technical solution of the text coordinate determination device, please refer to the description of the technical solution of the text coordinate determination method described above.
[0128] Figure 6 A structural block diagram of a computing device 600 according to an embodiment of this application is shown. The components of the computing device 600 include, but are not limited to, a memory 610 and a processor 620. The processor 620 is connected to the memory 610 via a bus 630, and a database 650 is used to store data.
[0129] The computing device 600 also includes an access device 640, which enables the computing device 600 to communicate via one or more networks 660. Examples of these networks include a Public Switched Telephone Network (PSTN), a Local Area Network (LAN), a Wide Area Network (WAN), a Personal Area Network (PAN), or a combination of communication networks such as the Internet. The access device 640 may include one or more of any type of wired or wireless network interface (e.g., a Network Interface Card (NIC)), such as an IEEE 802.11 Wireless Local Area Network (WLAN) interface, a Wi-MAX interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a Near Field Communication (NFC) interface, and so on.
[0130] In one embodiment of this application, the aforementioned components of the computing device 600 and Figure 6 Other components, not shown, can also be connected to each other, for example, via a bus. It should be understood that... Figure 6 The block diagram of the computing device shown is for illustrative purposes only and is not intended to limit the scope of this application. Those skilled in the art can add or replace other components as needed.
[0131] The computing device 600 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or PCs. The computing device 600 can also be a mobile or stationary server.
[0132] The processor 620 executes the computer instructions to implement the steps of the text coordinate determination method.
[0133] The above is a schematic representation of a computing device according to this embodiment. It should be noted that the technical solution of this computing device and the technical solution of the text coordinate determination method described above belong to the same concept. Details not described in detail in the technical solution of the computing device can be found in the description of the technical solution of the text coordinate determination method described above.
[0134] An embodiment of this application also provides a computer-readable storage medium storing computer instructions that, when executed by a processor, implement the steps of the text coordinate determination method described above.
[0135] The above is an illustrative scheme of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium and the technical solution of the above-described text coordinate determination method belong to the same concept. For details not described in detail in the technical solution of the storage medium, please refer to the description of the technical solution of the above-described text coordinate determination method.
[0136] The foregoing has described specific embodiments of this application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired results. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0137] The computer instructions include computer program code, which may be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium may be appropriately added to or subtracted according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media may not include electrical carrier signals and telecommunication signals.
[0138] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0139] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0140] The preferred embodiments disclosed above are merely illustrative of this application. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the content of this application. These embodiments are selected and specifically described in this application to better explain the principles and practical applications of this application, thereby enabling those skilled in the art to better understand and utilize this application. This application is limited only by the claims and their full scope and equivalents.
Claims
1. A method for determining text coordinates, characterized in that, include: Extract the text outline of the target text line from the text line image, and determine the text box coordinates of the target text line in the text line image based on the text outline; Determine the position information corresponding to the initial text in the target text line, perform vertical segmentation on the target text line, and determine the coordinates of the segmentation interval corresponding to the target text line based on the processing result; Based on the target text and reference text in the target text line, the candidate segmentation intervals of the target text and the coordinates of the candidate segmentation intervals are determined. The coordinates of the candidate segmentation intervals are verified based on the verification interval coordinates. The target segmentation interval coordinates are determined based on the verification results. The verification interval coordinates are obtained based on the calculation parameters corresponding to the text line image and the target position information corresponding to the target text. The text coordinates corresponding to the initial text are calculated based on the text box coordinates and the target segmentation interval coordinates.
2. The method as described in claim 1, characterized in that, Before extracting the text outline of the target text line from the text line image, the method further includes: Determine the initial text line image; The initial text line image is subjected to color inversion, noise reduction, and / or line removal to obtain a text line image.
3. The method as described in claim 2, characterized in that, Inverting the initial text line image includes: Extract the pixel values of the pixels in the initial text line image; The set of black pixels and the set of white pixels are determined based on the pixel values; If the number of pixels in the black pixel set is greater than the number of pixels in the white pixel set, the pixel values are inverted to obtain an inverted text line image.
4. The method as described in claim 2, characterized in that, The initial text line image is subjected to denoising processing, including: The initial text line image is binarized; Denoising calculations are performed on the initial text line image and the binarized initial text line image to obtain a denoised text line image.
5. The method as described in claim 2, characterized in that, The initial text line image is subjected to line removal processing, including: The initial text line image is projected to determine the lines to be deleted in the initial text line image; The lines to be deleted are then deleted to obtain a text line image with the lines removed.
6. The method as described in claim 1, characterized in that, Extracting the text outline of a target text line from a text line image, and determining the text box coordinates of the target text line in the text line image based on the text outline, includes: The text line image is padded with edges based on a preset rectangle, and the target text line is determined in the padded text line image. The text outline of the target text line is determined based on the preset rectangle in the text line image after edge patching; Determine the image coordinate system corresponding to the text line image, and calculate the text box coordinates of the target text line in the image coordinate system based on the side length information of the text outline.
7. The method as described in claim 1, characterized in that, Determining the position information corresponding to the initial text in the target text line includes: The text line image is input into the character recognition model to obtain the position information corresponding to the initial characters in the target text line output by the character recognition model.
8. The method as described in claim 1, characterized in that, The target text line is vertically segmented, and the coordinates of the segmentation interval corresponding to the target text line are determined based on the processing result, including: The text line image is binarized, and the binarized text line image is then vertically segmented. Determine the initial segmentation interval in the vertically segmented text line image; If all pixels in the initial segmentation interval are black pixels, the initial segmentation interval is determined to be the segmentation interval corresponding to the target text line; Determine the image coordinate system corresponding to the text line image, and calculate the segmentation interval coordinates in the image coordinate system, wherein the segmentation interval coordinates and the text box coordinates are located in the same coordinate system.
9. The method as described in claim 1, characterized in that, Based on the target text and reference text in the target text line, determine the candidate segmentation intervals of the target text and the coordinates of the corresponding candidate segmentation intervals. Verify the coordinates of the candidate segmentation intervals based on the verification interval coordinates. Determine the coordinates of the target segmentation interval based on the verification results, including: Identify the target text and reference text within the target text line; Based on the target position information corresponding to the target text and the reference position information corresponding to the reference text, determine the candidate segmentation interval of the target text and the coordinates of the candidate segmentation interval corresponding to the candidate segmentation interval; Obtain the calculation parameters corresponding to the text line image, and calculate the verification interval coordinates based on the calculation parameters and the target location information; The coordinates of the candidate segmentation interval are verified based on the verification interval coordinates; If the coordinate verification is successful, the candidate segmentation interval and the coordinates of the candidate segmentation interval are used as the target segmentation interval and the target segmentation interval coordinates of the target text.
10. The method as described in claim 9, characterized in that, The method further includes: If the coordinate verification fails, the coordinates of the verification interval will be used as the target segmentation interval coordinates corresponding to the initial text.
11. A text coordinate determining device, characterized in that, include: The extraction module is configured to extract the text outline of a target text line in a text line image, and determine the text box coordinates of the target text line in the text line image based on the text outline; The segmentation module is configured to determine the position information corresponding to the initial text in the target text line, perform vertical segmentation on the target text line, and determine the coordinates of the segmentation interval corresponding to the target text line based on the processing result; The determination module is configured to determine the candidate segmentation interval of the target text and the coordinates of the candidate segmentation interval corresponding to the candidate segmentation interval based on the target text and reference text in the target text line, perform coordinate verification on the coordinates of the candidate segmentation interval based on the verification interval coordinates, and determine the target segmentation interval coordinates based on the verification result. The verification interval coordinates are obtained based on the calculation parameters corresponding to the text line image and the target position information corresponding to the target text. The calculation module is configured to calculate the text coordinates corresponding to the initial text based on the text box coordinates and the target segmentation interval coordinates.
12. A computing device, comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, characterized in that, When the processor executes the computer instructions, it implements the steps of the method according to any one of claims 1-10.
13. A computer-readable storage medium storing computer instructions, characterized in that, When executed by a processor, the computer instructions implement the steps of the method according to any one of claims 1-10.
Citation Information
Patent Citations
File image segmentation method and device, computer device and storage medium
CN110728687A
Document recognition method and device, computer equipment and storage medium
CN112580594A
Method and device for detecting single character in image, electronic equipment and storage medium
CN115294590A