Image processing method and related equipment
Predict text geometric information through curve fitting and neural network, determine the polygonal text box and correct its edges, solve the problem of curved and perspective text recognition, improve the recognition accuracy and robustness, and achieve efficient recognition of curved text.
Patent Information
- Application Number
- CN202310217833.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-28
- Publication Date
- 2024-08-30
AI Technical Summary
It is difficult for existing technology to effectively recognize text images with bends and perspectives, resulting in recognition results containing garbled characters and a lack of mature solutions.
The polygonal text box of the image is determined through curve fitting, and text recognition is performed based on the text box. A neural network is used to predict the geometric information of the text data, including centerline mask, radius and end side inclination angle, and the text box is corrected to improve recognition accuracy. .
It improves the accuracy of curved text recognition, avoids parameter estimation errors, improves algorithm robustness, makes the polygonal text box closer to the actual text shape, and solves the problem of inaccurate recognition of the beginning and end of curved and perspective text.
Smart Images

Figure CN118570829A
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of artificial intelligence, and in particular, to an image processing method and related equipment. Background Art
[0002] Artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a branch of computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is also the study of the design principles and implementation methods of various intelligent machines, so that machines have the functions of perception, reasoning and decision-making. Research in the field of artificial intelligence includes robotics, natural language processing, computer vision, decision-making and reasoning, human-computer interaction, recommendation and search, basic AI theory, etc.
[0003] At present, image text extraction technology based on optical character recognition (OCR) has been widely used in people's daily lives. The well-known ID card / bank card number recognition and license plate recognition all use OCR technology. However, for text line images with curves and perspectives (such as artistic store signs, arc-shaped packaging cans, wrinkled books, etc.), there is currently no mature solution in the industry. In most cases, if the straight text OCR technology is directly used, the final recognized content will contain garbled characters.
[0004] Therefore, how to recognize curved text is a technical problem that needs to be solved urgently. Summary of the invention
[0005] The present application provides an image processing method for improving the recognition accuracy of curved text in an image.
[0006] The first aspect of the embodiment of the present application provides an image processing method, which can be applied to scenarios such as text recognition. The method can be executed by an image processing device, or by a component of the image processing device (such as a processor, a chip, or a chip system, etc.). The method includes: acquiring an image, the image including text data; determining a first polygonal text box of the image based on curve fitting; and determining a text recognition result of the image based on the first polygonal text box.
[0007] In the embodiment of the present application, a polygonal text box of text data is determined by curve fitting, and then the recognition result of the text data is determined based on the polygonal text box. Since curve fitting is adopted, the risk of parameter estimation error is avoided, the robustness of the algorithm is improved, and the polygonal text box is closer to the curved text.
[0008] Optionally, in a possible implementation of the first aspect, the above steps: determining the first polygonal text box of the image based on curve fitting, include: predicting geometric information of the text data, the geometric information including the centerline mask of the area where the text data is located and the radius of the area; constructing a centerline equation based on the centerline mask, the centerline equation is used to represent the relationship between the horizontal coordinate and the vertical coordinate of any point on the centerline mask; determining the first polygonal text box based on the centerline equation and the radius.
[0009] In this possible implementation, curve fitting is used to estimate the text centerline equation, which is more robust and more accurate than the model's pixel-by-pixel regression of the text line contour or centerline contour.
[0010] Optionally, in a possible implementation of the first aspect, the above step: determining the first polygonal text box based on the center line equation and the radius includes: determining the upper and lower edge point pairs based on the center line equation and the radius; determining the first polygonal text box based on the upper and lower edge point pairs.
[0011] In this possible implementation, the first polygonal text box can be obtained by using the center line equation and the upper and lower edge point pairs determined by the radius.
[0012] Optionally, in a possible implementation of the first aspect, the above-mentioned geometric information also includes: an end-side inclination angle of the area; determining a text recognition result of the image based on a first polygonal text box, including: correcting the first polygonal text box based on the end-side inclination angle to obtain a second polygonal text box; and determining the text recognition result based on the second polygonal text box.
[0013] In this possible implementation, the effect of the end-side tilt correction on the subsequent correction is taken into account during the normalization of the text box, thereby improving the recognition effect at both ends of the curved text. The end-side tilt is used to correct the edges of the text to solve the problem of inaccurate prediction of the beginning and end of curved and perspective text. Different from the prior art, which defaults to the edges of both ends of the text line being perpendicular to the center line, the left and right edges of the text line in most perspective scenes are not orthogonal to the center line. Therefore, special estimation of the end-side tilt can greatly improve the detection and recognition effect of arc-shaped, trapezoidal, and parallelogram text.
[0014] Optionally, in a possible implementation of the first aspect, the above step: predicting geometric information of text data includes: predicting geometric information based on a neural network, the neural network includes a first structure and a second structure, the first structure is used to predict a centerline mask, and the second structure is used to predict a radius and an end side tilt angle.
[0015] In this possible implementation, since the centerline mask is a binary classification task, and the radius and the end roll angle are regression problems, better prediction results can be obtained by predicting separately through the two branches of the neural network.
[0016] Optionally, in a possible implementation of the first aspect, the above step: determining the text recognition result of the image based on the polygonal text box includes: converting the text data into a horizontal rectangular image based on the first polygonal text box; and identifying the horizontal rectangular image to obtain the text recognition result.
[0017] In this possible implementation, the polygonal text box is adjusted horizontally to meet the input requirements of the OCR model.
[0018] The second aspect of the embodiment of the present application provides an image processing device. The image processing device includes: an acquisition unit, used to acquire an image, the image including text data; a determination unit, used to determine a first polygonal text box of the image based on curve fitting; and the determination unit is also used to determine a text recognition result of the image based on multiple polygonal text boxes.
[0019] Optionally, in a possible implementation of the second aspect, the above-mentioned determination unit is specifically used to predict geometric information of text data, the geometric information including the centerline mask of the area where the text data is located and the radius of the area; the determination unit is specifically used to construct a centerline equation based on the centerline mask, and the centerline equation is used to represent the relationship between the horizontal coordinate and the vertical coordinate of any point on the centerline mask; the determination unit is specifically used to determine the first polygonal text box based on the centerline equation and the radius.
[0020] Optionally, in a possible implementation of the second aspect, the above-mentioned determination unit is specifically used to determine the upper and lower edge point pairs based on the center line equation and the radius; the determination unit is specifically used to determine the first polygonal text box based on the upper and lower edge point pairs.
[0021] Optionally, in a possible implementation of the second aspect, the above-mentioned geometric information also includes: an end side inclination angle of the area; a determination unit, specifically used to correct the first polygonal text box based on the end side inclination angle to obtain a second polygonal text box; a determination unit, specifically used to determine the text recognition result based on the second polygonal text box.
[0022] Optionally, in a possible implementation of the second aspect, the above-mentioned determination unit is specifically used to predict geometric information based on a neural network, the neural network includes a first structure and a second structure, the first structure is used to predict a centerline mask, and the second structure is used to predict a radius and an end side tilt angle.
[0023] Optionally, in a possible implementation of the second aspect, the above-mentioned determination unit is specifically used to convert text data into a horizontal rectangular image based on the first polygonal text box; the determination unit is specifically used to identify the horizontal rectangular image to obtain a text recognition result.
[0024] The third aspect of the present application provides an image processing device, including: a processor, the processor is coupled to a memory, the memory is used to store programs or instructions, when the program or instructions are executed by the processor, the image processing device implements the method in the above-mentioned first aspect or any possible implementation method of the first aspect.
[0025] A fourth aspect of the present application provides a computer-readable medium having a computer program or instruction stored thereon. When the computer program or instruction is executed on a computer, the computer executes the method in the aforementioned first aspect or any possible implementation of the first aspect.
[0026] A fifth aspect of the present application provides a computer program product. When the computer program product is executed on a computer, it enables the computer to execute the method in the aforementioned first aspect or any possible implementation manner of the first aspect.
[0027] A sixth aspect of an embodiment of the present application provides a chip system, which includes at least one processor for supporting an image processing device to implement the functions involved in the above-mentioned first aspect or any possible implementation method of the first aspect.
[0028] In a possible design, the chip system may also include a memory for storing program instructions and data necessary for the image processing device. The chip system may be composed of a chip, or may include a chip and other discrete devices. Optionally, the chip system also includes an interface circuit, which provides program instructions and / or data for the at least one processor.
[0029] Among them, the technical effects brought about by the second, third, fourth, fifth, and sixth aspects or any possible implementation methods thereof can refer to the technical effects brought about by the first aspect or different possible implementation methods of the first aspect, and will not be repeated here.
[0030] From the above technical solution, it can be seen that the present application has the following advantages: the polygonal text box of the text data is determined by curve fitting, and then the recognition result of the text data is determined based on the polygonal text box. Due to the use of curve fitting, the risk of parameter estimation error is avoided, the robustness of the algorithm is improved, and the polygonal text box is closer to the curved text. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 A schematic diagram of the structure of the system architecture provided in the embodiment of the present application;
[0032] Figure 2 A schematic diagram of a chip hardware structure provided in an embodiment of the present application;
[0033] Figure 3A A schematic diagram of the structure of an image processing system provided in an embodiment of the present application;
[0034] Figure 3B Another structural schematic diagram of the image processing system provided in an embodiment of the present application;
[0035] Figure 4 A flowchart of an image processing method provided in an embodiment of the present application;
[0036] Figure 5 An example diagram of an image provided in an embodiment of the present application;
[0037] Figure 6 An example diagram of a neural network provided in an embodiment of the present application;
[0038] Figure 7 Another example diagram of a neural network provided in an embodiment of the present application;
[0039] Figure 8 An example diagram of edge point pairs provided in an embodiment of the present application;
[0040] Fig. 9 An example diagram of a polygonal text box provided in an embodiment of the present application;
[0041] Fig.10 Another example diagram of a polygonal text box provided in an embodiment of the present application;
[0042] Fig.11 Another flowchart of the image processing method provided in the embodiment of the present application;
[0043] Fig.12 Another structural diagram of the system architecture provided in the embodiment of the present application;
[0044] Fig.13 A schematic diagram of text recognition results provided in an embodiment of the present application;
[0045] Fig.14 A structural schematic diagram of an image processing device provided in an embodiment of the present application;
[0046] Fig.15 Another structural schematic diagram of the image processing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0047] The present application provides an image processing method for improving the recognition accuracy of curved text in an image.
[0048] To facilitate understanding, the relevant terms and concepts mainly involved in the embodiments of the present application are first introduced below.
[0049] 1. Curve fitting
[0050] Curve fitting refers to selecting an appropriate curve type to fit the observed data and using the fitted curve equation to analyze the relationship between two variables. The purpose of curve fitting is to find a functional relationship based on the given data and then use the function to predict unknown data.
[0051] 2. Optical character recognition (OCR)
[0052] OCR refers to the process in which an electronic device (such as a scanner or digital camera) examines characters printed on paper and then uses character recognition methods to translate the shapes into computer text; that is, the process of scanning text materials and then analyzing and processing the image files to obtain text and layout information.
[0053] At present, the OCR technology for curved text lines in academia is still in the process of continuous evolution. Although there are many solutions, the overall process can be summarized as follows: Step 1, OCR detection: Detect the area where the text is located in the image through a deep learning model. Usually, an irregular polygonal box is used to represent curved text. Step 2, OCR correction: Send the detected text area to the correction model, predict the normalized text box coordinates (align the upper and lower points), and convert the curved text image into a horizontal text image through geometric transformation. Step 3, OCR recognition: For the horizontal text image output in the second step, use a deep model to predict the text information content.
[0054] It can be found that compared with traditional straight text OCR technology, the difference between curved and perspective text OCR technology lies mainly in steps 1 and 2, namely OCR detection and correction. Experiments show that step 1 affects the recall rate of the final recognition effect, while step 2 affects the accuracy of the final recognition effect. Since step 2 requires model prediction and correction for each line of text, the latency is very high. The industry sometimes ignores step 2 and directly calculates the minimum enclosing rectangle of the curved text in step 1 as the correction result, trading accuracy for low latency.
[0055] In summary, the current OCR detection effect of curved perspective text lags far behind that of straight text detection, and there is also a bottleneck in latency. There is still a long way to go before true commercialization.
[0056] In order to solve the above technical problems, the embodiment of the present application provides an image processing method, which determines a polygonal text box of text data through curve fitting, and then determines the recognition result of the text data based on the polygonal text box. Due to the use of curve fitting, the risk of parameter estimation error is avoided, the robustness of the algorithm is improved, and the polygonal text box is closer to the curved text.
[0057] The following first introduces the system architecture provided by the embodiments of the present application.
[0058] See attached Figure 1 , an embodiment of the present invention provides a system architecture 100. As shown in the system architecture 100, the data acquisition device 160 is used to collect training data. In the embodiment of the present application, the training data includes: a training image, and the training image includes text data. The training data is stored in the database 130, and the training device 120 obtains a target model / rule 101 based on the training data maintained in the database 130. The target model / rule 101 can be used to predict the geometric information of the text data in the image, and the geometric information includes at least one of the following: the center line mask of the area where the text data is located, and the radius of the area. The end side tilt angle of the area, etc.
[0059] In one possible implementation, the target model / rule 101 in the embodiment of the present application may specifically include a first structure and a second structure, the first structure is used to predict the centerline mask, and the second structure is used to predict the radius and the end tilt angle. In this case, the target model / rule 101 can also be understood as a common trunk, dual-branch deep model. It can be understood that in this case, the first structure and the second structure of the target model / rule 101 can be trained together or separately. Of course, since the first structure is mainly used to implement binary classification tasks and the second structure is mainly used to solve regression problems, separate training has a better effect.
[0060] In another possible implementation, the target model / rule 101 in the embodiment of the present application may specifically include a structure for predicting the centerline mask, radius and end side tilt angle. In this case, the target model / rule 101 may also be understood as a single-branch depth model.
[0061] It should be noted that, in actual applications, the training data maintained in the database 130 may not all come from the data acquisition device 160, but may also be received from other devices. It should also be noted that the training device 120 may not train the target model / rule 101 entirely based on the training data maintained by the database 130, but may also obtain training data from the cloud or other places for model training. The above description should not be used as a limitation on the embodiments of the present application.
[0062] The target model / rule 101 trained by the training device 120 can be applied to different systems or devices, such as Figure 1 The execution device 110 shown in the figure can be a terminal, such as a mobile phone terminal, a tablet computer, a laptop computer, an augmented reality (AR) device / virtual reality (VR) device, a vehicle terminal, etc. Of course, the execution device 110 can also be a server or a cloud. Figure 1 In the embodiment, the execution device 110 is configured with an I / O interface 112 for data interaction with an external device. The user can input data to the I / O interface 112 through the client device 140. The input data in the embodiment of the present application can include: an image to be recognized. In addition, the input data can be input by the user, or uploaded by the user through a shooting device, or from a database, which is not limited here.
[0063] The preprocessing module 113 is used to preprocess the input data received by the I / O interface 112. In the embodiment of the present application, the preprocessing module 113 can be used to split the input data to obtain a sub-data set. For example: the input image is an image, and the preprocessing module 113 is used to split the image to obtain multiple image blocks. For another example, the preprocessing module 113 can be used to reduce or geometrically scale the input data so that the image meets the input size of the neural network.
[0064] When the execution device 110 preprocesses the input data, or when the computing module 111 of the execution device 110 performs calculations and other related processing, the execution device 110 can call the data, code, etc. in the data storage system 150 for corresponding processing, and can also store the data, instructions, etc. obtained from the corresponding processing into the data storage system 150.
[0065] Finally, the I / O interface 112 returns the processing result, such as the result corresponding to the above-mentioned target task, to the client device 140 to provide it to the user.
[0066] It is worth noting that the training device 120 can generate corresponding target models / rules 101 based on different training data for different goals or different tasks. The corresponding target models / rules 101 can be used to achieve the above goals or complete the above tasks, thereby providing users with the desired results.
[0067] In the attached Figure 1 In the case shown in the figure, the user can manually give input data, and the manual giving can be operated through the interface provided by the I / O interface 112. In another case, the client device 140 can automatically send input data to the I / O interface 112. If the client device 140 is required to automatically send input data and needs to obtain the user's authorization, the user can set the corresponding authority in the client device 140. The user can view the results output by the execution device 110 on the client device 140, and the specific presentation form can be a specific method such as display, sound, action, etc. The client device 140 can also be used as a data acquisition terminal to collect the input data of the input I / O interface 112 and the output results of the output I / O interface 112 as shown in the figure as new sample data, and store them in the database 130. Of course, it is also possible not to collect through the client device 140, but the I / O interface 112 directly stores the input data of the input I / O interface 112 and the output results of the output I / O interface 112 as new sample data in the database 130.
[0068] It is worth noting that Figure 1 This is only a schematic diagram of a system architecture provided by an embodiment of the present invention. The positional relationship between the devices, components, modules, etc. shown in the figure does not constitute any limitation. Figure 1 In the embodiment, the data storage system 150 is an external memory relative to the execution device 110. In other cases, the data storage system 150 may also be placed in the execution device 110.
[0069] The following introduces a chip hardware structure provided by an embodiment of the present application.
[0070] Figure 2 A chip hardware structure provided in an embodiment of the present invention includes a neural network processor 20. The chip can be arranged as follows: Figure 1 The execution device 110 shown in FIG. 1 is used to complete the calculation work of the calculation module 111. The chip can also be set in Figure 1 The training device 120 shown is used to complete the training work of the training device 120 and output the target model / rule 101.
[0071] The neural network processor 20 can be a neural network processing unit (NPU), a tensor processing unit (TPU), or a graphics processing unit (GPU) or any other processor suitable for large-scale XOR processing. Take NPU as an example: the neural network processor 20 is mounted on the main central processing unit (CPU) (host CPU) as a coprocessor, and the main CPU assigns tasks. The core part of the NPU is the operation circuit 203, and the controller 204 controls the operation circuit 203 to extract data from the memory (weight memory or input memory) and perform operations.
[0072] In some implementations, the operation circuit 203 includes multiple processing units (process engines, PEs) inside. In some implementations, the operation circuit 203 is a two-dimensional systolic array. The operation circuit 203 can also be a one-dimensional systolic array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the operation circuit 203 is a general-purpose matrix processor.
[0073] For example, assume there is an input matrix A, a weight matrix B, and an output matrix C. The operation circuit 203 takes the corresponding data of the matrix B from the weight memory 202 and caches it on each PE in the operation circuit. The operation circuit takes the matrix A data from the input memory 201 and performs a matrix operation with the matrix B, and the partial result or the final result of the matrix is stored in the accumulator 208.
[0074] The vector calculation unit 207 can further process the output of the operation circuit, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. For example, the vector calculation unit 207 can be used for network calculations of non-convolutional / non-FC layers in a neural network, such as pooling, batch normalization, local response normalization, etc.
[0075] In some implementations, the vector calculation unit 207 can store the processed output vector to the unified buffer 206. For example, the vector calculation unit 207 can apply a nonlinear function to the output of the operation circuit 203, such as a vector of accumulated values, to generate an activation value. In some implementations, the vector calculation unit 207 generates a normalized value, a merged value, or both. In some implementations, the processed output vector can be used as an activation input to the operation circuit 203, for example, for use in a subsequent layer in a neural network.
[0076] The unified memory 206 is used to store input data and output data.
[0077] The weight data is directly transferred from the external memory to the input memory 201 and / or the unified memory 206 through the direct memory access controller 205 (DMAC), the weight data in the external memory is stored in the weight memory 202, and the data in the unified memory 206 is stored in the external memory.
[0078] The bus interface unit (BIU) 210 is used to implement the interaction between the main CPU, DMAC and instruction fetch memory 209 through the bus.
[0079] An instruction fetch buffer 209 connected to the controller 204 is used to store instructions used by the controller 204 .
[0080] The controller 204 is used to call the instructions cached in the memory 209 to control the working process of the computing accelerator.
[0081] Generally, the unified memory 206, the input memory 201, the weight memory 202 and the instruction fetch memory 209 are all on-chip memories, and the external memory is a memory outside the NPU, which can be a double data rate synchronous dynamic random access memory (DDR SDRAM for short), a high bandwidth memory (HBM) or other readable and writable memory.
[0082] Next, several application scenarios of this application are introduced.
[0083] Figure 3A A schematic diagram of the structure of an image processing system provided in an embodiment of the present application, the image processing system includes a terminal device ( Figure 3AIn the figure, only the terminal device is a mobile phone as an example) and an image processing device. It is understandable that, in addition to mobile phones, terminal devices can also be tablet computers (pads), portable game consoles, personal digital assistants (PDAs), laptop computers, ultra mobile personal computers (UMPCs), handheld computers, netbooks, vehicle-mounted media playback devices, wearable electronic devices, virtual reality (VR) terminal devices, augmented reality (AR), vehicles, vehicle-mounted terminals, aircraft terminals, intelligent robots and other terminal devices. The terminal device is the initiator of data processing. As the initiator of the data processing request, the request is usually initiated by the user through the terminal device.
[0084] The above-mentioned image processing device can be a device or server with data processing function such as a cloud server, a network server, an application server and a management server. The image processing device receives a data processing request from a terminal device through an interactive interface, and then performs data processing in the form of machine learning, deep learning, search, reasoning, decision-making, etc. through a memory that stores data and a processor link for data processing. The memory in the image processing device can be a general term, including local storage and a database that stores historical data. The database can be on the image processing device or on other network servers.
[0085] exist Figure 3A In the image processing system shown, the terminal device can receive instructions from the user. For example, the terminal device can obtain an image input / selected by the user (for example, an image collected by the terminal device through the terminal device, etc.), and then initiate a request to the image processing device, so that the image processing device predicts the geometric information of the text data for the image obtained by the terminal device and / or recognizes the text data of the image, thereby obtaining the corresponding processing result for the image (for example, geometric information and / or text recognition result). Exemplarily, the terminal device can obtain the image input by the user, and then initiate an image processing request to the image processing device, so that the image processing device predicts and recognizes the image, thereby obtaining the geometric information of the text data in the image. Furthermore, the image can be recognized by the geometric information to obtain the text recognition result, and the text recognition result of the image can be displayed for the user to view and use.
[0086] exist Figure 3A In the embodiment, the image processing device can execute the image processing method of the embodiment of the present application.
[0087] Figure 3B Another structural diagram of the image processing system provided in the embodiment of the present application is shown in FIG. Figure 3BIn the terminal device ( Figure 3B In this example, the terminal device is a mobile phone. The terminal device can directly obtain data (for example, the data is an image, etc.) and process it directly by the hardware of the terminal device itself. The specific process is the same as Figure 3A Similarly, please refer to the above description and will not repeat them here.
[0088] Optionally, in Figure 3B In the image processing system shown, the terminal device can receive instructions from the user. For example, the terminal device can obtain the image selected by the user in the terminal device, and then the terminal device itself performs geometric information prediction of the text data and / or recognizes the text data of the image for the image, thereby obtaining the corresponding processing results for the image (such as geometric information and / or text recognition results), and displays the processing results for the user to view and use.
[0089] Optionally, in Figure 3B In the image processing system shown, the terminal device can collect images in real time or periodically, and then the terminal device itself performs detection, recognition, etc. on the image to obtain a corresponding processing result for the image.
[0090] exist Figure 3B In the embodiment of the present application, the terminal device itself can execute the image processing method.
[0091] Above Figure 3A and Figure 3B The terminal device in the example can be Figure 1 The client device 140 or the execution device 110 in Figure 3A The image processing device in the embodiment may be Figure 1 The execution device 110 in the embodiment, wherein the data storage system 150 can store the data to be processed (such as images, etc.) of the execution device 110, and the data storage system 150 can be integrated on the execution device 110, or can be set on the cloud or other network servers.
[0092] The following describes the image processing method provided in the embodiment of the present application. The method can be executed by an image processing device, or by a component of the image processing device (such as a processor, a chip, or a chip system, etc.). The image processing device can be a cloud device (such as the aforementioned Figure 3A as shown), or a terminal device (such as Figure 3B Of course, the method can also be executed by a system consisting of a cloud device and a terminal device (as described above). Figure 3AOptionally, the method may be processed by a CPU in an image processing device, or may be processed by a CPU and a GPU together, or may use other processors suitable for neural network calculations without using a GPU, and this application does not limit this.
[0093] The method provided in the embodiment of the present application is mainly applicable to text recognition scenarios (such as OCR, etc.).
[0094] See also Figure 4 , a flow chart of an image processing method provided by an embodiment of the present application, the method may include steps 401 to 403. Steps 401 to 403 are described in detail below.
[0095] Step 401, acquiring an image.
[0096] In the embodiment of the present application, there are many ways for the image processing device to obtain images, which can be through collection / shooting, or by receiving images sent by other devices, or by selecting them from a database, etc., which are not limited here.
[0097] The image in the embodiment of the present application includes text data. Further, the image includes curved text data. The curved text data in the image can be understood as a curved text box containing text data in the image.
[0098] For example, Figure 5 An example of an image.
[0099] Step 402: determine a first polygonal text box of the image based on curve fitting.
[0100] After the image processing device acquires the image, the first polygonal text box of the image can be determined based on curve fitting. The description of curve fitting can refer to the aforementioned related terms, which will not be repeated here. In addition, the number of first polygonal text boxes is related to the number of rows of text data in the image. For example, one row of text data can obtain one first polygonal text box.
[0101] Optionally, the image processing device first predicts geometric information of the text data, which includes a centerline mask of the area where the text data is located and a radius of the area. Then, a centerline equation is constructed based on the centerline mask, and the centerline equation is used to represent the relationship between the horizontal coordinate and the vertical coordinate of any point on the centerline mask. Then, a first polygonal text box is determined based on the centerline equation and the radius.
[0102] Optionally, in order to improve the accuracy of the edge of the polygonal text box, the image processing device may also predict the end side tilt angle of the text data (for example, the above-mentioned geometric information also includes the end side tilt angle).
[0103] The image processing device can predict the geometric information of the text data through a neural network. Specifically, the image processing device inputs the image into the neural network to obtain the geometric information.
[0104] Usually, the centerline equation corresponds to a line of text data. That is, the centerline mask can be used to divide different text lines and obtain an irregular polygonal box for each line of text.
[0105] In one possible implementation, the neural network may include a first structure and a second structure. The first structure is used to predict the centerline mask, and the second structure is used to predict the radius and the end tilt angle. In this case, the neural network can also be understood as a common trunk, dual-branch deep model. It can be understood that in this case, the first structure and the second structure can be trained together or separately. Of course, since the first structure is mainly used to implement binary classification tasks and the second structure is mainly used to solve regression problems, separate training has a better effect.
[0106] For example, the neural network in the above case can be as follows Figure 6 As shown, it can be seen that the input of the neural network is the image, and one branch of the neural network outputs the centerline mask. The other branch of the neural network outputs the region radius R. Among them, the white horizontal lines in the centerline mask represent the center lines of multiple text lines in the image, and the rest are black.
[0107] In another possible implementation, the neural network may specifically include a structure for predicting the centerline mask, radius and end side tilt angle. In this case, the neural network may also be understood as a single-branch deep model.
[0108] For example, the neural network in the above case can be as follows Figure 7 As shown, it can be seen that the input of the neural network is the image, and the output of the neural network includes the center line mask and the area radius R.
[0109] Among them, taking the geometric information including the end side tilt angle as an example, the two branches of the dual-branch deep model correspond to the centerline mask prediction (for example, the number of output channels is 1) and the radius and angle parameter regression prediction (for example, the number of output channels is 3). The single-branch deep model predicts the centerline, radius, and angle on the same branch (for example, the number of output channels is 4). Generally speaking, the actual effect of the dual branch is better than that of the single branch, and the reasoning speed of the single branch is faster than that of the dual branch.
[0110] In addition, the backbone network of the neural network can use traditional convolutional networks such as ResNet, MobileNet, etc., or Transformer structures such as SWIN, TWIN, etc. The branches use FPN structures to connect to the backbone network.
[0111] For example, Figure 6 and Figure 7 Each rectangle in the figure represents a convolution or Transformer block. The decreasing length of the rectangle represents an increase in the downsampling multiple. The arrowed lines represent the connection between blocks and the previous reasoning process.
[0112] After the image processing device obtains the above geometric information, it can obtain the irregular polygonal box (also called the first polygonal text box) of each line of text by performing contour detection on the centerline mask. The points on the polygonal text box are sampled at equal intervals, and then the centerline equation of the text line is fitted using the sampling points as samples. For example, it can be assumed that the centerline of the person and the text line satisfies the equation: y = ax 3 +bx 2 +cx+d or x=ay 3 +by 2 +cy+d. Then use the singular value decomposition of the matrix to solve the coefficients (a, b, c, d). Among them, xy is the horizontal and vertical coordinates of any point on the center line of the graph. This process can also be understood as predicting the above coefficients through the predicted center line mask, and then constructing the center line equation.
[0113] It can be understood that the above centerline equation is just an example of a cubic curve. In practical applications, it can also be in other forms, which are not limited here.
[0114] After the image processing device constructs the centerline equation, it further determines the first polygonal text box based on the centerline equation and the radius. Specifically, the upper and lower edge point pairs can be determined based on the normal and radius of the centerline, and then the first polygonal text box can be determined based on the upper and lower edge point pairs. Among them, the length of the normal of the centerline plus the radius can obtain the upper and lower edge point pairs, and then the first polygonal text box is determined by connecting the upper and lower edge point pairs. In other words, starting from the upper edge point of the starting point of the centerline of the text line, all the upper edge points are linked in sequence, and then starting from the lower edge point of the ending point of the centerline of the text line, all the lower edge points are linked in sequence, and finally the upper and lower point pairs at both ends are connected to obtain the first polygonal text box. Among them, the upper and lower points at both ends can be connected by straight lines or curves, etc., which are not limited here.
[0115] For example, an example of determining the upper and lower edge point pairs based on the normal and radius of the center line can be as follows: Figure 8 As shown, an example of determining the first polygonal text box based on the upper and lower edge point pairs can be as follows Fig. 9 shown.
[0116] Step 403: determine the text recognition result of the image based on the first polygonal text box.
[0117] After acquiring the first polygonal text box, the image processing device may determine a text recognition result of the image based on the first polygonal text box.
[0118] Optionally, in order to improve the accuracy of the edge of the polygonal text box, the image processing device can also predict the end side tilt angle of the text data (for example, the above-mentioned geometric information also includes the end side tilt angle), and correct the direction of the edge lines at both ends of the text by the end side tilt angle, so as to obtain a normalized curved text box (clockwise, starting from the upper left vertex, and the upper and lower edge points are aligned). That is, a complete representation form of the curved text line (i.e., the second polygonal text box) can be obtained.
[0119] For example, the end side tilt angle and the second polygon text box corrected by the end side tilt angle can be as follows: Fig.10 shown.
[0120] It is understandable that if the aforementioned geometric information includes the end side tilt angle, the image processing device can directly determine the text recognition result of the image based on the second polygonal text box in this step 403. If the aforementioned geometric information does not include the end side tilt angle, the text recognition result of the image can be directly determined based on the first polygonal text box in this step 403. For the convenience of explanation, the polygonal text box is used to summarize the situation of the first polygonal text box or the second polygonal text box.
[0121] After the image processing device obtains the polygonal text box, the upper and lower edges of the polygonal text box can be smoothed based on a curve smoothing algorithm (e.g., Catmull-Rom curve estimation, etc.). Then, the polygonal text box is straightened into a horizontal rectangle using piecewise geometric transformation, and a horizontal rectangular image is determined in the image based on the horizontal rectangle. The horizontal rectangular image is then input into the OCR recognition model to obtain a text recognition result.
[0122] For example, the image processing method provided in the embodiment of the present application can also be as follows: Fig.11 shown.
[0123] In the embodiment of the present application, on the one hand, a polygonal text box of text data is determined by curve fitting, and then the recognition result of the text data is determined based on the polygonal text box. Due to the use of curve fitting, the risk of parameter estimation errors is avoided, the robustness of the algorithm is improved, and the polygonal text box is closer to the curved text. On the other hand, the edges of the text at both ends are corrected by the end-side tilt angle, supporting the detection and recognition of perspective text lines such as arcs, trapezoids, and parallelograms. In other words, a set of solutions is used to solve the two major detection problems of bending and perspective at the same time. Effectively improve the accuracy of text recognition at both ends of the text line in the scenarios of round packaging cans, wrinkled books, and art shop signs. On the other hand, it is proposed to combine text detection and text correction into one, abandon the line-by-line correction model, and use the detection model output parameters to directly normalize the text box. The efficiency of the algorithm can be greatly improved while ensuring accuracy.
[0124] Another system architecture provided by the embodiment of the present application can be as follows Fig.12 As shown, the system architecture includes a model prediction module, a text box fitting module and a smooth correction module. Among them, the model prediction module includes the pre-processing of the input image and running the model to obtain the return parameters (center line mask, text line radius and end side tilt angle). The text box fitting module includes the division of text lines, the center line fitting of single-line text, and the use of regression radius and end side tilt angle to obtain the text box edge points. The smooth correction module includes Catmull-Rom curve fitting to smooth the upper and lower edges, and geometric transformation to straighten the text line image. Among them, the steps in each module can refer to the aforementioned Figure 4 The description of the embodiment shown in the figure will not be repeated here. The first one is
[0125] The image processing method provided by the embodiment of the present application is efficient and can detect and correct curved text lines by adding a prediction branch and modifying part of the post-processing logic without changing the original straight text line detection model architecture.
[0126] On the one hand, the text line detection step uses curve fitting, which greatly simplifies the processing efficiency and improves the robustness of the algorithm. Compared with the model's pixel-by-pixel regression of text line contours or centerline contours, it is more robust and more accurate.
[0127] On the other hand, the impact of the end-side tilt correction on subsequent correction is taken into account during the text box normalization process, which improves the recognition effect of the beginning and end of the curved text. The end-side tilt is used to correct the edges of the text to solve the problem of inaccurate prediction of the beginning and end of the curved and perspective text. Different from the existing technology that the edges of the two ends of the text line are perpendicular to the center line by default, it can be found that the left and right edges of the text line in most perspective scenes are not orthogonal to the center line. Therefore, special estimation of the end-side tilt can greatly improve the detection and recognition effect of arc-shaped, trapezoidal, and parallelogram text (see Fig.13, the geometric information on the left does not include the end side tilt angle, and the geometric information on the right includes the end side tilt angle. Or it can be understood that the left side is the detection result of the polygonal text box that has not been corrected by the end side tilt angle, and the right side is the detection result of the polygonal text box that has been corrected by the end side tilt angle).
[0128] On the other hand, the correction step does not require re-running an additional deep model for each line of text, which has a clear advantage in speed while ensuring the recognition effect.
[0129] On the other hand, the image processing method provided in the embodiment of the present application solves the problem of long delay. At the same time, the output parameters of the detection model are used to normalize the text, which solves the problem of reduced recognition rate caused by the industry directly using the minimum bounding rectangle to normalize the text. A perfect balance is achieved in the dilemma of delay and accuracy.
[0130] The image processing method in the embodiment of the present application is described above. The image processing device in the embodiment of the present application is described below. Fig.14 , an embodiment of the image processing device in the embodiment of the present application includes:
[0131] An acquisition unit 1401 is used to acquire an image, where the image includes text data;
[0132] A determining unit 1402, configured to determine a first polygonal text box of the image based on curve fitting;
[0133] The determining unit 1402 is further configured to determine a text recognition result of the image based on the multiple polygonal text boxes.
[0134] Optionally, determination unit 1402 is specifically used to predict geometric information of text data, the geometric information including the centerline mask of the area where the text data is located and the radius of the area; determination unit 1402 is specifically used to construct a centerline equation based on the centerline mask, the centerline equation is used to represent the relationship between the horizontal coordinate and the vertical coordinate of any point on the centerline mask; determination unit 1402 is specifically used to determine the first polygonal text box based on the centerline equation and the radius.
[0135] Optionally, the determination unit 1402 is specifically used to determine the upper and lower edge point pairs based on the center line equation and the radius; the determination unit 1402 is specifically used to determine the first polygonal text box based on the upper and lower edge point pairs.
[0136] Optionally, the geometric information also includes: an end-side tilt angle of the area; a determination unit 1402, specifically used to correct the first polygonal text box based on the end-side tilt angle to obtain a second polygonal text box; and a determination unit 1402, specifically used to determine a text recognition result based on the second polygonal text box.
[0137] Optionally, the determination unit 1402 is specifically used to predict geometric information based on a neural network, the neural network includes a first structure and a second structure, the first structure is used to predict a centerline mask, and the second structure is used to predict a radius and an end side tilt angle.
[0138] Optionally, the determination unit 1402 is specifically configured to convert the text data into a horizontal rectangular image based on the first polygonal text box; the determination unit 1402 is specifically configured to recognize the horizontal rectangular image to obtain a text recognition result.
[0139] In this embodiment, the operations performed by each unit in the image processing device are the same as those described above. Figures 1 to 13 The description in the illustrated embodiment is similar and will not be repeated here.
[0140] In this embodiment, on the one hand, the polygonal text box of the text data is determined by curve fitting, and then the recognition result of the text data is determined based on the polygonal text box. Due to the use of curve fitting, the risk of parameter estimation errors is avoided, the robustness of the algorithm is improved, and the polygonal text box is closer to the curved text. On the other hand, the edges of the two ends of the text are corrected by the end-side tilt angle, supporting the detection and recognition of perspective text lines such as arcs, trapezoids, and parallelograms. In other words, a set of solutions is used to solve the two major detection problems of bending and perspective at the same time. Effectively improve the text recognition accuracy at both ends of the text line in the scenes of round packaging cans, wrinkled books, and art shop signs. On the other hand, it is proposed to combine text detection and text correction into one, abandon the line-by-line correction model, and use the detection model output parameters to directly normalize the text box. The efficiency of the algorithm can be greatly improved while ensuring accuracy.
[0141] See also Fig.15 , a schematic diagram of the structure of another image processing device provided by the present application. The image processing device may include a processor 1501, a memory 1502 and a communication port 1503. The processor 1501, the memory 1502 and the communication port 1503 are interconnected via a line. The memory 1502 stores program instructions and data.
[0142] The memory 1502 stores the aforementioned Figures 1 to 13 In the corresponding implementation manner shown, the steps executed by the image processing device correspond to program instructions and data.
[0143] Processor 1501, used to execute the above Figures 1 to 13 The steps performed by the image processing device shown in any of the embodiments shown.
[0144] Communication port 1503 can be used to receive and send data, and to perform the above Figures 1 to 13 The steps related to obtaining in any of the embodiments shown.
[0145] In one implementation, the image processing device may include Fig.15 More or fewer components are merely illustrative in this application and are not limiting.
[0146] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0147] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0148] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0149] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk and other media that can store program code.
Claims
1. An image processing method, characterized in that: The method comprises: Acquire an image, wherein the image includes text data; Determine a first polygonal text box of the image based on curve fitting; A text recognition result of the image is determined based on the first polygonal text box.
2. The method according to claim 1, characterized in that The determining the first polygonal text box of the image based on curve fitting comprises: Predicting geometric information of the text data, the geometric information including a center line mask of a region where the text data is located and a radius of the region; Constructing a centerline equation based on the centerline mask, wherein the centerline equation is used to represent the relationship between the abscissa and the ordinate of any point on the centerline mask; The first polygonal text box is determined based on the center line equation and the radius.
3. The method according to claim 2, characterized in that The determining the first polygonal text box based on the centerline equation and the radius includes: Determine upper and lower edge point pairs based on the centerline equation and the radius; The first polygonal text box is determined based on the upper and lower edge point pairs.
4. The method according to claim 2 or 3, characterized in that: The geometric information also includes: the end side tilt angle of the region; The determining the text recognition result of the image based on the first polygonal text box includes: Correcting the first polygonal text box based on the end side tilt angle to obtain a second polygonal text box; The text recognition result is determined based on the second polygonal text box.
5. The method according to claim 4, characterized in that The predicting geometric information of the text data includes: The geometric information is predicted based on a neural network, wherein the neural network includes a first structure and a second structure, wherein the first structure is used to predict the centerline mask, and the second structure is used to predict the radius and the end side tilt angle.
6. The method according to any one of claims 1 to 5, characterized in that The determining the text recognition result of the image based on the first polygonal text box includes: Converting the text data into a horizontal rectangular image based on the first polygonal text frame; The horizontal rectangular image is recognized to obtain the text recognition result.
7. An image processing device, characterized in that: The image processing device comprises: An acquisition unit, used for acquiring an image, wherein the image includes text data; A determining unit, configured to determine a first polygonal text box of the image based on curve fitting; The determining unit is further configured to determine a text recognition result of the image based on the multiple polygonal text boxes.
8. The image processing device according to claim 7, characterized in that The determining unit is specifically used to predict the geometric information of the text data, wherein the geometric information includes a center line mask of a region where the text data is located and a radius of the region; The determining unit is specifically used to construct a centerline equation based on the centerline mask, and the centerline equation is used to represent the relationship between the abscissa and the ordinate of any point on the centerline mask; The determining unit is specifically configured to determine the first polygonal text box based on the center line equation and the radius.
9. The image processing device according to claim 8, characterized in that The determining unit is specifically configured to determine the upper and lower edge point pairs based on the center line equation and the radius; The determining unit is specifically configured to determine the first polygonal text box based on the upper and lower edge point pairs.
10. The image processing device according to claim 8 or 9, characterized in that: The geometric information also includes: the end side tilt angle of the region; The determining unit is specifically configured to correct the first polygonal text box based on the end side tilt angle to obtain a second polygonal text box; The determining unit is specifically configured to determine the text recognition result based on the second polygonal text box.
11. The image processing device according to claim 10, characterized in that The determination unit is specifically used to predict the geometric information based on a neural network, the neural network includes a first structure and a second structure, the first structure is used to predict the centerline mask, and the second structure is used to predict the radius and the end side tilt angle.
12. The image processing device according to any one of claims 7 to 11, characterized in that: The determining unit is specifically configured to convert the text data into a horizontal rectangular image based on the first polygonal text frame; The determining unit is specifically configured to identify the horizontal rectangular image to obtain the text recognition result.
13. An image processing device, characterized in that: include: A processor, the processor is coupled to a memory, the memory is used to store programs or instructions, when the program or instructions are executed by the processor, the image processing device performs the method according to any one of claims 1 to 6.
14. A computer storage medium, characterized in that: The method comprises computer instructions, and when the computer instructions are executed on a terminal device, the terminal device executes the method according to any one of claims 1 to 6.
15. A computer program product, characterized in that When the computer program product is run on a computer, the computer is caused to execute the method according to any one of claims 1 to 6.
