Document quality inspection and orientation correction method

Through the dating method of correcting correction and pre -training documents, the problem of difficulty detecting the internal quality of the documents in the existing technology and the problem of correction of the inclined and flipping status of the certificate are solved. The accuracy of extraction and validity identification.

CN118097099BActive Publication Date: 2025-01-28SHENZHEN WISE E-COMMERCE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211490456.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-25
Publication Date
2025-01-28
Estimated Expiration
2042-11-25

AI Technical Summary

Technical Problem

The prior art is difficult to detect internal quality problems of the certificate, such as perforation and rupture, and it is impossible to effectively correct the tilt and flip state of the certificate, affecting the extraction and validity identification of the certificate information.

Method used

Use the dynasty to correct the correction method. Through the calculation of the MASK outline and portrait MASK center point, judge the tilt angle and orientation of the document, and perform corresponding correction operations. At the same time, the pre -trained document segmentation model is used to test the completeness of the document.

Benefits of technology

The detection and correction of the internal quality of the document can be realized, the inclined angle and flip status of the document can be identified and adjusted, and the accuracy of the obtained and effective identification of the document information is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118097099B_ABST
    Figure CN118097099B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for document quality detection and orientation correction, which belongs to the field of image processing technology, and includes a correction method, which is composed of judging the inclination angle of the document and correcting it, judging the orientation of the document and correcting it, calculating the document MASK contour, and then calculating the inclined rectangle with the minimum area that tightly contains the document MASK contour, calculating the inclination angle θ of the rectangle and making corresponding corrections according to the angle θ. The present invention is based on a pre-trained document segmentation model, and with the help of a portrait MASK and a document MASK, it can handle more types of document orientation problems and make corrections, and can not only effectively detect defects such as corners, but also detect quality problems such as perforations, holes, and cracks, and can also achieve recognition, calculation and correction of the inclination angle of the document, and with the help of a portrait MASK and a document MASK, the orientation of the document is judged to solve the problems of flipping and rotating the document image by 180°, 90°, and 270°.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular to a document quality detection and orientation correction method. Background Art

[0002] ID photos are widely used in today's digital age, such as online financial management, e-commerce, real-name authentication, etc. Photos taken and uploaded by users often have various quality problems, and inevitably have various tilted, flipped and other random shooting phenomena, which have a great impact on the subsequent extraction of ID information and the validity identification of IDs. Relying solely on manual verification is not only a huge workload, but also prone to errors due to fatigue, carelessness, etc., and it is also impossible to verify ID photos uploaded by users in real time around the clock. Therefore, it is urgent to develop an automated image quality detection method.

[0003] In the prior art, the detection of document images is performed by extracting corners from the document graphics to obtain corner images, and a pre-built standard corner judgment model is used to determine the integrity of the corner images to obtain the document defect detection result. This method can only detect corner defects, but cannot detect quality problems such as perforations and cracks inside the document. The document can only be corrected through four corner points, but cannot determine whether the document is flipped horizontally or vertically. Therefore, a document quality detection and orientation correction method is proposed. Summary of the invention

[0004] The purpose of the present invention is to solve the problems in the prior art and to propose a document quality detection and orientation correction method.

[0005] In order to achieve the above object, the present invention adopts the following technical solutions:

[0006] A document orientation correction method, comprising a correction method, the correction method comprising determining the inclination angle of the document and correcting it and determining the orientation of the document and correcting it;

[0007] Determine the tilt angle of the document and correct it:

[0008] S1, calculate the document mask outline, and then calculate the smallest inclined rectangle that only contains the document mask outline;

[0009] S2, set the coordinates of the four points of the rectangle to the upper left , Top Right , bottom right and lower left , according to the lower left and lower right Coordinates or upper left and upper right Coordinates are used to calculate the tilt angle θ of the rectangle;

[0010] S3, when making correction, the original image is rotated in the opposite direction by an angle θ to adjust the angle of the document to be horizontal;

[0011] The above-mentioned determination and correction of the orientation of the certificate takes the image at the upper right corner of the certificate as an example:

[0012] S4. When the height of the document is greater than its width, it is judged to be rotated by 90° or 270°. In both cases, it is necessary to rotate it by 90° to make it wider than its height before proceeding to the next step of calculation;

[0013] S5. Calculate the center coordinates of the ID MASK, denoted as ; Calculate the coordinates of the center point of the portrait MASK, recorded as ;

[0014] S6, using the center coordinates of the certificate as the origin to determine the placement status of the certificate: normal placement, rotation of 180°, horizontal flip and vertical flip;

[0015] S7. If the document is judged to be in an abnormal placement state, a method corresponding to the placement state is used to correct it.

[0016] Preferably, the lower left and lower right Taking coordinates as an example, the calculation formula for the tilt angle θ is:

[0017] ,in , .

