Image processing method and device, electronic equipment, readable storage medium and product

By performing text frame recognition and candidate frame correction on the image to be detected during target detection, the problem of poor text detection effect of the target detection algorithm is solved, and the detection effect and accuracy are improved.

CN118658151APending Publication Date: 2024-09-17MASHANG CONSUMER FINANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410524804.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-26
Publication Date
2024-09-17

AI Technical Summary

Technical Problem

The target detection algorithm is less effective at detecting pictures containing text, especially the detection of small targets such as text is inaccurate.

Method used

By performing text box recognition on the image to be detected before target detection, the text box information is obtained, and the candidate box is corrected based on this information to ensure that the corrected candidate box accurately represents the text boundary, thereby improving the detection effect.

Benefits of technology

It improves the detection effect of detection targets, especially the recognition accuracy of text boundaries, and enhances the detection ability of small targets.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118658151A
    Figure CN118658151A
Patent Text Reader

Abstract

The invention provides an image processing method and device, electronic equipment, a readable storage medium and a product. The image processing method comprises the following steps: acquiring a to-be-detected picture containing characters; performing textbox recognition on the to-be-detected picture to obtain textbox information in the to-be-detected picture; performing feature extraction on the to-be-detected picture to obtain image feature information of the to-be-detected picture; performing detection target identification on the image feature information to obtain a candidate box; and correcting the candidate box based on the textbox information, and detecting the to-be-detected picture based on the corrected candidate box and the image feature information to obtain a detection result. According to the technical scheme, the accuracy of text edge detection can be improved, and the recognition effect of the detection target can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence, and specifically to an image processing method, device, electronic device, readable storage medium and product. Background Art

[0002] With the development of artificial intelligence, target detection algorithms have been applied in many scenarios. However, the detection effect of target detection algorithms on small targets such as text is poor. Therefore, when there is text in the image to be detected, the detection effect of the target based on the target detection algorithm is poor. Summary of the invention

[0003] The present application provides an image processing method, device, electronic device, readable storage medium and product, which can solve the problem of poor detection effect when detecting targets based on target detection algorithms.

[0004] In order to solve the above technical problems:

[0005] In a first aspect, an embodiment of the present application provides an image processing method, comprising:

[0006] Get the image to be detected containing text;

[0007] Perform text box recognition on the image to be detected to obtain text box information in the image to be detected;

[0008] Perform feature extraction on the image to be detected to obtain image feature information of the image to be detected;

[0009] Perform detection and target recognition on the image feature information to obtain the candidate box;

[0010] The candidate box is corrected based on the text box information, and the image to be detected is detected based on the corrected candidate box and image feature information to obtain a detection result.

[0011] In a second aspect, an embodiment of the present application provides an image processing device, including:

[0012] An acquisition module is used to acquire the image to be detected containing text;

[0013] A recognition module is used to perform text box recognition on the image to be detected and obtain text box information in the image to be detected;

[0014] A feature extraction module is used to extract features from the image to be detected and obtain image feature information of the image to be detected;

[0015] The recognition module is also used to detect target recognition based on image feature information to obtain candidate boxes;

[0016] The processing module is used to modify the candidate box based on the text box information, and detect the image to be detected based on the modified candidate box and image feature information to obtain a detection result.

[0017] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the steps of the method of the first aspect described above are implemented.

[0018] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method of the first aspect described above are implemented.

[0019] In a fifth aspect, an embodiment of the present application further provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the steps of the method of the first aspect described above.

[0020] In an embodiment of the present application, before detecting the detection target, the text box information is obtained by first performing text box recognition on the image to be detected, and then the detected candidate box is corrected based on the text box information, and the image to be detected is detected based on the corrected candidate box and image feature information to obtain a detection result. In this embodiment, since the text box information can accurately indicate the position of the text boundary, and the candidate box is the boundary box of the detection target obtained by identifying the detection target, the candidate box is corrected by the text box information, that is, the boundary box of the detection target obtained by identifying is corrected by the text box information, which can ensure that the corrected candidate box can accurately represent the boundary of the text in the detection target, thereby facilitating the improvement of the detection effect of the detection target. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0022] Figure 1 It is one of the flow charts of the image processing method provided in the embodiment of the present application;

