CN118097099A - Certificate quality detection and orientation correction method - Google Patents
Certificate quality detection and orientation correction method Download PDFInfo
- Publication number
- CN118097099A CN118097099A CN202211490456.1A CN202211490456A CN118097099A CN 118097099 A CN118097099 A CN 118097099A CN 202211490456 A CN202211490456 A CN 202211490456A CN 118097099 A CN118097099 A CN 118097099A
- Authority
- CN
- China
- Prior art keywords
- certificate
- mask
- area
- coordinates
- calculating
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 38
- 238000012937 correction Methods 0.000 title claims abstract description 30
- 238000001514 detection method Methods 0.000 title claims abstract description 13
- 238000004364 calculation method Methods 0.000 claims abstract description 11
- 230000002159 abnormal effect Effects 0.000 claims description 3
- 238000012545 processing Methods 0.000 abstract description 3
- 230000011218 segmentation Effects 0.000 abstract description 3
- 230000007547 defect Effects 0.000 abstract description 2
- 238000010586 diagram Methods 0.000 description 2
- 238000000605 extraction Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000018109 developmental process Effects 0.000 description 1
- 238000007689 inspection Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000012795 verification Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/20—Image preprocessing
- G06V10/24—Aligning, centring, orientation detection or correction of the image
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Multimedia (AREA)
- Theoretical Computer Science (AREA)
- Image Analysis (AREA)
Abstract
The invention discloses a certificate quality detection and orientation correction method, which belongs to the technical field of image processing and comprises a correction method, wherein the correction method comprises the steps of judging the inclination angle of a certificate, correcting, judging the orientation of the certificate and correcting, calculating the MASK outline of the certificate, then calculating to obtain an inclined rectangle which tightly contains the minimum area of the MASK outline of the certificate, calculating the inclination angle theta of the rectangle and carrying out corresponding correction according to the angle theta. The invention can process more types of certificate orientation problems and correct the problems by means of the portrait MASK and the certificate MASK based on a pre-trained certificate segmentation model, can effectively detect defects such as corners and the like, can detect quality problems of perforation, holes and breakage, can achieve identification calculation and correction of inclination angles of the certificates, and can judge the orientation of the certificates by means of the portrait MASK and the certificate MASK so as to solve the problems of overturning and rotating 180 DEG, rotating 90 DEG and rotating 270 DEG of the certificate pictures.
Description
Technical Field
The invention relates to the technical field of image processing, in particular to a certificate quality detection and orientation correction method.
Background
The identity document photo has wide application in the present digital age, such as online financial management, electronic commerce, real-name authentication and the like, often has various quality problems for the user to shoot the uploaded photo, and can not avoid the random shooting phenomena such as various inclinations, overturns and the like, thereby having great influence on the subsequent document information extraction and the validity authentication of the document. The manual verification is only used, so that the workload is huge, errors such as fatigue, carelessness and the like are easy to occur, and meanwhile, the certificate photos uploaded by the user cannot be verified in real time in all weather, so that the development of an automatic image quality detection method is urgent.
In the prior art, the corner image is obtained by carrying out corner extraction on the certificate image according to the detection of the certificate image, and the integrity judgment is carried out on the corner image by utilizing a pre-constructed standard corner judgment model to obtain the incomplete detection result of the certificate.
Disclosure of Invention
The invention aims to solve the problems in the prior art and provides a certificate quality detection and orientation correction method.
In order to achieve the above purpose, the present invention adopts the following technical scheme:
The certificate orientation correction method comprises a correction method, wherein the correction method comprises the steps of judging the inclination angle of the certificate and correcting the orientation of the certificate;
Judging the inclination angle of the certificate and correcting:
S1, calculating a MASK outline of the certificate, and then calculating to obtain an inclined rectangle which tightly contains the minimum area of the MASK outline of the certificate;
S2, setting four point coordinates of the rectangle as upper left P 0(X0,Y0), upper right P 1(X1,Y1), lower right P 2(X2,Y2) and lower left P 3(X3,Y3), and calculating the inclination angle theta of the rectangle according to the lower left P 3(X3,Y3) and lower right P 2(X2,Y2) coordinates or the upper left P 0(X0,Y0) and upper right P 1(X1,Y1) coordinates;
S3, when correction is carried out, the original image is reversely rotated by an angle theta to achieve the aim of adjusting the angle of the evidence to be horizontal;
the orientation of the certificate is judged and corrected, and the upper right of the certificate is taken as an example of the image:
S4, when the height of the certificate is larger than the width, judging that the certificate rotates by 90 degrees or 270 degrees, and in both the above two cases, rotating by 90 degrees to enable the certificate to be in a state of being larger than the width, and then performing the next calculation;
S5, calculating the center coordinates of the certificate MASK, and marking the center coordinates as PCARDCENTER = (X C,YC); calculating the coordinates of the center point of the portrait MASK, and marking as PPhotoCenter = (X p,Yp);
S6, judging by taking the center coordinates of the certificate as an origin to obtain the placement state of the certificate: normal placement, rotation 180 °, horizontal flip and vertical flip;
and S7, correcting the situation that the certificate is in the abnormal placement state after judgment by using a method corresponding to the placement state.
Preferably, taking the coordinates of the lower left P 3(X3,Y3) and the lower right P 2(X2,Y2) as an example in S2, the calculation formula of the inclination angle θ is:
θ=90° -arctan (d y/dx), where d y=-(y2-y3),dX=X2-X3.
Preferably, the central coordinate method for calculating the certificate MASK is as follows: the certificate MASK is a binary image, wherein the foreground area value is 1, the background area value is 0, the index value with the value of 1 is calculated to obtain the coordinate of each point of the foreground area, the average value of the coordinates is calculated, and the center point coordinate of the certificate MASK is obtained by rounding down;
Similarly, the coordinates of the center point of the portrait MASK are calculated by the calculation mode.
Preferably, in the step S6, the method for determining using the center coordinates of the certificate as the origin is as follows:
(1) If the portrait center point is in the first quadrant, that is, X P >0 and Y P >0, then normal placement is established;
(2) If the portrait center point is in the second quadrant, i.e., X P <0 and Y P >0, then it is flipped horizontally;
(3) If the portrait center point is in the third quadrant, i.e., X P <0 and Y P <0, then it is rotated 180 °;
(4) If the portrait center point is in the fourth quadrant, X P >0 and Y P <0, then it is flipped vertically.
The certificate quality detection method comprises the following steps:
Calculating the contour of the certificate MASK corrected by the certificate orientation correction method to obtain the contour area area_cnt of the certificate MASK calculated, and then calculating to obtain the boundary frame area area_rect of the contour, wherein ratio is set as the ratio of the contour area to the boundary frame area:
ratio=area_cnt/area_rect。
Preferably, a threshold t is set, if the ratio of the contour area to the bounding box area is greater than or equal to t, the certificate is judged to be complete, and if the ratio of the contour area to the bounding box area is less than t, the certificate is judged to be incomplete.
Compared with the prior art, the invention has the beneficial effects that:
1. The invention can process more types of certificate orientation problems and correct by means of portrait MASK and certificate MASK based on a pre-trained certificate segmentation model, can effectively detect defects such as corners and the like, can detect quality problems of perforation, holes and breakage, and can also achieve identification, calculation and correction of inclination angles of the certificates.
2. The orientation of the certificate is judged by means of the portrait MASK and the certificate MASK, so that the problems of turning over and rotating 180 DEG, 90 DEG and 270 DEG of the certificate picture are solved.
Drawings
FIG. 1 is a schematic diagram of a certificate MASK coordinate system of a certificate quality detection and orientation correction method according to the invention;
Fig. 2 is a schematic structural diagram of a certificate quality detection and orientation correction method according to the present invention.
Detailed Description
The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are only some embodiments of the present invention, but not all embodiments, and all other embodiments obtained by those skilled in the art without making creative efforts based on the embodiments of the present invention are included in the protection scope of the present invention.
Example 1
Referring to fig. 1, the present invention outputs a document area MASK and a portrait area MASK (if other methods can obtain a document MASK and a portrait MASK), based on a pre-trained document segmentation model, first performs orientation correction, and then performs quality detection of whether the document is incomplete;
The certificate orientation correction method comprises a correction method, wherein the correction method comprises the steps of judging the inclination angle of the certificate and correcting the orientation of the certificate;
Judging the inclination angle of the certificate and correcting:
calculating the contour of the certificate MASK, and then calculating an inclined rectangle which tightly contains the minimum area of the contour of the certificate MASK;
Assuming that four point coordinates of the rectangle are upper left P 0(X0,Y0), upper right P 1(X1,Y1), lower right P 2(X2,Y2) and lower left P 3(X3,Y3), calculating an inclination angle theta of the rectangle according to lower left P 3(X3,Y3) and lower right P 2(X2,Y2) coordinates or upper left P 0(X0,Y0) and upper right P 1(X1,Y1) coordinates;
taking the lower left P 3(X3,Y3) and the lower right P 2(X2,Y2) coordinates as an example, the calculation formula of the inclination angle θ is:
θ=90° -arctan (d y/dx), where d y=-(y2-y3),dX=X2-X3.
When correction is carried out, the original image is reversely rotated by an angle theta to achieve the aim of adjusting the angle of the evidence to be horizontal;
the orientation of the certificate is judged and corrected, and the upper right of the certificate is taken as an example of the image:
When the height of the certificate is larger than the width, judging that the certificate rotates by 90 degrees or 270 degrees, and in both the above two cases, rotating by 90 degrees to enable the certificate to be in a state of larger than the width, and then performing the next calculation;
calculating the center coordinates of the certificate MASK, which is recorded as PCARDCENTER = (X C,YC); the method for calculating the center coordinates of the certificate MASK comprises the following steps: the certificate MASK is a binary image, wherein the foreground area value is 1, the background area value is 0, the index value with the value of 1 is calculated to obtain the coordinate of each point of the foreground area, the average value of the coordinates is calculated, and the center point coordinate of the certificate MASK is obtained by rounding down;
similarly, the human image MASK center point coordinates are calculated by the calculation method, and the human image MASK center point coordinates are calculated and are denoted by PPhotoCenter = (X p,Yp).
Judging by taking the center coordinates of the certificate as the origin to obtain the placement state of the certificate: normal placement, rotation 180 °, horizontal flip and vertical flip;
The method for judging the center coordinate of the certificate is as the origin, which comprises the following steps:
(1) If the portrait center point is in the first quadrant, that is, X P >0 and Y P >0, then normal placement is established;
(2) If the portrait center point is in the second quadrant, i.e., X P <0 and Y P >0, then it is flipped horizontally;
(3) If the portrait center point is in the third quadrant, i.e., X P <0 and Y P <0, then it is rotated 180 °;
(4) If the portrait center point is in the fourth quadrant, X P >0 and Y P <0, then it is flipped vertically.
And correcting the situation that the certificate is in the abnormal placement state after judgment by using a method corresponding to the placement state, for example, the certificate is horizontally overturned, and the normal placement state is obtained after horizontal overturning again.
Embodiment two:
Referring to fig. 2, the document quality inspection method includes the steps of:
Calculating the contour of the certificate MASK corrected by the certificate orientation correction method to obtain the contour area area_cnt of the certificate MASK calculated, and then calculating to obtain the boundary frame area area_rect of the contour, wherein ratio is set as the ratio of the contour area to the boundary frame area:
ratio=area_cnt/area_rect。
Preferably, a threshold t is set, if the ratio of the contour area to the bounding box area is greater than or equal to t, the certificate is judged to be complete, and if the ratio of the contour area to the bounding box area is less than t, the certificate is judged to be incomplete.
It is noted 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;
the invention has very simple realization, for example, the inclination angle of the certificate is judged and the inclination angle of the MASK is calculated by correction, and the inclination angle can be directly obtained from the inclined rectangle containing the minimum area of the MASK outline;
the present invention may be deployed using any programming language, and the following is exemplified by python:
The operation steps are as follows depending on the OpenCV image processing library:
The first step: reading in the credentials MASK and the portrait MASK (or having been acquired by other means, then converting to a grey map) in grey map mode;
and a second step of: judging the inclination angle of the certificate and correcting;
and a third step of: judging the orientation of the certificate and correcting;
Fourth step: and (3) detecting the integrity of the certificate, and presetting an area ratio threshold t of the outline and the boundary box, for example, setting t to be 0.95, and comparing the calculated ratio with t to obtain whether the certificate is complete or not.
The foregoing is only a preferred embodiment of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art, who is within the scope of the present invention, should make equivalent substitutions or modifications according to the technical scheme of the present invention and the inventive concept thereof, and should be covered by the scope of the present invention.
Claims (6)
1. The certificate orientation correction method is characterized by comprising a correction method, wherein the correction method comprises the steps of judging the inclination angle of a certificate and correcting, judging the orientation of the certificate and correcting;
Judging the inclination angle of the certificate and correcting:
S1, calculating a MASK outline of the certificate, and then calculating to obtain an inclined rectangle which tightly contains the minimum area of the MASK outline of the certificate;
S2, setting four point coordinates of the rectangle as upper left P 0(X0,Y0), upper right P 1(X1,Y1), lower right P 2(X2,Y2) and lower left P 3(X3,Y3), and calculating the inclination angle theta of the rectangle according to the lower left P 3(X3,Y3) and lower right P 2(X2,Y2) coordinates or the upper left P 0(X0,Y0) and upper right P 1(X1,Y1) coordinates;
S3, when correction is carried out, the original image is reversely rotated by an angle theta to achieve the aim of adjusting the angle of the evidence to be horizontal;
the orientation of the certificate is judged and corrected, and the upper right of the certificate is taken as an example of the image:
S4, when the height of the certificate is larger than the width, judging that the certificate rotates by 90 degrees or 270 degrees, and in both the above two cases, rotating by 90 degrees to enable the certificate to be in a state of being larger than the width, and then performing the next calculation;
S5, calculating the center coordinates of the certificate MASK, and marking the center coordinates as PCARDCENTER = (X C,YC); calculating the coordinates of the center point of the portrait MASK, and marking as PPhotoCenter = (X p,Yp);
S6, judging by taking the center coordinates of the certificate as an origin to obtain the placement state of the certificate: normal placement, rotation 180 °, horizontal flip and vertical flip;
and S7, correcting the situation that the certificate is in the abnormal placement state after judgment by using a method corresponding to the placement state.
2. The method for correcting the orientation of a document according to claim 1, wherein in S2, taking the coordinates of the lower left P 3(X3,Y3) and the lower right P 2(X2,Y2) as an example, the calculation formula of the inclination angle θ is:
θ=90° -arctan (d y/dx), where d y=-(y2-y3),dX=X2-X3.
3. The method for correcting the orientation of a document according to claim 1, wherein the method for calculating the center coordinates of the MASK of the document in S6 is as follows: the certificate MASK is a binary image, wherein the foreground area value is 1, the background area value is 0, the index value with the value of 1 is calculated to obtain the coordinate of each point of the foreground area, the average value of the coordinates is calculated, and the center point coordinate of the certificate MASK is obtained by rounding down;
Similarly, the coordinates of the center point of the portrait MASK are calculated by the calculation mode.
4. The method of claim 1, wherein the document orientation correction is performed,
The method for judging by taking the center coordinate of the certificate as the origin in the S6 comprises the following steps:
(1) If the portrait center point is in the first quadrant, that is, X P >0 and Y P >0, then normal placement is established;
(2) If the portrait center point is in the second quadrant, i.e., X P <0 and Y P >0, then it is flipped horizontally;
(3) If the portrait center point is in the third quadrant, i.e., X P <0 and Y P <0, then it is rotated 180 °;
(4) If the portrait center point is in the fourth quadrant, X P >0 and Y P <0, then it is flipped vertically.
5. The certificate quality detection method is characterized by comprising the following steps of:
Calculating the contour of the certificate MASK corrected by the certificate orientation correction method to obtain the contour area area_cnt of the certificate MASK calculated, and then calculating to obtain the boundary frame area area_rect of the contour, wherein ratio is set as the ratio of the contour area to the boundary frame area:
ratio=area_cnt/area_rect。
6. The method of claim 4, wherein a threshold t is set, the document is determined to be complete if the ratio of the contour area to the bounding box area is greater than or equal to t, and the document is determined to be incomplete if the ratio of the contour area to the bounding box area is less than t.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211490456.1A CN118097099A (en) | 2022-11-25 | 2022-11-25 | Certificate quality detection and orientation correction method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211490456.1A CN118097099A (en) | 2022-11-25 | 2022-11-25 | Certificate quality detection and orientation correction method |
Publications (1)
Publication Number | Publication Date |
---|---|
CN118097099A true CN118097099A (en) | 2024-05-28 |
Family
ID=91163739
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211490456.1A Pending CN118097099A (en) | 2022-11-25 | 2022-11-25 | Certificate quality detection and orientation correction method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN118097099A (en) |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2010011359A (en) * | 2008-06-30 | 2010-01-14 | Sharp Corp | Image processing apparatus, image forming apparatus, method of controlling the image processing apparatus, control program, and recording medium |
CN102668541A (en) * | 2009-12-22 | 2012-09-12 | 苹果公司 | Image capture device having tilt or perspective correction |
US20130202220A1 (en) * | 2012-02-08 | 2013-08-08 | JVC Kenwood Corporation | Image process device, image process method, and image process program |
CN105046252A (en) * | 2014-11-21 | 2015-11-11 | 华中科技大学 | Method for recognizing Renminbi (Chinese currency yuan) crown codes |
CN113538291A (en) * | 2021-08-02 | 2021-10-22 | 广州广电运通金融电子股份有限公司 | Card image tilt correction method and device, computer equipment and storage medium |
CN113962906A (en) * | 2021-12-03 | 2022-01-21 | 四川新网银行股份有限公司 | Identity card image correction method and system for multi-task detection |
-
2022
- 2022-11-25 CN CN202211490456.1A patent/CN118097099A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2010011359A (en) * | 2008-06-30 | 2010-01-14 | Sharp Corp | Image processing apparatus, image forming apparatus, method of controlling the image processing apparatus, control program, and recording medium |
CN102668541A (en) * | 2009-12-22 | 2012-09-12 | 苹果公司 | Image capture device having tilt or perspective correction |
US20130202220A1 (en) * | 2012-02-08 | 2013-08-08 | JVC Kenwood Corporation | Image process device, image process method, and image process program |
CN105046252A (en) * | 2014-11-21 | 2015-11-11 | 华中科技大学 | Method for recognizing Renminbi (Chinese currency yuan) crown codes |
CN113538291A (en) * | 2021-08-02 | 2021-10-22 | 广州广电运通金融电子股份有限公司 | Card image tilt correction method and device, computer equipment and storage medium |
CN113962906A (en) * | 2021-12-03 | 2022-01-21 | 四川新网银行股份有限公司 | Identity card image correction method and system for multi-task detection |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109409374B (en) | Joint-based same-batch test paper answer area cutting method | |
WO2018219054A1 (en) | Method, device, and system for license plate recognition | |
WO2023273219A1 (en) | Glass curtain wall open window open state detection method and apparatus, device, and medium | |
CN109918523B (en) | Circuit board component detection method based on YOLO9000 algorithm | |
CN102789658A (en) | Ultraviolet anti-counterfeiting check authenticity verification method | |
US20120008874A1 (en) | Image processing apparatus, image processing method, image processing program, and storage medium | |
CN114143519A (en) | Method and device for automatically matching projection image with curtain area and projector | |
CN112528776B (en) | Text line correction method and device | |
CN104732225A (en) | Image rotation processing method | |
US20230095142A1 (en) | Method and apparatus for improving object image | |
CN107392203A (en) | Regular picture information identifying method and system | |
CN112419207A (en) | Image correction method, device and system | |
CN118097099A (en) | Certificate quality detection and orientation correction method | |
CN109840453B (en) | Face matching method and device | |
CN110610163B (en) | Table extraction method and system based on ellipse fitting in natural scene | |
WO2022021687A1 (en) | Method for positioning quick response code area, and electronic device and storage medium | |
CN112634141A (en) | License plate correction method, device, equipment and medium | |
TWM601383U (en) | Seal recognition system | |
CN111127327A (en) | Picture inclination detection method and device | |
CN114359923A (en) | Certificate character recognition method and device, computer and storage medium | |
CN112383670B (en) | Test paper scanning automatic centering method and device | |
CN104408452A (en) | Latin character skew correction method and system based on rotating projection width | |
CN115456906A (en) | Damaged image-based facial image restoration method, device, equipment and medium | |
TWI854370B (en) | Profile information generation method, document checking method and system | |
CN114863456A (en) | Question identification method, device, equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |