A paper correction method, system and storage medium in an image
The paper image is corrected through the key point detection model and the thin plate spline interpolation algorithm, which solves the problem of low distortion paper recognition accuracy in the existing technology and achieves automatic correction and improved recognition accuracy.
Patent Information
- Application Number
- CN202210482796.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-05
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2042-05-05
AI Technical Summary
When the existing technology processes paper images with imaging errors or distortions, the text recognition accuracy is low. Especially when the paper is folded or the shooting angle is poor, the distortion cannot be effectively corrected, resulting in a high recognition error rate.
A key point detection model (such as the HourGlass algorithm) is used to determine the center point and edge key points of the paper, a paper template is constructed, a transformation matrix is generated by a thin plate spline interpolation algorithm to correct the paper, and a corrected paper image is generated.
It realizes the automatic correction of deformed paper, significantly reduces the text recognition error rate, has low cost and strong versatility.
Smart Images

Figure CN115100658B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, system and storage medium for correcting paper in an image. Background Art
[0002] With the development of computer vision technology, optical character recognition (OCR) technology plays an important role in today's intelligent office. In the processing of bill forms and other related work, character recognition technology is widely used because of its fast recognition speed, high recognition accuracy, simple operation, and ability to greatly improve work efficiency. For the recognition of characters on paper, it is usually necessary to identify the circumscribed rectangle of the area where the characters are located; however, the shooting environment of paper is complex, and the current recognition of characters on paper has the following key problems: (1) camera fisheye distortion and imaging errors caused by large inclination angles; (2) distortion introduced by paper folding and paper twisting; (3) distortion caused by shooting angle.
[0003] The above-mentioned paper with imaging errors or distortions is very difficult to recognize text. In particular, when the paper is folded or the camera is tilted too much during shooting, the paper in the image is distorted, which greatly reduces the accuracy of subsequent text recognition. The current text recognition algorithm based on deep learning only focuses on the detection and recognition of text, without considering the impact of the distortion introduced by the paper folding and camera shooting. When the paper is folded or the shooting angle is not good and there is distortion, the existing text recognition algorithm can detect the distorted text area very accurately, but when the detected rectangular area is sent to the recognition network, the distortion in the recognition area will cause low text recognition accuracy. Therefore, how to quickly and accurately correct the deformed paper in the paper image and reduce the error rate of text recognition in the distorted paper is a technical problem that needs to be solved urgently. Summary of the invention
[0004] In view of this, the present invention provides a method, system and storage medium for correcting paper in an image to solve one or more problems existing in the prior art.
[0005] According to one aspect of the present invention, the present invention discloses a method for correcting paper in an image, the method comprising:
[0006] Acquire a paper image, and input the paper image into a trained key point detection model to output a central area heat map and an edge key point regression map of the paper image;
[0007] Determine the coordinates of the center point position of the paper to be corrected in the paper image based on the central area heat map, and use the values corresponding to the center point position in each edge key point regression map as the coordinates of the corresponding edge key point of the paper to be corrected;
[0008] Acquire a paper size in the paper image, construct a paper template based on the acquired paper size, and calculate the coordinates of each target key point on the paper template corresponding to each edge key point based on the determined number of each edge key point;
[0009] The paper to be corrected is corrected based on the coordinates of the edge key points and the coordinates of the target key points to generate a corrected paper.
[0010] In some embodiments of the present invention, the paper to be corrected is corrected based on the coordinates of the edge key points and the coordinates of the target key points, including:
[0011] Generate a matching point pair based on the coordinates of the edge key point and the coordinates of the target key point;
[0012] Inputting the matching point pair into a thin plate spline interpolation algorithm to obtain a transformation matrix between the coordinates of the edge key point and the coordinates of the target key point;
[0013] The paper to be corrected is corrected based on the transformation matrix.
[0014] In some embodiments of the present invention, the algorithm used by the key point detection model is the HourGlass algorithm or the CornerNet algorithm.
[0015] In some embodiments of the present invention, when the algorithm adopted by the key point detection model is the HourGlass algorithm, the HourGlass algorithm includes a central area regression branch and an edge key point regression branch.
[0016] In some embodiments of the present invention, the loss function of the HourGlass algorithm is:
[0017] Loss = L P +α×L C ;
[0018] Among them, the L P is the loss corresponding to the heat map of the central area, and the L P Calculated using the Focal Loss function; L C is the loss corresponding to the edge key point regression graph, and the L P Calculated using the Smooth L1 loss function; α is the weight coefficient.
[0019] In some embodiments of the present invention, determining the coordinates of the center point of the paper to be corrected in the paper image based on the central area heat map includes:
[0020] Extracting peak values from the central area heat map;
[0021] The position coordinates corresponding to the extracted peak value are used as the position coordinates of the center point of the paper to be corrected.
[0022] In some embodiments of the present invention, the shape of the paper template is a rectangle; the coordinates of the target key points on the upper edge of the paper template are respectively: The coordinates of the target key points at the lower edge of the paper template are: in, W2 is the width of the paper template, H2 is the height of the paper template, i is the number of target key points on the upper edge or lower edge of the paper template, and k is the number of edge key points.
[0023] In some embodiments of the present invention, the coordinates of the target key points on the left edge of the paper template are respectively: The coordinates of the target key points on the right edge of the paper template are: in, W2 is the width of the paper template, H2 is the height of the paper template, j is the number of target key points on the left edge or right edge of the paper template, and k is the number of edge key points.
[0024] According to another aspect of the present invention, a paper correction system in an image is also disclosed, the system comprising a processor and a memory, wherein the memory stores computer instructions, the processor is used to execute the computer instructions stored in the memory, and when the computer instructions are executed by the processor, the system implements the steps of the method described in any of the above embodiments.
[0025] According to another aspect of the present invention, a computer-readable storage medium is also disclosed, on which a computer program is stored, characterized in that when the program is executed by a processor, the steps of the method described in any of the above embodiments are implemented.
[0026] The paper correction method, system and storage medium in the image disclosed in the embodiments of the present invention determine the center point position coordinates and the coordinates of the edge key points of the paper in the paper image based on the key point detection model, and further determine the coordinates of each target key point corresponding to each edge key point based on the newly created paper template, and further correct the paper to be corrected based on the determined edge key points and target key points. The correction method realizes automatic and convenient correction of deformed paper in the image, thereby reducing the error rate of subsequent text recognition; and the method has low deployment cost and strong versatility.
[0027] Additional advantages, purposes, and features of the present invention will be described in part in the following description, and will become apparent to those skilled in the art after studying the following, or may be learned from the practice of the present invention. The purposes and other advantages of the present invention may be achieved and obtained by the structures specifically pointed out in the written description, claims, and drawings.
[0028] Those skilled in the art will appreciate that the objectives and advantages that can be achieved with the present invention are not limited to the above specific description, and the above and other objectives that can be achieved by the present invention will be more clearly understood from the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The drawings described herein are used to provide a further understanding of the present invention, constitute a part of this application, and do not constitute a limitation of the present invention. The components in the drawings are not drawn to scale, but are only for illustrating the principles of the present invention. In order to facilitate the illustration and description of some parts of the present invention, the corresponding parts in the drawings may be enlarged, that is, they may become larger relative to other components in the exemplary device actually manufactured according to the present invention. In the drawings:
[0030] Figure 1 FIG. 4 is a flow chart of a method for correcting paper in an image according to an embodiment of the present invention.
[0031] Figure 2 FIG. 4 is a flow chart of a method for correcting paper in an image according to another embodiment of the present invention.
[0032] Figure 3 4 is a structural principle diagram of a method for correcting paper in an image according to an embodiment of the present invention. DETAILED DESCRIPTION
[0033] To make the purpose, technical solution and advantages of the embodiments of the present invention more clear, the embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings. Here, the exemplary embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.
[0034] It should be noted here that in order to avoid obscuring the present invention due to unnecessary details, only structures and / or processing steps closely related to the solutions according to the present invention are shown in the accompanying drawings, while other details that are not closely related to the present invention are omitted.
[0035] It should be emphasized that the terms “include / comprises / has” when used herein refer to the presence of features, elements, steps or components, but do not exclude the presence or addition of one or more other features, elements, steps or components.
[0036] Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. In the accompanying drawings, the same reference numerals represent the same or similar components, or the same or similar steps.
[0037] Figure 1 FIG. 1 is a flow chart of a method for correcting paper in an image according to an embodiment of the present invention. Figure 1 As shown, the correction method at least includes steps S10 to S40.
[0038] Step S10: Acquire a paper image, and input the paper image into a trained key point detection model to output a central area heat map and an edge key point regression map of the paper image.
[0039] In this step, the paper image is an image taken by a camera containing paper information, and the paper in the image is twisted or distorted during the imaging process, so the acquired paper image is the image to be corrected. The paper image is input into the trained key point detection model in order to detect the key points of the paper in the paper image, and the key points include the center key points and the edge key points; it can be understood that the paper image may contain the information of one or more sheets of paper.
[0040] There is no specific restriction on the algorithm used by the key point detection model, as long as it can complete the key point detection of the paper image. Exemplarily, the algorithm used by the key point detection model is the HourGlass algorithm or the CornerNet algorithm; taking the HourGlass algorithm as an example, if you want to obtain the central area heat map and edge key point regression map of the paper image, the HourGlass algorithm includes a central area regression branch and an edge key point regression branch. The central area regression branch is used to obtain the central area heat map of the paper image, and the edge key point regression branch is used to obtain the edge key point regression map of the paper image.
[0041] Specifically, the center area regression branch is used to regress the center point of the paper to generate a two-dimensional Gaussian heat map of the same size as the original image, and the paper edge key point regression branch is used to regress the edge key points of each side of each paper. And in one embodiment, this step specifically includes: obtaining a paper image; extracting the features of the paper image through the HourGlass algorithm to obtain a feature map corresponding to the paper image; further based on the extracted feature map, regressing and analyzing through the center area regression branch of the HourGlass algorithm to obtain a center area heat map; and then based on the extracted feature map, regressing and analyzing through the edge key point regression branch of the HourGlass algorithm to obtain an edge key point regression map. It should be understood that in the above example, the key point detection model based on the HourGlass algorithm is used as an example, and the key point detection model based on the CornerNet algorithm or other algorithms is similar to the implementation process of this embodiment, which will not be repeated here.
[0042] In another embodiment of the present invention, when the algorithm used by the key point detection model is the HourGlass algorithm, the loss function of the HourGlass algorithm is:
[0043] Loss = L P +α×L c ;
[0044] Among them, the L P is the loss corresponding to the heat map of the central area, and the L P Calculated using the Focal Loss function; L c is the loss corresponding to the edge key point regression graph, and the L P Calculated using the Smooth L1 loss function; α is the weight coefficient.
[0045] Step S20: determining the coordinates of the center point position of the paper to be corrected in the paper image based on the central area heat map, and taking the values corresponding to the center point positions in the edge key point regression maps as the coordinates of the corresponding edge key points of the paper to be corrected.
[0046] In this step, the center point position coordinates of the paper to be corrected in the paper image are determined based on the center area heat map obtained in step S10. The paper to be corrected in the paper image is the paper that has been distorted or has imaging errors in the paper image. It can be seen from step S10 that the number of papers in the paper image can be one or more. Therefore, it can be understood that when the paper image contains only one paper, only one set of center point position coordinates is obtained; and if the paper image contains multiple papers, multiple sets of center point position coordinates can be obtained based on the center area heat map, that is, the multiple sets of center point position coordinates represent the center points of multiple papers. Similarly, when there are multiple drawings in the paper image, the corresponding determined edge key points are also the edge key points corresponding to the multiple papers.
[0047] Exemplarily, determining the position coordinates of the center point of the paper to be corrected in the paper image based on the central area heat map includes: extracting the peak value of the central area heat map; and using the position coordinates corresponding to the extracted peak value as the position coordinates of the center point of the paper to be corrected. For example, when the paper image contains only one paper to be corrected, the center point coordinates of the paper to be corrected extracted based on the central area heat map can be recorded as (C x ,C y ).
[0048] Since the number of edge key points corresponding to each paper to be corrected is multiple, the number of edge key point regression maps output by the key point detection model is also multiple. For example, when the number of edge key points corresponding to the paper to be corrected is K, the generated edge key point regression map includes edge key point regression maps corresponding to K x coordinates and edge key point regression maps corresponding to K y coordinates, that is, the number of generated edge key point regression maps is 2×K. When determining the coordinates of the edge key points, first determine the position of the X-axis coordinate of the edge key point in the corresponding edge key point regression map based on the determined center point position of the paper, and obtain the value of the position as the X-axis coordinate of the edge key point; then determine the position of the Y-axis coordinate of the edge key point in the corresponding edge key point regression map based on the determined center point position of the paper, and then obtain the value of the position as the Y-axis coordinate of the edge key point. Therefore, the coordinates of K edge key points can be determined based on 2K edge key point regression maps; for example, the coordinate set of K edge key points can be recorded as [(X1,Y1),(X2,Y2),...,(X k ,Y k )].
[0049] In this step, the center point of each paper in the image can be obtained by performing MaxPooling and NMS (non-maximum suppression) on the central area heat map (two-dimensional Gaussian heat map); the paper edge key point regression branch is used to regress the edge key points of the four edges of each paper. For K key points, the paper key point regression branch generates 2*K edge key point regression maps of the same size as the original image; the X coordinate of the Nth key point can be obtained based on 2N-1 regression maps, and the Y coordinate of the Nth key point can be obtained based on the 2Nth regression map.
[0050] Step S30: Acquire the paper size in the paper image, construct a paper template based on the acquired paper size, and calculate the coordinates of each target key point on the paper template corresponding to each edge key point based on the determined number of each edge key point.
[0051] In this step, the paper size in the paper image can be pre-set or extracted based on the information of the paper to be corrected in the paper image. Assuming that the shape of the paper is rectangular, the edge key points of the paper are the key points located on the upper, lower, left and right edges of the rectangular paper. If the shape of the uncorrected paper is rectangular, the shape of the paper template should also be rectangular, and the size of the paper template should also be consistent with the size of the uncorrected paper. In addition, it should be understood that the target key point is the target edge key point on the paper template; in order to facilitate the distinction from the edge key points on the paper to be corrected, the target edge key point on the paper template is defined as the target key point in this article.
[0052] In step S20, the coordinates of the K edge key points obtained are [(X1, Y1), (X2, Y2), ..., (X k ,Y k ) can be the relative coordinates normalized based on the paper size. When the width and height of the paper to be corrected are W1 and H1 respectively, the actual coordinate set of the K edge key points should be [(W1*X1,H1*Y1),(W1*X2,H1*Y2),…,(W1*X k ,H1*Y k )]. In addition, the multiple edge key points located at the edge of the paper to be corrected are evenly spaced based on the size of the paper to be corrected; if the positions of the multiple edge key points are not evenly spaced, the expression form of the actual coordinate set of each edge key point will change accordingly; in common, the actual coordinates of each edge key point can be calculated based on the spacing between the edge key points, the normalized coordinates of the edge key points and the size of the paper.
[0053] Exemplarily, the coordinates of each target key point on the paper template corresponding to each edge key point are calculated based on the determined number of each edge key point, specifically including: taking target key points on the corresponding edge of the paper template in equal proportion, and the number of target key points on each edge is equal to the number of edge key points on the corresponding edge of the paper to be corrected. For example, if the shape of the paper to be corrected is a rectangle and the size of the rectangle is W1×H1, then the shape of the newly created paper template is also a rectangle, and the size of the rectangular paper template is W2×H2, and W2 is equal to W1, and H2 is equal to H1. If the number of edge key points located on the upper edge of the paper to be corrected is four, then the upper edge of the paper template is further divided into four equal parts to obtain the corresponding multiple target key points on the upper edge of the paper template; the method for determining the target key points of other edges on the paper template is similar to the method for determining the target key points of the upper edge of the paper template.
[0054] In one embodiment, the coordinates of the target key points on the upper edge of the paper template are: The coordinates of the target key points at the lower edge of the paper template are: in, W2 is the width of the paper template, H2 is the height of the paper template, i is the number of target key points on the upper or lower edge of the paper template, and k is the number of edge key points. The coordinates of the target key points on the left edge of the paper template are: The coordinates of the target key points on the right edge of the paper template are: in, W2 is the width of the paper template, H2 is the height of the paper template, j is the number of target key points on the left edge or right edge of the paper template, and k is the number of edge key points.
[0055] It should be understood that the calculation method of the target key points listed above is only a preferred example, and it can also be changed or replaced according to the actual application scenario, as long as the position of the obtained target key points corresponds to the position of the edge key points one by one.
[0056] Step S40: Correcting the paper to be corrected based on the coordinates of the edge key points and the coordinates of the target key points to generate a corrected paper.
[0057] In this step, the coordinates of the edge key points and the coordinates of the target key points form a matching point pair, and the paper to be corrected is further corrected based on the formed control point pair. Exemplarily, correcting the paper to be corrected based on the coordinates of the edge key points and the coordinates of the target key points specifically includes: generating a matching point pair based on the coordinates of the edge key points and the coordinates of the target key points; inputting the matching point pair into a thin plate spline interpolation algorithm to obtain a transformation matrix between the coordinates of the edge key points and the coordinates of the target key points; and correcting the paper to be corrected based on the transformation matrix.
[0058] In the above embodiment, the thin plate spline interpolation algorithm (TPS) is used as the paper correction algorithm. The thin plate spline interpolation algorithm is a kind of interpolation method and a commonly used 2D interpolation method. Specifically, if some corresponding control points in two pictures are given (edge key points in the paper to be corrected and target key points in the paper template), the thin plate spline interpolation algorithm is used to analyze how to perform a specific deformation on one of the pictures so that its control points can coincide with the control points of the other picture, that is, the deformation matrix between the edge key points and the target key points is calculated based on the thin plate spline interpolation algorithm.
[0059] In addition, if there are multiple papers on the paper image, multiple groups of matching point pairs are generated. Similarly, the transformation matrix corresponding to each paper to be corrected can be obtained based on the thin plate spline interpolation algorithm.
[0060] The above method is described below in conjunction with a specific embodiment. However, it should be noted that the specific embodiment is only for better illustrating the present application and does not constitute an improper limitation on the present application. Figure 2 As shown, the paper correction method in the image specifically includes: S100 to S07.
[0061] Step S100: input the image to be detected.
[0062] Specifically, the image is a paper image, and the present invention can automatically detect and correct the paper in the image by photographing the paper to be identified and sending the photographed image to the network after standardization. In this step, standardizing the photographed image means processing the image into a standard format, including resizing, etc.
[0063] Step S101: Use HourGlass to perform paper center area regression and key point regression.
[0064] Specifically, the image output after the standardization in step S100 is sent to Figure 3 The HourGlass network shown in Figure 3The paper center area regression map (or center area heat map) and edge key point regression map are shown. Preferably, in the embodiment of the present invention, k=24 edge control points are regressed, and the network outputs a center area regression map and 48 edge key point regression maps. In addition, it should be noted that the paper information in the paper image in the accompanying drawings of the embodiment of the present invention is only used to indicate the state of the paper, and the specific text content in the paper is not analyzed in the present invention, that is, the text content in the paper can be ignored.
[0065] Specifically, the HourGlass algorithm includes a central area regression branch and a paper edge key point regression branch; the central area regression branch is used to regress the center point of the paper and generate a two-dimensional Gaussian heat map with the same size as the original image.
[0066] Step S102: Calculate the center point of each piece of paper in the image.
[0067] Specifically, the center point of each paper in the image can be obtained by performing peak extraction and NMS (non-maximum suppression) on the central area regression map output in step S101.
[0068] Step S103: Calculate the edge key points of each paper in the image.
[0069] Specifically, by obtaining the center point coordinates (C x ,C y ), the relative coordinates of the 24 edge key points of each paper are obtained from the positions corresponding to the 48 edge control point regression maps output in step S101 [(X1, Y1), (X2, Y2), ..., (X k ,Y k )], and finally, by combining the width W1 and height H1 of the image input in step S100, the coordinate set S of the 24 edge key points of each paper is calculated. C , S C =[(W1*X1,H1*Y1),(W1*X2,H1*Y2),…,(W1*X k ,H1*Y k )], where W1 is the width of the paper to be corrected and H1 is the height of the paper to be corrected.
[0070] Step S104: Reconstruct the paper width and height to obtain a rectangular template, and calculate the target key points of the template.
[0071] Specifically, the width and height of the A4 paper are used as the reconstructed width and height to obtain a rectangular template, whose width and height are recorded as W2 and H2, and K target key points are taken in equal proportion on the upper, lower, left and right edges of the rectangular template. Preferably, K=24 in the embodiment of the present invention.
[0072] in:
[0073] The key points on the top of the rectangle are
[0074] The key points of the bottom side of the rectangle are
[0075] The key point on the left side of the rectangle is
[0076] The key points on the right side of the rectangle are
[0077] W2 is the width of the paper template, H2 is the height of the paper template, i is the number of target key points on the upper edge or lower edge of the paper template, j is the number of target key points on the left edge or right edge of the paper template, and k is the number of edge key points.
[0078] Step S105: Calculate the transformation matrix according to the edge key points and the target key points.
[0079] Specifically, the edge key points obtained in step S103 are used as control points, and the target key points obtained in step S104 are used as target points to calculate the transformation matrix required by the correction algorithm. Specifically, the correction algorithm uses a thin plate spline interpolation algorithm (TPS).
[0080] Step S106: transform the original input image (paper to be corrected) through a transformation matrix to obtain the corrected paper.
[0081] Specifically, the paper in step S100 is transformed by using the transformation matrix calculated in step S105 to obtain the corrected paper.
[0082] Step S107: looping steps S104 to S106 until all the paper in the image is corrected.
[0083] In this embodiment, step S104 to step S106 are executed cyclically because the paper image in this embodiment has a plurality of paper sheets to be corrected. It is easy to understand that when there is only one paper sheet to be corrected in the paper image, step S107 can be omitted.
[0084] Through the above embodiments, it can be found that the paper correction method in the image adopts a paper detection algorithm (HourGlass), a paper reconstruction algorithm and a paper correction algorithm. The paper detection algorithm HourGlass includes a paper center area regression branch and a paper edge key point regression branch; when the paper in the image is distorted, the method can automatically correct the distorted paper to reduce the error rate of subsequent text recognition; and the method automatically performs recognition and correction throughout the entire process, greatly reducing labor costs; in addition, the method can be combined with any existing text recognition technology, and has the characteristics of low deployment cost and strong versatility.
[0085] Correspondingly, the present invention also discloses a paper correction system in an image, which includes a processor and a memory, wherein the memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the system implements the steps of the method described in any of the above embodiments.
[0086] In addition, the invention also discloses a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of the method described in any of the above embodiments are implemented.
[0087] It should be understood by those skilled in the art that the exemplary components, systems and methods described in conjunction with the embodiments disclosed herein can be implemented in hardware, software or a combination of the two. Whether it is performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention. When implemented in hardware, it can be, for example, an electronic circuit, an application-specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present invention are programs or code segments used to perform the required tasks. The program or code segment can be stored in a machine-readable medium or transmitted on a transmission medium or a communication link via a data signal carried in a carrier. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, and the like. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.
[0088] It should also be noted that the exemplary embodiments mentioned in the present invention describe some methods or systems based on a series of steps or devices. However, the present invention is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiments, or in a different order from the embodiments, or several steps can be performed simultaneously.
[0089] In the present invention, features described and / or illustrated for one embodiment may be used in the same or similar manner in one or more other embodiments, and / or combined with features of other embodiments or replace features of other embodiments.
[0090] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for correcting paper in an image, characterized in that: The method comprises: Acquire a paper image, and input the paper image into a trained key point detection model to output a central area heat map and an edge key point regression map of the paper image; Determine the coordinates of the center point position of the paper to be corrected in the paper image based on the central area heat map, and use the values corresponding to the center point position in each edge key point regression map as the coordinates of the corresponding edge key point of the paper to be corrected; Acquire a paper size in the paper image, construct a paper template based on the acquired paper size, and calculate the coordinates of each target key point on the paper template corresponding to each edge key point based on the determined number of each edge key point; Correcting the paper to be corrected based on the coordinates of the edge key points and the coordinates of the target key points to generate a corrected paper; The paper to be corrected is corrected based on the coordinates of the edge key points and the coordinates of the target key points, including: Generate a matching point pair based on the coordinates of the edge key point and the coordinates of the target key point; Inputting the matching point pair into a thin plate spline interpolation algorithm to obtain a transformation matrix between the coordinates of the edge key point and the coordinates of the target key point; Correcting the paper to be corrected based on the transformation matrix; The shape of the paper template is a rectangle; the coordinates of the target key points on the upper edge of the paper template are: The coordinates of the target key points at the lower edge of the paper template are: in, W2 is the width of the paper template, H2 is the height of the paper template, i is the number of target key points on the upper edge or lower edge of the paper template, and k is the total number of edge key points.
2. The paper correction method in an image according to claim 1, characterized in that: The algorithm used by the key point detection model is the HourGlass algorithm or the CornerNet algorithm.
3. The paper correction method in an image according to claim 2, characterized in that: When the algorithm adopted by the key point detection model is the HourGlass algorithm, the HourGlass algorithm includes a central area regression branch and an edge key point regression branch.
4. The paper correction method in an image according to claim 3, characterized in that: The loss function of the HourGlass algorithm is: Loss=L P +α×L C ; Among them, the L P is the loss corresponding to the heat map of the central area, and the L P Calculated using the Focal Loss function; L C is the loss corresponding to the edge key point regression graph, and the L P Calculated using the Smooth L1 loss function; α is the weight coefficient.
5. The paper correction method in an image according to claim 1, characterized in that: Determining the center point position coordinates of the paper to be corrected in the paper image based on the center area heat map includes: Extracting peak values from the central area heat map; The position coordinates corresponding to the extracted peak value are used as the position coordinates of the center point of the paper to be corrected.
6. The paper correction method in an image according to claim 1, characterized in that: The coordinates of the target key points on the left edge of the paper template are: The coordinates of the target key points on the right edge of the paper template are: in, W2 is the width of the paper template, H2 is the height of the paper template, j is the number of target key points on the left edge or right edge of the paper template, and k is the number of edge key points.
7. A paper correction system in an image, the system comprising a processor and a memory, characterized in that: The memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the system implements the steps of the method as claimed in any one of claims 1 to 6.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Text image correction method and device, computer device and storage medium
CN110866871A
License plate key point correction method, system and device and storage medium
CN111709884A