[0023] Figure 2 This is the second flowchart of the image processing method provided in the embodiment of the present application;

[0024] Figure 3 It is one of the structural schematic diagrams of the image processing device provided in the embodiment of the present application;

[0025] Figure 4 This is the second structural diagram of the image processing device provided in the embodiment of the present application;

[0026] Figure 5 It is a schematic diagram of correcting the candidate frame in an embodiment of the present application. DETAILED DESCRIPTION

[0027] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0028] In the related art, when performing target detection on a picture containing text, the following steps are usually included: The picture is subjected to feature extraction through a backbone extraction network to obtain picture features. The picture features are identified through a region proposal network to obtain candidate boxes. Boxes of interest are generated from the candidate boxes. The boxes of interest are classified and regressed to obtain the coordinates and category of each predicted box as well as the category confidence. When this method is used to analyze the layout in the picture, since the text boundaries in the layout are generally white backgrounds, the target detection network may have inaccurate edge detection problems. As a result, in some cases, the boundaries of the layout analysis box are inaccurate, which in turn leads to poor target detection effects.

[0029] Based on this, in an embodiment of the present application, since the text box information can accurately indicate the position of the text boundary, and the candidate box is the boundary box of the detection target obtained by identifying the target, the candidate box is corrected based on the text box information, that is, the boundary box of the detection target obtained by identifying the text box information is corrected to ensure that the corrected candidate box can accurately represent the boundary of the text in the detection target, thereby helping to improve the detection effect of the detection target.

[0030] See also Figure 1 , Figure 1 A schematic diagram of a flow chart of an image processing method provided in an embodiment of the present application, the image processing method comprises the following steps:

[0031] Step 101: Obtain a picture to be detected containing text.

[0032] The image to be detected may be an image including text in various scenes, for example, a poster image, a magazine cover, a news page, etc.

[0033] Step 102: Perform text box recognition on the image to be detected to obtain text box information in the image to be detected.

[0034] Specifically, text box recognition may be performed on the image to be detected based on various text box recognition methods. For example, text box recognition may be performed on the image to be detected based on optical character recognition (OCR) technology to obtain text box information in the image to be detected.

[0035] Among them, the text box information may include a text box of the text in the image to be detected, and the text box is used to represent the boundary position of the selected text. Specifically, when the image to be detected includes table data, a text box can be generated for each cell in the table data. When the image to be detected includes text in multiple paragraphs, a text box can be generated for each paragraph, or a text box can be generated for each sentence in each paragraph, etc.

[0036] Step 103: extract features from the image to be detected to obtain image feature information of the image to be detected.

[0037] The image feature information may be visual feature information of the image to be detected, that is, features that can be observed visually, such as the position, shape, and included content of all elements in the image to be detected.

[0038] Specifically, in some embodiments of the present application, various feature extraction networks can be used to extract features from the image to be detected to obtain image feature information. For example, the classic feature extraction network structure ResNet50 can be used to extract features from the image to be detected to obtain image feature information.

[0039] Step 104: perform detection target recognition on the image feature information to obtain a candidate frame.

[0040] The above-mentioned detection target may be a pre-set detection target, wherein the detection target is a specific object in the image to be detected, for example, the detection target may be a table, illustration, etc. in the image to be detected.

[0041] It is understandable that, since the above-mentioned image to be detected may include several detection targets, it is also possible to obtain several candidate frames by identifying the image feature information. Therefore, in step 104, the number of candidate frames may be one or more. Unless otherwise specified, the subsequent mention of a candidate frame may refer to any one of the multiple candidate frames, and the same processing is applied to the other candidate frames, which will not be repeated in this embodiment.

[0042] Specifically, the image feature information may be identified based on various image feature information identification methods to obtain a candidate box. For example, the image feature information may be input into a region proposal network for identification to obtain a candidate box.

[0043] The region proposal network may be any proposal network for determining candidate regions, for example, a region proposal network (RPN). By inputting image feature information into the region proposal network for recognition, a large number of candidate boxes output by the region proposal network can be obtained.