[0018] Preferably, the method for calculating the center coordinates of the ID MASK is as follows: the ID MASK is a binary image, in which the foreground area value is 1 and the background area value is 0, the index value with the value of 1 is calculated, the coordinates of each point in the foreground area are obtained, the average value of these coordinates is calculated and rounded down to obtain the coordinates of the center point of the ID MASK;

[0019] Similarly, the coordinates of the center point of the portrait MASK are calculated using the above calculation method.

[0020] Preferably, the method for judging in S6 using the center coordinates of the certificate as the origin is:

[0021] (1) If the center point of the portrait is in the first quadrant, that is, >0 and >0, it is normal placement;

[0022] (2) If the center point of the portrait is in the second quadrant, that is, <0 and >0, it is horizontal flip;

[0023] (3) If the center point of the portrait is in the third quadrant, that is <0 and <0, it is rotated 180°;

[0024] (4) If the center point of the portrait is in the fourth quadrant, that is >0 and <0, it is vertical flip.

[0025] The document quality detection method comprises the following steps:

[0026] Calculate the contour of the document MASK corrected by the document orientation correction method to obtain the calculated contour area of ​​the document MASK , and then calculate to get the bounding box area of ​​the contour ,set up is the ratio of the contour area to the bounding box area:

[0027] .

[0028] Preferably, a threshold t is set, if the ratio of the contour area to the bounding box area is If the ratio of the contour area to the bounding box area is greater than or equal to t, the document is considered intact. If it is less than t, the certificate is judged to be incomplete.

[0029] Compared with the prior art, the present invention has the following beneficial effects:

[0030] 1. The present invention is based on a pre-trained document segmentation model. With the help of portrait MASK and document MASK, it can handle more types of document orientation problems and correct them. It can not only effectively detect defects such as corners, but also detect quality problems such as perforations, holes, and cracks. It can also recognize, calculate, and correct the tilt angle of the document.

[0031] 2. Use the portrait mask and ID mask to determine the orientation of the ID card, so as to solve the problem of flipping and rotating the ID card image by 180°, 90°, and 270°. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 A schematic diagram of the document MASK coordinate system for the document quality detection and orientation correction method proposed in the present invention;

[0033] Figure 2 This is a structural schematic diagram of the document quality detection and orientation correction method proposed in the present invention. DETAILED DESCRIPTION

[0034] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0035] Embodiment 1

[0036] Reference Figure 1 The present invention is based on a pre-trained document segmentation model, outputs a document area mask MASK and a portrait area mask MASK (if there are other methods to obtain the document MASK and the portrait MASK, it is also acceptable), firstly performs orientation correction, and then performs a quality inspection to determine whether the document is incomplete;

[0037] A document orientation correction method, comprising a correction method, the correction method comprising determining the inclination angle of the document and correcting it and determining the orientation of the document and correcting it;

[0038] Determine the tilt angle of the document and correct it:

[0039] Calculate the document mask outline, and then calculate the smallest inclined rectangle that only contains the document mask outline;

[0040] Set the coordinates of the four points of the rectangle to the upper left , Top Right , bottom right and lower left , according to the lower left and lower right Coordinates or upper left and upper right Coordinates are used to calculate the tilt angle θ of the rectangle;

[0041] Lower left and lower right Taking coordinates as an example, the calculation formula for the tilt angle θ is:

[0042] ,in , .

[0043] When making corrections, the original image is rotated in the opposite direction by an angle of θ to adjust the angle of the document to a horizontal level;

[0044] The above-mentioned process of determining the orientation of the certificate and correcting it takes the image at the upper right corner of the certificate as an example:

[0045] When the height of the document is greater than its width, it is judged to be rotated 90° or 270°. In both cases, it is necessary to rotate 90° to make it wider than its height before proceeding to the next step of calculation;

[0046] Calculate the center coordinates of the ID MASK, recorded as ; The method for calculating the center coordinates of the ID MASK is as follows: the ID MASK is a binary image, where the foreground area value is 1 and the background area value is 0. The index value with a value of 1 is calculated to obtain the coordinates of each point in the foreground area. The average value of these coordinates is calculated and rounded down to obtain the coordinates of the center point of the ID MASK;

[0047] Similarly, the coordinates of the center point of the portrait MASK are calculated using the above calculation method, and the coordinates of the center point of the portrait MASK are calculated and recorded as .

[0048] The center coordinates of the certificate are used as the origin to determine the placement status of the certificate: normal placement, 180° rotation, horizontal flip and vertical flip;

[0049] The method for judging the origin with the center coordinates of the certificate is:

[0050] (1) If the center point of the portrait is in the first quadrant, that is, >0 and >0, it is normal placement;

[0051] (2) If the center point of the portrait is in the second quadrant, that is, <0 and >0, it is horizontal flip;

[0052] (3) If the center point of the portrait is in the third quadrant, that is <0 and <0, it is rotated 180°;

[0053] (4) If the center point of the portrait is in the fourth quadrant, that is >0 and <0, it is vertical flip.