[0044] Step 105: modify the candidate box based on the text box information, and detect the image to be detected based on the modified candidate box and image feature information to obtain a detection result.

[0045] Since the text box information can indicate the boundary position of the text in the image to be detected, and the above-mentioned region proposal network has a poor boundary recognition effect for small objects such as text. Therefore, correcting the candidate box based on the text box information can specifically refer to: by comparing the boundaries of each position indicated by the text box information with the boundaries of the corresponding position indicated by the candidate box, when there is a conflict between the boundary of a certain position indicated by the text box information and the boundary of the position indicated by the candidate box, the boundary of the position indicated by the candidate box is corrected according to the boundary of the position indicated by the text box information, and a corrected candidate box corresponding to the candidate box is obtained, so that the boundary of the position indicated by the text box information is consistent with the boundary of the position indicated by the corrected candidate box.

[0046] It can be understood that after correcting the above-mentioned candidate box, a corrected candidate box can be obtained, and the boundary of the text in the area indicated by the corrected candidate box is consistent with the boundary of the text in the area indicated by the text box information. In this way, the accuracy of text boundary recognition can be improved.

[0047] After obtaining the corrected candidate frame, the image to be detected can be detected based on the corrected candidate frame and image feature information to obtain a detection result, wherein the detection result may include detection frame information, wherein the detection frame information includes: position information of the corresponding corrected candidate frame, category information and confidence of the corresponding corrected candidate frame, etc.

[0048] Specifically, the area of ​​the corrected candidate frame can be cropped out from the image feature information according to the position indicated by the corrected candidate frame, and the frame of interest can be obtained. Then, the frame of interest is input into the classification network for classification, and the category and confidence of each frame of interest are obtained. Then, the coordinates of the frame are obtained through the regression network branch, thereby obtaining the above detection frame information.

[0049] It is understandable that the above-mentioned ResNet50, RPN, classification network and regression network can be different modules in the same target detection model. For example, the target detection model can be various large models. Among them, the large model can refer to: a large language model based on a generative architecture in the field of natural language processing, for example, a large model can be a GPT-3 model, GPT, Bloom series, etc.

[0050] In some embodiments of the present application, the image processing method can be applied to various target detection scenarios, or the image processing method can also be applied to the training scenario of the target detection model. When the image processing method is applied to the training scenario of the target detection model, the training data can also include labels corresponding to the image to be detected, so that the detection box information can be used as the prediction result, and the prediction result can be compared with the above label to determine the loss of the model, and the model parameters can be optimized based on the loss of the model.

[0051] In this implementation, before performing target detection, the text box information is obtained by first performing text box recognition on the image to be detected, and then the detected candidate box is corrected based on the text box information, and the image to be detected is detected based on the corrected candidate box and image feature information to obtain a detection result. In this embodiment, since the text box information can accurately indicate the position of the text boundary, and the candidate box is the boundary box of the detection target obtained by identifying the detection target, the boundary box of the detection target obtained by identifying the detection target is corrected by the text box information to ensure that the corrected candidate box can accurately represent the boundary of the text in the detection target, which is conducive to improving the recognition effect of the detection target.

[0052] Optionally, the text box information includes a text box, and modifying the candidate box based on the text box information includes:

[0053] Check whether the candidate box is tangent to the text box;

[0054] When the candidate frame is tangent to the text frame, the candidate frame is corrected so that the text frame is included in the candidate frame.

[0055] The above-mentioned tangency between the candidate box and the text box specifically refers to: whether the boundary of the candidate box cuts the text box. For example, when the boundary of the candidate box divides the text box into two parts, it can be determined that the candidate box and the text box are tangent. Correspondingly, when the text box is located within the candidate box, or the boundary of the text box coincides with the boundary of the candidate box, it is determined that the candidate box and the text box are not tangent.

[0056] In this implementation, when the candidate box is tangent to the text box, only a portion of the text corresponding to the text box may be located within the candidate box, resulting in poor text recognition effect. Based on this, in an embodiment of the present application, by detecting whether the candidate box is tangent to the text box, and if the candidate box is tangent to the text box, the candidate box is corrected so that the candidate box includes the text box. Since the corrected candidate box includes the text box, it is beneficial to improve the recognition effect of the text.

[0057] Optionally, the candidate box and the text box both include N edges, and there is a one-to-one correspondence between the N edges of the candidate box and the N edges of the text box; N is an integer greater than or equal to 4; the candidate box and the text box are tangent to each other, which means that a target edge included in the candidate box is tangent to the text box; the target edge is any one of the N edges; and modifying the candidate box includes:

[0058] Replace the target edge of the candidate box with the edge in the text box that matches the target edge.

[0059] For ease of understanding, the following takes the candidate box and the text box as rectangular boxes as an example to further explain the above correction process. When the candidate box and the text box are rectangular boxes, the value of N is 4. The four sides of the candidate box are defined as the first side, the second side, the third side and the fourth side. At the same time, the four sides of the text box are defined as the fifth side, the sixth side, the seventh side and the eighth side. The first side matches the fifth side, the second side matches the sixth side, the third side matches the seventh side, and the fourth side matches the eighth side. The above matching refers to the matching of the positions of the edges. For example, when the first side forms the upper edge of the candidate box, the fifth side forms the upper edge of the text box; when the second side forms the lower edge of the candidate box, the sixth side forms the lower edge of the text box; when the third side forms the left edge of the candidate box, the seventh side forms the left edge of the text box; when the fourth side forms the right edge of the candidate box, the eighth side forms the right edge of the text box. The above replacement of the target edge of the candidate box with the edge in the text box that matches the target edge can specifically refer to:

[0060] In the case where the first side is tangent to the text box, the first side of the candidate box is replaced by the fifth side of the text box;

[0061] When the second side is tangent to the text box, the second side of the candidate box is replaced by the sixth side of the text box;

[0062] When the third side is tangent to the text box, the third side of the candidate box is replaced by the seventh side of the text box;

[0063] When the fourth side is tangent to the text box, the fourth side of the candidate box is replaced by the eighth side of the text box.

[0064] Specifically, see Figure 5, the first side forms the upper edge of the candidate box, the fifth side forms the upper edge of the text box; the second side forms the lower edge of the candidate box, the sixth side forms the lower edge of the text box; the third side forms the left edge of the candidate box, the seventh side forms the left edge of the text box; the fourth side forms the right edge of the candidate box, and the eighth side forms the right edge of the text box. Figure 5 (a) is a schematic diagram showing that the first side of the candidate box is tangent to the text box. Figure 5 (b) Figure 5 The first edge of the candidate box in (a) is replaced by Figure 5 Schematic diagram after the fifth side of the text box in (a).

[0065] In this implementation, each edge of the candidate box is detected one by one to determine whether the candidate box is tangent to the text box, and if the candidate box has a target edge that is tangent to the text box, the target edge of the candidate box is replaced with an edge in the text box that matches the target edge. In this way, the text box corresponding to the candidate box can be located inside the candidate box, thereby avoiding the problem of inaccurate text boundary recognition caused by the boundary of the candidate box cutting the text box, thereby improving the accuracy of text boundary recognition.

[0066] Optionally, the text box information includes a text box; performing feature extraction on the image to be detected to obtain image feature information of the image to be detected includes:

[0067] Based on the text box, draw an identification box corresponding to the text box in the image to be detected to obtain a drawn image;

[0068] Perform feature extraction on the drawn picture to obtain image feature information.

[0069] The above identification box can be used to identify the position of the corresponding text box in the image to be detected.

[0070] It is understandable that the identification box is located above the text selected by the text box, but the identification box will not block the identified text. For example, the identification box is a semi-transparent identification box, or the identification box can also be an identification box that only includes a boundary line.

[0071] The outline shape of the logo frame may be the same as that of the text frame, or the logo frame may be a logo frame of a specific size, for example, the logo frame may be a rectangular frame with a width of 2 pixels and a height of 1 pixel.

[0072] In this implementation, an identification box is drawn in the image to be detected, and the position of the text in the image to be detected is marked by the identification box. In this way, during the feature extraction process, text recognition can be performed according to the position indicated by the identification box, thereby improving the accuracy of text feature extraction, which in turn is beneficial to improving the accuracy of subsequent target detection.