[0054] If the document is judged to be in an abnormal placement state, it is corrected using a method corresponding to the placement state. For example, if it has been horizontally flipped, it can be horizontally flipped again to obtain a normal placement state.

[0055] Embodiment 2:

[0056] Reference Figure 2 , a document quality detection method, comprising the following steps:

[0057] Calculate the contour of the document MASK corrected by the document orientation correction method to obtain the calculated contour area of ​​the document MASK , and then calculate to get the bounding box area of ​​the contour ,set up is the ratio of the contour area to the bounding box area:

[0058] .

[0059] Preferably, a threshold t is set, if the ratio of the contour area to the bounding box area is If the ratio of the contour area to the bounding box area is greater than or equal to t, the document is considered intact. If it is less than t, the certificate is judged to be incomplete.

[0060] It is worth noting that the present invention can handle a wide variety of document types, not limited to identity documents, as long as the position of the portrait relative to the document when the document is normally placed is determined;

[0061] The present invention is very simple to implement. For example, the tilt angle of the MASK calculated in the above-mentioned determination of the tilt angle of the document and correction can be directly obtained from the tilted rectangle with the minimum area containing the outline of the MASK.

[0062] The present invention can be implemented and deployed using any programming language, and Python is used as an example below:

[0063] rely Image processing library, the operation steps are as follows:

[0064] Step 1: Read the ID MASK and portrait MASK in grayscale mode (or convert them into grayscale if they have been obtained by other means);

[0065] Step 2: Determine the tilt angle of the document and correct it;

[0066] Step 3: Determine the orientation of the document and correct it;

[0067] Step 4: Document integrity detection: pre-set the threshold t of the area ratio of the contour to the bounding box. For example, set t to 0.95 to calculate the Compare with t to determine whether the document is complete.

[0068] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and inventive concept of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.

Claims

1. A method for correcting the orientation of a certificate, characterized in that: The method comprises a correction method, wherein the correction method comprises determining the tilt angle of the document and correcting it, and determining the orientation of the document and correcting it; Determine the tilt angle of the document and correct it: S1, calculate the document mask outline, and then calculate the smallest inclined rectangle that only contains the document mask outline; S2, set the coordinates of the four points of the rectangle to the upper left , Top Right , bottom right and lower left , according to the lower left and lower right Coordinates or upper left and upper right Coordinates are used to calculate the tilt angle θ of the rectangle; S3, when making correction, the original image is rotated in the opposite direction by an angle θ to adjust the angle of the document to be horizontal; The method for determining the orientation of the certificate and correcting it is as follows: S4. When the height of the document is greater than its width, it is judged to be rotated by 90° or 270°. In both cases, it is necessary to rotate it by 90° to make it wider than its height before proceeding to the next step of calculation; S5. Calculate the center coordinates of the ID MASK, denoted as ; Calculate the coordinates of the center point of the portrait MASK, recorded as ; S6, using the center coordinates of the certificate as the origin to determine the placement status of the certificate: normal placement, rotation of 180°, horizontal flip and vertical flip; S7. If the document is in an abnormal placement state after determination, use a method corresponding to the placement state to correct it; The S2 is at the lower left and lower right Coordinate calculation, the calculation formula for the tilt angle θ is: ,in , The method for calculating the center coordinates of the document MASK in S6 is as follows: the document MASK is a binary image, in which the foreground area value is 1 and the background area value is 0, and the index value with the value of 1 is calculated to obtain the coordinates of each point in the foreground area, and the average value of these coordinates is calculated and rounded down to obtain the coordinates of the center point of the document MASK; The coordinates of the center point of the portrait MASK are calculated by using the method for calculating the center coordinates of the ID MASK in S6; The method for determining the origin of the document center coordinates in S6 is: (1) If the center point of the portrait is in the first quadrant, that is, >0 and >0, it is normal placement; (2) If the center point of the portrait is in the second quadrant, that is, <0 and >0, it is horizontal flip; (3) If the center point of the portrait is in the third quadrant, that is <0 and <0, it is rotated 180°; (4) If the center point of the portrait is in the fourth quadrant, that is >0 and <0, it is vertical flip.

2. A method for detecting the quality of a certificate after correction according to the method for correcting the orientation of a certificate according to claim 1, characterized in that: The following steps are involved: Calculate the contour of the document MASK corrected by the document orientation correction method to obtain the calculated contour area of ​​the document MASK , and then calculate to get the bounding box area of ​​the contour ,set up is the ratio of the contour area to the bounding box area: ; The ratio of the contour area to the bounding box area is set to a threshold t. If the ratio of the contour area to the bounding box area If the ratio of the contour area to the bounding box area is greater than or equal to t, the document is considered intact. If it is less than t, the certificate is judged to be incomplete.

Citation Information

Patent Citations

  • Card image tilt correction method and device, computer equipment and storage medium

    CN113538291A

  • Image processing apparatus, image forming apparatus, method of controlling the image processing apparatus, control program, and recording medium

    JP2010011359A