[0073] Optionally, the image processing method is performed by an object detection model, and the object detection model is trained based on a training data set;

[0074] The identification box is a semi-transparent box located on the upper layer of the image to be detected, and the pixel color in the identification box is the target pixel color. The target pixel color refers to the pixel color with the lowest frequency of occurrence among the pixel colors of the sample images in the training data set.

[0075] Specifically, the target detection model may be the target detection model in the above embodiments including ResNet50, RPN, a classification network, and a regression network.

[0076] The above-mentioned image processing method may be specifically performed by the target detection model to refer to: after obtaining the picture to be detected and recognizing the picture to be detected based on the optical character recognition (OCR) technology to obtain the text box information in the picture to be detected, the picture to be detected is subjected to feature extraction based on the ResNet50 in the target detection model to obtain the image feature information of the picture to be detected; then, the image feature information is input into the region proposal network for recognition based on the RPN in the target detection model to obtain the candidate box; the candidate box is corrected based on the target detection model using the text box information to obtain the corrected candidate box; finally, the classification network and regression network based on the target detection model use the corrected candidate box and image feature information for detection to obtain the detection box information.

[0077] Specifically, in the process of determining the pixel color in the identification frame, the color of each pixel in all sample images in the training data set can be counted, and the frequency of occurrence of various colors can be counted, and then the pixel color with the lowest frequency of occurrence is determined as the pixel color in the identification frame. The pixel color with the lowest frequency of occurrence is referred to as the target color below. For example, when the target color is (255, 127, 36,), when drawing the identification frame corresponding to the text frame in the image to be detected, the identification frame with the color (255, 127, 36,) can be drawn.

[0078] In this implementation, since the sample images in the above-mentioned training data set are usually historical images to be identified, and there is usually a certain similarity between the current image to be identified and the historical images to be identified, that is, the target color in the training data set also appears less frequently in the current image to be identified. Based on this, by drawing the color of the identification box as the target color, the problem of interference with the subsequent feature extraction process caused by the presence of too many pixels with the same target color in the image content of the image to be identified can be avoided.

[0079] Optionally, when the image processing method is applied to the training process of the target detection model, feature extraction is performed on the image to be detected to obtain image feature information of the image to be detected, including:

[0080] Preprocessing the image to be detected to obtain a preprocessed image, wherein the preprocessing includes at least one of the following: scaling based on a random scaling ratio, and rotating based on a random angle, wherein the random scaling ratio ranges from 0.5 to 2.0 times, and the random angle ranges from -10° to 10°;

[0081] Randomly crop an image region of a preset size from the preprocessed image to obtain a cropped image;

[0082] Perform feature extraction on the cropped image to obtain image feature information of the image to be detected.

[0083] The above-mentioned image to be detected can be any sample image in the above-mentioned training data set. Specifically, for any sample image, multiple corresponding preprocessed images can be generated by preprocessing. That is, for each sample image, multiple different preprocessings are performed to obtain a preprocessed image after each preprocessing. In this way, the target detection model can be trained based on each sample image and the preprocessed images generated based on the sample images, which is conducive to improving the generalization ability of the trained target model.

[0084] Among them, the above-mentioned preset size can be the size of the image required to be input by the target detection model. For example, when the target detection model is used to process a 1280×1280 pixel image, the preset size can be 1280×1280 pixels.

[0085] The above-mentioned scaling based on a random scaling ratio may specifically refer to: randomly taking a scaling ratio between 0.5 and 2.0 times to scale the image to be detected. The above-mentioned rotation based on a random angle may specifically refer to: randomly taking a rotation angle between -10° and 10° to rotate the scaled image, or, the rotation based on a random angle may specifically refer to: randomly taking a rotation angle between -10° and 10° to rotate the image to be detected. Alternatively, the above-mentioned scaling based on a random scaling ratio may specifically refer to: randomly taking a scaling ratio between 0.5 and 2.0 times to scale the rotated image to be detected.

[0086] Specifically, during the process of rotating the picture, the layout frame in the picture and the above-mentioned text frame will also rotate accordingly, wherein the layout frame includes the header layout frame, footer layout frame, table layout frame, picture layout frame and text layout frame, etc.

[0087] It can be understood that in the process of training the target detection model, in each round of training, a picture to be detected can be determined to execute the above-mentioned image processing method, wherein the determined picture to be detected can be a sample picture in the training data set in the above-mentioned embodiment, or the determined picture to be detected can also be a picture obtained after the above-mentioned preprocessing is performed on the sample picture in the training data set.

[0088] In this implementation, the target detection model is trained based on the preprocessed images, which helps to improve the generalization ability of the trained target model.

[0089] Optionally, the image to be detected includes at least one of the following types of layout frames: a header layout frame, a footer layout frame, a table layout frame, a picture layout frame and a text layout frame;

[0090] The cropping conditions of random cropping include: the boundary line of the cropped image area of ​​the preset size is not tangent to the layout frame in the image to be detected.

[0091] In this implementation, when randomly cropping a picture, it is necessary to ensure that the layout frame in the picture is not cut, so that the layout frame in the cropped picture can be ensured to be a complete layout frame, which is beneficial to improving the quality of the obtained picture to be processed.

[0092] Optionally, when the image processing method is applied to the target detection model to perform a detection process on the image, obtaining the image to be detected containing text includes:

[0093] Get the initial image;

[0094] The initial image is scaled to a preset size to obtain the image to be detected.

[0095] The initial image may be an original image that needs to be detected. Since the image size that can be processed by the target detection model is a preset size, before the initial image is input into the target detection model for target detection, the initial image may be scaled to a preset size to obtain a to-be-detected image, and then the obtained to-be-detected image may be processed based on the above-mentioned image processing method.

[0096] It can be understood that the target detection model used in the process of detecting images based on the target detection model is: a model obtained after training based on the above training data set.

[0097] In this implementation, by scaling the initial image to a preset size, the obtained image to be detected can meet the size requirement of the target detection model for the input image.

[0098] See also Figure 2 , Figure 2 A flowchart of an image processing method provided in an embodiment of the present application is provided. The method is applied to a training process of a target detection model. The method comprises the following steps:

[0099] After obtaining the initial image, on the one hand, the initial image is recognized based on the OCR algorithm to obtain text box information, and on the other hand, the initial image is preprocessed and cropped to obtain a slice image of a preset size.

[0100] Based on the text box information, an identification box is drawn in the slice image to obtain a drawn image.

[0101] Based on the backbone extraction network, feature extraction is performed on the drawn image to obtain image feature information.

[0102] The image feature information is input into the region proposal network for recognition to obtain the candidate box.

[0103] The candidate box is modified based on the text box information to obtain a modified candidate box.

[0104] The region of the corrected candidate frame is cropped out from the image feature information to obtain the frame of interest.

[0105] The box of interest is processed through the regression network to obtain the coordinates of the box.

[0106] The box of interest is classified through the classification network to obtain the category and location of the box.

[0107] See also Figure 3 , Figure 3 The present invention provides a schematic diagram of the structure of an image processing device 300, which includes:

[0108] The acquisition module 301 is used to acquire a picture to be detected containing text;

[0109] The recognition module 302 is used to perform text box recognition on the image to be detected to obtain text box information in the image to be detected;

[0110] The feature extraction module 303 is used to extract features from the image to be detected to obtain image feature information of the image to be detected;

[0111] The recognition module 302 is also used to detect the target recognition based on the image feature information to obtain the candidate frame;

[0112] The processing module 304 is used to modify the candidate box based on the text box information, and detect the image to be detected based on the modified candidate box and image feature information to obtain a detection result.

[0113] Optionally, the processing module 304 includes:

[0114] The detection submodule is used to detect whether the candidate box is tangent to the text box;

[0115] The correction submodule is used to correct the candidate box when the candidate box is tangent to the text box, so that the candidate box includes the text box.

[0116] Optionally, both the candidate box and the text box include N edges, and there is a one-to-one correspondence between the N edges of the candidate box and the N edges of the text box; N is an integer greater than or equal to 4; the candidate box and the text box are tangent to each other means that the target edge included in the candidate box is tangent to the text box; the target edge is any one of the N edges; the correction submodule is specifically used to replace the target edge of the candidate box with an edge in the text box that matches the target edge.

[0117] Optionally, the text box information includes a text box; the feature extraction module 303 includes:

[0118] A drawing submodule is used to draw an identification frame corresponding to the text frame in the image to be detected based on the text frame to obtain a drawn image;

[0119] The feature extraction submodule is used to extract features from the drawn image to obtain image feature information.

[0120] Optionally, the image processing method is performed by an object detection model, and the object detection model is trained based on a training data set;

[0121] The identification box is a semi-transparent box located on the upper layer of the image to be detected, and the pixel color in the identification box is the target pixel color. The target pixel color refers to the pixel color with the lowest frequency of occurrence among the pixel colors of the sample images in the training data set.

[0122] Optionally, the feature extraction module 303 includes:

[0123] A preprocessing submodule, used for preprocessing the image to be detected to obtain a preprocessed image, wherein the preprocessing includes at least one of the following: scaling based on a random scaling ratio, and rotating based on a random angle;

[0124] A cropping submodule is used to randomly crop an image region of a preset size from a preprocessed image to obtain a cropped image;

[0125] The feature extraction submodule is used to extract features from the cropped image to obtain image feature information of the image to be detected.

[0126] Optionally, the image to be detected includes at least one of the following types of layout frames: a header layout frame, a footer layout frame, a table layout frame, a picture layout frame and a text layout frame;

[0127] The cropping conditions of random cropping include: the boundary line of the cropped image area of ​​the preset size is not tangent to the layout frame in the image to be detected.

[0128] The image processing device 300 provided in the embodiment of the present application can implement each process in the above-mentioned image processing method embodiment, and will not be described again here to avoid repetition.

[0129] See also Figure 4 , Figure 4 is a structural diagram of an image processing device 400 provided in another embodiment of the present application, such as Figure 4 As shown, the image processing device 400 includes: a processor 401, a memory 402, and a computer program stored in the memory 402 and executable on the processor. The various components in the database generating device are coupled together via a bus interface 403. When the computer program is executed by the processor 401, the following steps are implemented:

[0130] Get the image to be detected containing text;

[0131] Perform text box recognition on the image to be detected to obtain text box information in the image to be detected;

[0132] Perform feature extraction on the image to be detected to obtain image feature information of the image to be detected;

[0133] Perform detection and target recognition on the image feature information to obtain the candidate box;

[0134] The candidate box is corrected based on the text box information, and the image to be detected is detected based on the corrected candidate box and image feature information to obtain a detection result.

[0135] Optionally, the text box information includes a text box, and modifying the candidate box based on the text box information includes:

[0136] Check whether the candidate box is tangent to the text box;

[0137] When the candidate frame is tangent to the text frame, the candidate frame is corrected so that the text frame is included in the candidate frame.

[0138] Optionally, the candidate box and the text box both include N edges, and there is a one-to-one correspondence between the N edges of the candidate box and the N edges of the text box; N is an integer greater than or equal to 4; the candidate box and the text box are tangent to each other, which means that a target edge included in the candidate box is tangent to the text box; the target edge is any one of the N edges; and modifying the candidate box includes:

[0139] Replace the target edge of the candidate box with the edge in the text box that matches the target edge.

[0140] Optionally, the text box information includes a text box; performing feature extraction on the image to be detected to obtain image feature information of the image to be detected includes:

[0141] Based on the text box, draw an identification box corresponding to the text box in the image to be detected to obtain a drawn image;

[0142] Perform feature extraction on the drawn picture to obtain image feature information.

[0143] Optionally, the image processing method is performed by an object detection model, and the object detection model is trained based on a training data set;

[0144] The identification box is a semi-transparent box located on the upper layer of the image to be detected, and the pixel color in the identification box is the target pixel color. The target pixel color refers to the pixel color with the lowest frequency of occurrence among the pixel colors of the sample images in the training data set.

[0145] Optionally, when the image processing method is applied to the training process of the target detection model, feature extraction is performed on the image to be detected to obtain image feature information of the image to be detected, including:

[0146] Preprocessing the image to be detected to obtain a preprocessed image, wherein the preprocessing includes at least one of the following: scaling based on a random scaling ratio, and rotating based on a random angle;

[0147] Randomly crop an image region of a preset size from the preprocessed image to obtain a cropped image;

[0148] Perform feature extraction on the cropped image to obtain image feature information of the image to be detected.

[0149] Optionally, the image to be detected includes at least one of the following types of layout frames: a header layout frame, a footer layout frame, a table layout frame, a picture layout frame and a text layout frame;

[0150] The cropping conditions of random cropping include: the boundary line of the cropped image area of ​​the preset size is not tangent to the layout frame in the image to be detected.

[0151] An embodiment of the present application also provides an electronic device, including a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0152] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the above method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. Among them, the computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0153] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0154] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for an electronic device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods of each embodiment of the present application.

[0155] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A method for processing an image, characterized in that: include: Get the image to be detected containing text; Performing text box recognition on the image to be detected to obtain text box information in the image to be detected; Extracting features of the image to be detected to obtain image feature information of the image to be detected; Performing detection target recognition on the image feature information to obtain a candidate frame; The candidate frame is modified based on the text frame information, and the image to be detected is detected based on the modified candidate frame and the image feature information to obtain a detection result.

2. The method according to claim 1, characterized in that The text box information includes a text box, and the modifying the candidate box based on the text box information includes: Detecting whether the candidate frame is tangent to the text frame; In the case that the candidate frame is tangent to the text frame, the candidate frame is modified so that the text frame is included in the candidate frame.

3. The method according to claim 2, characterized in that The candidate box and the text box both include N edges, and there is a one-to-one correspondence between the N edges of the candidate box and the N edges of the text box; N is an integer greater than or equal to 4; the candidate box and the text box are tangent to each other, which means that the target edge included in the candidate box is tangent to the text box; The target edge is any one of the N edges; and the modifying the candidate frame includes: The target edge of the candidate box is replaced by an edge in the text box that matches the target edge.

4. The method according to claim 1, characterized in that: The text box information includes a text box; the feature extraction of the image to be detected to obtain image feature information of the image to be detected includes: Based on the text box, drawing an identification box corresponding to the text box in the picture to be detected to obtain a drawn picture; Feature extraction is performed on the drawn picture to obtain the image feature information.

5. The method according to claim 4, characterized in that The image processing method is performed by a target detection model, and the target detection model is trained based on a training data set; The identification frame is a semi-transparent frame located on the upper layer of the image to be detected, and the pixel color in the identification frame is the target pixel color, which refers to the pixel color with the lowest occurrence frequency among the pixel colors of the sample images in the training data set.

6. The method according to claim 1, characterized in that In the case where the image processing method is applied to a training process of a target detection model, extracting features from the image to be detected to obtain image feature information of the image to be detected includes: Preprocessing the image to be detected to obtain a preprocessed image, wherein the preprocessing includes at least one of the following: scaling based on a random scaling ratio, and rotating based on a random angle; Randomly cropping an image area of ​​a preset size from the preprocessed image to obtain a cropped image; Feature extraction is performed on the cropped image to obtain image feature information of the image to be detected.

7. The method according to claim 6, characterized in that The image to be detected includes at least one of the following types of layout frames: a header layout frame, a footer layout frame, a table layout frame, a picture layout frame and a text layout frame; The cropping condition of the random cropping includes: the boundary line of the cropped image area of ​​the preset size is not tangent to the layout frame in the image to be detected.

8. An image processing device, characterized in that: include: An acquisition module is used to acquire the image to be detected containing text; A recognition module, used to perform text box recognition on the image to be detected to obtain text box information in the image to be detected; A feature extraction module is used to extract features from the image to be detected to obtain image feature information of the image to be detected; The recognition module is further used to perform detection target recognition on the image feature information to obtain a candidate frame; A processing module is used to modify the candidate box based on the text box information, and detect the image to be detected based on the modified candidate box and the image feature information to obtain a detection result.

9. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the method according to any one of claims 1 to 7 when executed by the processor.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

11. A computer program product, characterized in that The computer program product is stored in a storage medium, and the computer program product is executed by at least one processor to implement the steps of the method according to any one of claims 1 to 7.