Nothing Special   »   [go: up one dir, main page]

CN111768345A - Method, device and equipment for correcting back image of identity card and storage medium - Google Patents

Method, device and equipment for correcting back image of identity card and storage medium Download PDF

Info

Publication number
CN111768345A
CN111768345A CN202010398820.6A CN202010398820A CN111768345A CN 111768345 A CN111768345 A CN 111768345A CN 202010398820 A CN202010398820 A CN 202010398820A CN 111768345 A CN111768345 A CN 111768345A
Authority
CN
China
Prior art keywords
image
rotation angle
identity card
acquiring
corrected
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.)
Granted
Application number
CN202010398820.6A
Other languages
Chinese (zh)
Other versions
CN111768345B (en
Inventor
王晨旭
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN202010398820.6A priority Critical patent/CN111768345B/en
Publication of CN111768345A publication Critical patent/CN111768345A/en
Application granted granted Critical
Publication of CN111768345B publication Critical patent/CN111768345B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/80Geometric correction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/40Analysis of texture
    • G06T7/41Analysis of texture based on statistical description of texture
    • G06T7/44Analysis of texture based on statistical description of texture using image operators, e.g. filters, edge density metrics or local histograms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/60Analysis of geometric attributes
    • G06T7/62Analysis of geometric attributes of area, perimeter, diameter or volume
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10004Still image; Photographic image
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Probability & Statistics with Applications (AREA)
  • Geometry (AREA)
  • Character Input (AREA)

Abstract

The application relates to a method, a device, equipment and a storage medium for correcting an image on the back of an identity card, wherein the method comprises the following steps: detecting and obtaining all text lines in the image on the back side of the identity card, and obtaining respective external rectangles of each text line; according to the respective rotation angle of each circumscribed rectangle, acquiring the respective clockwise rotation angle and anticlockwise rotation angle of each circumscribed rectangle, and acquiring the median of all clockwise rotation angles as a first rotation angle and the median of all anticlockwise rotation angles as a second rotation angle; and correcting the image on the back side of the identity card according to the first rotation angle, the second rotation angle and the relative position relationship between the corrected external rectangles. This application is used for before reading identity card information, rectifies the identity card back to improve the speed and the degree of accuracy that identity card information read.

Description

Method, device and equipment for correcting back image of identity card and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a storage medium for correcting an image on a back side of an identity card.
Background
In modern society, real-name authentication is often required for users, and the authenticity of identity card information is checked to facilitate establishment of reliable credit basis among various industries. Nowadays, real-name authentication not only becomes a necessary means for network management, but also is widely applied to industries such as finance, banking, telecommunication, education and the like. The real-name authentication needs to use identification card identification, namely, intelligent identification is carried out on identification card information, manual input is omitted, and therefore the purpose of quickly reading information is achieved.
Therefore, how to quickly and accurately read the information of the identity card is a problem to be solved.
Disclosure of Invention
The application provides a method, a device, equipment and a storage medium for correcting an image on the back of an identity card, which are used for correcting the back of the identity card before reading identity card information so as to improve the speed and accuracy of reading identity card information.
In a first aspect, the present application provides a method for correcting an image on the back side of an identity card, including:
acquiring a back image of the identity card;
detecting and obtaining all text lines in the image on the back side of the identity card, and obtaining respective circumscribed rectangles of each text line;
according to the respective rotation angle of each circumscribed rectangle, acquiring the respective clockwise rotation angle and anticlockwise rotation angle of each circumscribed rectangle, acquiring the median of all the clockwise rotation angles as a first rotation angle, and acquiring the median of all the anticlockwise rotation angles as a second rotation angle;
and correcting the back image of the identity card according to the first rotation angle, the second rotation angle and the relative position relationship between the corrected external rectangles.
Optionally, the correcting the image on the back side of the identity card according to the first rotation angle, the second rotation angle, and the relative position relationship between the corrected circumscribed rectangles includes:
according to the first rotation angle, clockwise rotating the image on the back of the identity card to obtain a first correction image;
according to the second rotation angle, anticlockwise rotating the image on the back side of the identity card to obtain a second correction image;
acquiring coordinates of a left vertex of each circumscribed rectangle in the first corrected image, and acquiring coordinates of a left vertex of each circumscribed rectangle in the second corrected image;
according to the coordinates of the left vertex of each circumscribed rectangle in the first corrected image and the coordinates of the left vertex of each circumscribed rectangle in the second corrected image, selecting an image satisfying a preset distribution characteristic from the first corrected image and the second corrected image as the corrected ID card back image, wherein the preset distribution characteristic is as follows: and the X-axis coordinate of the left vertex of each circumscribed rectangle is concentrated in the same preset interval, the long edge of the identity card image is parallel to the X-axis after correction, and the X-axis is the abscissa axis of a predefined reference coordinate system.
Optionally, selecting, as the corrected id card backside image, an image satisfying a preset distribution characteristic from the first corrected image and the second corrected image according to the coordinates of the left vertex of each circumscribed rectangle in the first corrected image and the coordinates of the left vertex of each circumscribed rectangle in the second corrected image, including:
dividing the long edge of the first correction image into a plurality of length intervals at equal intervals by taking a preset length as an interval, classifying the X-axis coordinate of the left vertex of each circumscribed rectangle in the first correction image into the corresponding length interval, counting the number of the left vertices classified into each interval, and acquiring the maximum value of the counted number as a first maximum value;
dividing the long edge of the second correction image into a plurality of length intervals at equal intervals by taking the preset length as an interval, classifying the X-axis coordinate of the left vertex of each circumscribed rectangle in the second correction image into the corresponding length interval, counting the number of the left vertices classified into each interval, and acquiring the maximum value of the counted number as a second maximum value;
calculating the variance of the X-axis coordinate of the left vertex of each circumscribed rectangle in the first corrected image to obtain a first variance;
calculating the variance of the X-axis coordinates of the left vertex of each circumscribed rectangle in the second correction image to obtain a second variance;
if a first condition is met, taking the first corrected image as the corrected back image of the identity card, wherein the first condition is as follows: the first maximum is greater than 2 and the first variance is less than 1/3 of the second variance; or if a second condition is met, taking the second corrected image as the identity card back image after correction, wherein the second condition is as follows: the second maximum is greater than 2 and the second variance is less than 1/3 of the first variance.
Optionally, the correcting the image on the back side of the identity card according to the first rotation angle, the second rotation angle, and the relative position relationship between the corrected circumscribed rectangles includes:
according to the first rotation angle, clockwise rotating the image on the back of the identity card to obtain a third corrected image;
according to the second rotation angle, anticlockwise rotating the image on the back side of the identity card to obtain a fourth corrected image;
acquiring the minimum circumscribed rectangles of all the circumscribed rectangles in the third corrected image as a first image area, and acquiring the minimum circumscribed rectangles of all the circumscribed rectangles in the fourth corrected image as a second image area;
acquiring the central position of the first image area and the central position of each circumscribed rectangle in the first image area, and counting the number of the circumscribed rectangles with the central positions positioned on the left side of the central position of the first image area as a first number;
acquiring the central position of the second image area and the central position of each circumscribed rectangle in the second image area, and counting the number of the circumscribed rectangles with the central positions positioned on the left side of the central position of the second image area as a second number;
and if the first number is greater than the second number, taking the third corrected image as the corrected back image of the identity card, and if the first number is less than the second number, taking the fourth corrected image as the corrected back image of the identity card.
Optionally, after obtaining the respective circumscribed rectangle of each text line, before obtaining the respective clockwise rotation angle and the respective counterclockwise rotation angle of each circumscribed rectangle according to the respective rotation angle of each circumscribed rectangle, the method further includes:
acquiring a rotation angle of each circumscribed rectangle relative to a reference direction, and acquiring a height of each circumscribed rectangle, wherein the reference direction is an X-axis direction of a predefined reference coordinate system;
dividing angle intervals by taking a preset angle value as an interval, classifying each external rectangle into the corresponding angle interval according to a rotation angle, counting the number of the external rectangles classified into each angle interval, and acquiring the external rectangles with the largest number in the angle intervals to serve as alternative external rectangles;
dividing height intervals by taking a preset height value as an interval, classifying each alternative external rectangle into the corresponding height interval according to the height value, counting the number of the alternative external rectangles classified into each height interval, acquiring the alternative external rectangles with the largest number in the height intervals, and taking the alternative external rectangles as the effective external rectangles obtained after filtering.
Optionally, if it is determined that the first condition is not satisfied and after the second condition is not satisfied, the method further includes:
acquiring the minimum circumscribed rectangle of all the circumscribed rectangles in the first corrected image as a third image area, and acquiring the minimum circumscribed rectangle of all the circumscribed rectangles in the second corrected image as a fourth image area;
acquiring the central position of the third image area and the central position of each circumscribed rectangle in the third image area, and counting the number of the circumscribed rectangles with the central positions positioned on the left side of the central position of the third image area as a third number;
acquiring the central position of the fourth image area and the central position of each circumscribed rectangle in the fourth image area, and counting the number of the circumscribed rectangles with the central positions positioned on the left side of the central position of the fourth image area as a fourth number;
and if the third number is greater than the fourth number, taking the first corrected image as the corrected ID card back image, and if the third number is less than the fourth number, taking the second corrected image as the corrected ID card back image.
Optionally, the clockwise rotation angle is equal to the rotation angle, and the counterclockwise rotation angle is equal to an angle value obtained by subtracting the rotation angle from 180 degrees.
In a second aspect, the present application provides a device for correcting an image on the back side of an identification card, including:
the acquisition module is used for acquiring the back image of the identity card;
the detection module is used for detecting and obtaining all text lines in the back image of the identity card and obtaining respective external rectangles of each text line;
the selection module is used for acquiring the respective clockwise rotation angle and the respective anticlockwise rotation angle of each circumscribed rectangle according to the respective rotation angle of each circumscribed rectangle, acquiring the median of all the clockwise rotation angles as a first rotation angle, and acquiring the median of all the anticlockwise rotation angles as a second rotation angle;
and the correction module is used for correcting the image on the back side of the identity card according to the first rotation angle, the second rotation angle and the relative position relationship between the external rectangles after correction.
In a third aspect, the present application provides an electronic device, comprising: the system comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus; the memory for storing a computer program; the processor is configured to execute the program stored in the memory to implement the apparatus for correcting the image on the back side of the identification card according to the first aspect.
In a fourth aspect, the present application provides a computer-readable storage medium storing a computer program, which when executed by a processor implements the apparatus for correcting an image on the back side of an identification card according to the first aspect.
Compared with the prior art, the technical scheme provided by the embodiment of the application has the following advantages: according to the method provided by the embodiment of the application, all text lines in the back image of the identity card are obtained through detection, the respective external rectangles of each text line are obtained, the median of the clockwise rotation angle of each external rectangle and the median of the clockwise rotation angle of each external rectangle are utilized, the back image of the identity card can be corrected according to the two rotation angles and the relative position relationship between the corrected external rectangles, and therefore guarantee can be provided for improving the reading speed and accuracy of the subsequent back information of the identity card.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
FIG. 1 is a schematic flowchart of a method for correcting an image on the back side of an identification card according to an embodiment of the present disclosure;
FIG. 2 is a schematic diagram of a first calibration process in an embodiment of the present application;
FIG. 3 is a schematic diagram illustrating a process of selecting a corrected ID card backside image according to an embodiment of the present application;
FIG. 4 is a schematic diagram illustrating a process of determining a corrected image according to an embodiment of the present application;
FIG. 5 is a diagram illustrating a second exemplary calibration process according to an embodiment of the present application;
FIG. 6 is a diagram illustrating a detailed process of correcting an image on the back side of an ID card according to an embodiment of the present application;
FIG. 7 is a schematic structural diagram of a device for correcting an image on the back side of an identification card according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of an electronic device in an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application.
The embodiment of the application provides a method for correcting an image on the back of an identity card, which can be applied to any form of electronic equipment, including a terminal and a server.
It should be noted that the back side of the identification card referred in the embodiments of the present application refers to a side including specific certificate information, such as a side where important information such as a name and an identification card number is located.
As shown in fig. 1, the specific process of the identity card back image correction is as follows:
step 101, obtaining a back image of an identity card.
Specifically, the identity card back image may be obtained by directly shooting the identity card back by the electronic device, or may be obtained from other devices. For example, the server acquires the back image of the identity card transmitted after the terminal equipment shoots.
And 102, detecting and obtaining all text lines in the back image of the identity card, and obtaining respective circumscribed rectangles of each text line.
Wherein, a line of text in the image on the back side of the identity card is called a text line. The back of the ID card of the residents of the people's republic of China has 5 text lines which are respectively a first text line of the name, a second text line of the gender and the ethnicity, a third text line of the year, month and day of birth, a fourth text line of the address and a fifth text line of the ID number of the citizen.
And if the text line is not detected after the text line detection is finished, the image is not considered to be the identity card image.
The bounding rectangle for a line of text is the smallest bounding rectangle for the line of text.
In one embodiment, in order to filter invalid external rectangles in all external rectangles and improve the correction efficiency and accuracy, effective external rectangles after the invalid external rectangles are filtered are identified from all external rectangles, wherein the effective external rectangles are external rectangles with rotation angles distributed in the same angle interval in a concentrated mode, and height values distributed in the same height interval in a concentrated mode. And in the subsequent correction process, the correction is carried out based on the effective external rectangle obtained after filtering.
In one embodiment, the specific process of identifying the valid circumscribed rectangle is obtained by two processes, angle filtering and height filtering.
The angle filtering process specifically comprises the following steps: the method comprises the steps of obtaining the rotation angle of each external rectangle relative to a reference direction, dividing angle intervals by taking a preset angle value as an interval, classifying each external rectangle into a corresponding angle interval according to the rotation angle, counting the number of the external rectangles classified into each angle interval, obtaining the external rectangles with the largest number in the angle intervals, and taking the external rectangles as alternative external rectangles.
The process of high filtration specifically comprises: the method comprises the steps of obtaining the respective height of each external rectangle, dividing height intervals by taking a preset height value as an interval, putting each alternative external rectangle into the corresponding height interval according to the height value, counting the number of the alternative external rectangles put into each height interval, obtaining the alternative external rectangles in the height interval with the largest number, and taking the alternative external rectangles as the effective external rectangles obtained after filtering, namely the effective external rectangles for short.
The reference direction refers to the X-axis direction of a predefined reference coordinate system, and the reference coordinate system is a planar rectangular coordinate system.
For example, the rotation angle of each circumscribed rectangle is stored in an angle list (denoted as Alist), an angle histogram of the angle list is counted at intervals of a preset angle value (e.g., at intervals of 15 degrees), an interval including the largest number of rotation angles in the angle histogram is selected, the circumscribed rectangle corresponding to each rotation angle in the interval is used as a candidate circumscribed rectangle (a set of candidate circumscribed rectangles is denoted as R1all), that is, the circumscribed rectangle corresponding to a rotation angle not belonging to the interval is used as an invalid circumscribed rectangle, and the invalid circumscribed rectangle is filtered out.
For another example, the length of the short side of each candidate circumscribed rectangle is calculated, the height histograms of all candidate circumscribed rectangles in R1all are counted at preset pixel intervals (for example, 50 pixels), the interval with the largest number of distributed heights in the height histogram is selected, and the circumscribed rectangle corresponding to the height in the interval is taken as the effective circumscribed rectangle R2 all. For the convenience of calculation, the lengths of the short sides of the alternative circumscribed rectangles are calculated instead of the heights, namely the short sides are directly defaulted to be the heights, so that the complexity of calculation is reduced, and the accuracy of a final result is not influenced.
In a specific embodiment, for any one circumscribed rectangle, the rotation angle of the circumscribed rectangle is obtained, and the specific process is as follows: and calculating the minimum angle required for rotating the X axis of the reference coordinate system to the long side of the circumscribed rectangle anticlockwise, and determining the rotation angle of the circumscribed rectangle relative to the reference direction according to the minimum angle.
Specifically, judging whether the minimum angle is smaller than a preset angle value; if so, calculating a difference value obtained by subtracting the minimum angle from 180 degrees, and taking the obtained difference value as the rotation angle of the circumscribed rectangle; if not, the minimum angle is taken as the rotation angle of the circumscribed rectangle. Here, considering a text line approximately horizontal to the X axis, the minimum angle of the corresponding circumscribed rectangle is close to zero degrees or close to 180 degrees, and thus, for a case where Amin is smaller than a preset angle value (for example, smaller than 5 degrees), the rotation angle is uniformly recorded as 180-Amin.
Step 103, acquiring the respective clockwise rotation angle and counterclockwise rotation angle of each circumscribed rectangle according to the respective rotation angle of each circumscribed rectangle, and acquiring the median of all clockwise rotation angles as a first rotation angle and the median of all counterclockwise rotation angles as a second rotation angle.
For a circumscribed rectangle, the clockwise rotation angle of the circumscribed rectangle is equal to the rotation angle of the circumscribed rectangle, and the counterclockwise rotation angle of the circumscribed rectangle is equal to: and subtracting the angle value obtained by the rotation angle of the circumscribed rectangle from 180 degrees.
And step 104, correcting the back image of the identity card according to the first rotation angle, the second rotation angle and the relative position relationship between the corrected external rectangles.
Specific examples of correcting the identification card image include, but are not limited to, the following two types:
first, as shown in fig. 2, a calibration process is described by taking a case of filtering an invalid circumscribed rectangle as an example, and for a case of not filtering, only the valid circumscribed rectangle in the process needs to be replaced by a circumscribed rectangle, and a specific process of performing calibration is as follows:
step 201, clockwise rotating the image on the back side of the identity card according to a first rotation angle to obtain a first corrected image;
step 202, according to the second rotation angle, carrying out anticlockwise rotation on the back image of the identity card to obtain a second correction image;
step 203, acquiring the coordinates of the left vertex of each effective circumscribed rectangle in the first correction image, and acquiring the coordinates of the left vertex of each effective circumscribed rectangle in the second correction image;
and 204, selecting an image meeting preset distribution characteristics from the first correction image and the second correction image as a corrected ID card back image according to the coordinates of the left vertex of each effective circumscribed rectangle in the first correction image and the coordinates of the left vertex of each effective circumscribed rectangle in the second correction image.
Wherein the preset distribution characteristics are as follows: and the X-axis coordinate of the left vertex of each external rectangle is concentrated in the same preset interval, the long edge of the corrected ID card image is parallel to the X axis, and the X axis is the abscissa axis of a predefined reference coordinate system.
For example, a coordinate distribution histogram of all the left vertices of the effective circumscribed rectangle in the first corrected image is counted at intervals of a preset number of pixels (for example, at intervals of 50 pixel length), a peak value in the histogram is selected, and if the peak value is greater than 2, the first corrected image is used as the corrected back image of the identification card. Similarly, the coordinate distribution histogram of the left vertices of all the effective circumscribed rectangles in the second corrected image is counted at intervals of a preset number of pixels (for example, at intervals of 50 pixel length), a peak value in the histogram is selected, and if the peak value is greater than 2, the second corrected image is used as the corrected back image of the identification card. The method utilizes that the text lines on the back of the identity card after correction are left-aligned, and the coordinates of the left vertex are centrally distributed in the left part of the image. All the effective circumscribed rectangles can be replaced by all the circumscribed rectangles without filtering.
As shown in fig. 3, the specific process of selecting the corrected image on the back side of the identification card in step 204 is as follows:
step 301, equally dividing a long side of a first correction image into a plurality of length sections at intervals of a preset length, classifying an X-axis coordinate of a left vertex of each effective circumscribed rectangle in the first correction image into the corresponding length section, counting the number of the left vertices classified into each section, and acquiring a maximum value of the counted number as a first maximum value;
step 302, equally dividing the long edge of the second correction image into a plurality of length intervals by taking a preset length as an interval, classifying the X-axis coordinate of the left vertex of each effective circumscribed rectangle in the second correction image into the corresponding length interval, counting the number of the left vertices classified into each interval, and acquiring the maximum value of the counted number as a second maximum value;
step 303, calculating the variance of the X-axis coordinates of the left vertex of each effective circumscribed rectangle in the first corrected image to obtain a first variance;
step 304, calculating the variance of the X-axis coordinates of the left vertex of each effective circumscribed rectangle in the second corrected image to obtain a second variance;
step 305, if a first condition is satisfied, taking the first corrected image as a corrected identity card back image, where the first condition is: 1/3 where the first maximum is greater than 2 and the first variance is less than the second variance; or if a second condition is met, taking the second corrected image as the corrected identity card back image, wherein the second condition is as follows: the second maximum is greater than 2 and the second variance is less than 1/3 of the first variance.
After determining that the first condition is not satisfied and the second condition is not satisfied, determining a corrected image in the following manner, as shown in fig. 4, specifically as follows:
step 401, acquiring the minimum circumscribed rectangles of all effective circumscribed rectangles in the first corrected image as a third image area, and acquiring the minimum circumscribed rectangles of all effective circumscribed rectangles in the second corrected image as a fourth image area;
step 402, acquiring the central position of the third image area and the central positions of the effective circumscribed rectangles in the third image area, and counting the number of the effective circumscribed rectangles, which are positioned on the left side of the central position of the third image area, as a third number;
step 403, acquiring the center position of the fourth image area and the center positions of the effective circumscribed rectangles in the fourth image area, and counting the number of the effective circumscribed rectangles, of which the center positions are located on the left side of the center position of the fourth image area, as a fourth number;
in step 404, if the third number is greater than the fourth number, the first corrected image is used as the corrected identification card back image, and if the third number is less than the fourth number, the second corrected image is used as the corrected identification card back image.
Secondly, as shown in fig. 5, the correction process is also described by taking the case of filtering the invalid circumscribed rectangle as an example, for the case of not filtering, only the valid circumscribed rectangle in the process needs to be replaced by the circumscribed rectangle, and the specific process of correcting the identity card image is as follows:
step 501, clockwise rotating the image on the back side of the identity card according to the first rotation angle to obtain a third corrected image;
step 502, according to the second rotation angle, performing counterclockwise rotation on the image on the back side of the identity card to obtain a fourth corrected image;
step 503, acquiring the minimum circumscribed rectangles of all the effective circumscribed rectangles in the third corrected image as the first image area, and acquiring the minimum circumscribed rectangles of all the effective circumscribed rectangles in the fourth corrected image as the second image area;
step 504, acquiring the central position of the first image area and the central positions of the effective circumscribed rectangles in the first image area, and counting the number of the effective circumscribed rectangles, which are positioned at the left side of the central position of the first image area, as a first number;
step 505, obtaining the central position of the second image area and the central positions of the effective circumscribed rectangles in the second image area, and counting the number of the central positions of the effective circumscribed rectangles positioned on the left side of the central position of the second image area as a second number;
step 506, if the first number is greater than the second number, the third corrected image is used as the corrected identity card back image, and if the first number is less than the second number, the fourth corrected image is used as the corrected identity card back image.
In a specific embodiment, as shown in fig. 6, the correction process is described by taking the case of filtering an invalid circumscribed rectangle as an example, and for the case of no filtering, only the steps of replacing the valid circumscribed rectangle in the process with the circumscribed rectangle and removing the identified valid circumscribed rectangle are required, and the detailed process of correcting the image on the back of the identification card is as follows:
601, acquiring a back image of the identity card, and performing text line detection on the back image of the identity card;
step 602, obtaining respective circumscribed rectangles of each detected text line, for example, the minimum circumscribed rectangle of the text line region;
step 603, acquiring the rotation angle and the height of each external rectangle, respectively performing histogram statistics on the rotation angle and the height, and filtering the external rectangles with non-main directions and large height deviations according to the histogram statistical result to obtain effective external rectangles;
step 604, obtaining the respective clockwise rotation angle and counterclockwise rotation angle of each effective circumscribed rectangle, obtaining the median of all clockwise rotation angles as a first rotation angle, and obtaining the median of all counterclockwise rotation angles as a second rotation angle;
605, clockwise rotating the back image of the identity card by a first rotation angle to obtain a first corrected image, counterclockwise rotating the back image of the identity card by a second rotation angle to obtain a second corrected image, and respectively obtaining the distribution of the top points on the left side of the effective circumscribed rectangle in the first corrected image and the second corrected image;
step 606, judging whether one of the corrected images has at most 2 left side vertexes concentrated in the same length interval, and the variance of the X coordinate is smaller than that of the other corrected image, if so, executing step 607, otherwise, executing step 608;
step 607, outputting the corrected image satisfying the condition as a final corrected image;
step 608, calculating the minimum bounding rectangles of all the effective bounding rectangles in the first corrected image as the first image area, and calculating the minimum bounding rectangles of all the effective bounding rectangles in the second corrected image as the second image area;
step 609, acquiring the central position of the first image area and the central positions of all effective circumscribed rectangles in the first image area, counting the number of the central positions of the effective circumscribed rectangles positioned on the left side of the central position of the first image area as a first number, acquiring the central position of the second image area and the central positions of all the effective circumscribed rectangles in the second image area, and counting the number of the central positions of the effective circumscribed rectangles positioned on the left side of the central position of the second image area as a second number;
step 610, outputting the corrected image corresponding to the larger value of the first number and the second number as the final corrected image.
According to the method provided by the embodiment of the application, all the text lines in the image on the back side of the identity card are obtained through detection, the respective external rectangles of each text line are obtained, angles are selected from all the external rectangles to be distributed in the same angle interval in a concentrated mode, and the external rectangles distributed in the same height interval in a concentrated mode are used as effective external rectangles, so that invalid external rectangles in all the external rectangles can be filtered, and the correction efficiency and accuracy are improved. And the identity card back image can be corrected by utilizing the median of the clockwise rotation angle of each effective external rectangle and the median of the clockwise rotation angle of each effective external rectangle according to the two rotation angles and the relative position relationship between the corrected effective external rectangles, so that the reading speed and accuracy of the subsequent identity card back information can be improved.
Based on the same concept, the embodiment of the present application provides a device for correcting an image on the back of an identity card, and specific implementation of the device may refer to the description of the method embodiment, and repeated details are not repeated. As shown in fig. 7, the apparatus mainly includes:
an obtaining module 701, configured to obtain a back image of an identity card;
a detection module 702, configured to detect and obtain all text lines in the image on the back side of the identity card, and obtain a respective circumscribed rectangle of each text line;
the selecting module 703 is configured to obtain a clockwise rotation angle and a counterclockwise rotation angle of each circumscribed rectangle according to the respective rotation angle of each circumscribed rectangle, obtain a median of all the clockwise rotation angles as a first rotation angle, and obtain a median of all the counterclockwise rotation angles as a second rotation angle;
and the correcting module 704 is configured to correct the image on the back side of the identity card according to the first rotation angle, the second rotation angle, and the corrected relative position relationship between the external rectangles.
Based on the same concept, an embodiment of the present application further provides an electronic device, as shown in fig. 8, the electronic device mainly includes: a processor 801, a communication interface 802, a memory 803 and a communication bus 804, wherein the processor 801, the communication interface 802 and the memory 803 communicate with each other via the communication bus 804. Wherein, the memory 803 stores the program which can be executed by the processor 801, the processor 801 executes the program stored in the memory 803, and the following steps are realized: acquiring a back image of the identity card; detecting and obtaining all text lines in the image on the back side of the identity card, and obtaining respective circumscribed rectangles of each text line; according to the respective rotation angle of each circumscribed rectangle, acquiring the respective clockwise rotation angle and anticlockwise rotation angle of each circumscribed rectangle, acquiring the median of all the clockwise rotation angles as a first rotation angle, and acquiring the median of all the anticlockwise rotation angles as a second rotation angle; and correcting the back image of the identity card according to the first rotation angle, the second rotation angle and the relative position relationship between the corrected external rectangles.
The communication bus 804 mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus 804 may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in FIG. 8, but this is not intended to represent only one bus or type of bus.
The communication interface 802 is used for communication between the above-described electronic apparatus and other apparatuses.
The Memory 803 may include a Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Alternatively, the memory may be at least one memory device located remotely from the processor 801.
The Processor 801 may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc., and may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic devices, discrete gates or transistor logic devices, and discrete hardware components.
In still another embodiment of the present application, there is also provided a computer-readable storage medium having a computer program stored therein, which, when run on a computer, causes the computer to execute the method for correcting an image on the back side of an identification card described in the above embodiments.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the application to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored on a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wire (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wirelessly (e.g., infrared, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that includes one or more of the available media. The available media may be magnetic media (e.g., floppy disks, hard disks, tapes, etc.), optical media (e.g., DVDs), or semiconductor media (e.g., solid state drives), among others.
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The foregoing are merely exemplary embodiments of the present invention, which enable those skilled in the art to understand or practice the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A method for correcting an image on the back side of an identity card is characterized by comprising the following steps:
acquiring a back image of the identity card;
detecting and obtaining all text lines in the image on the back side of the identity card, and obtaining respective circumscribed rectangles of each text line;
according to the respective rotation angle of each circumscribed rectangle, acquiring the respective clockwise rotation angle and anticlockwise rotation angle of each circumscribed rectangle, acquiring the median of all the clockwise rotation angles as a first rotation angle, and acquiring the median of all the anticlockwise rotation angles as a second rotation angle;
and correcting the back image of the identity card according to the first rotation angle, the second rotation angle and the relative position relationship between the corrected external rectangles.
2. The method for correcting the image on the back of the identity card according to claim 1, wherein the step of correcting the image on the back of the identity card according to the first rotation angle, the second rotation angle and the relative position relationship between the circumscribed rectangles after correction comprises:
according to the first rotation angle, clockwise rotating the image on the back of the identity card to obtain a first correction image;
according to the second rotation angle, anticlockwise rotating the image on the back side of the identity card to obtain a second correction image;
acquiring coordinates of a left vertex of each circumscribed rectangle in the first corrected image, and acquiring coordinates of a left vertex of each circumscribed rectangle in the second corrected image;
according to the coordinates of the left vertex of each circumscribed rectangle in the first corrected image and the coordinates of the left vertex of each circumscribed rectangle in the second corrected image, selecting an image satisfying a preset distribution characteristic from the first corrected image and the second corrected image as the corrected ID card back image, wherein the preset distribution characteristic is as follows: and the X-axis coordinate of the left vertex of each circumscribed rectangle is concentrated in the same preset interval, the long edge of the identity card image is parallel to the X-axis after correction, and the X-axis is the abscissa axis of a predefined reference coordinate system.
3. The method for correcting the image on the back side of the identification card according to claim 2, wherein selecting an image satisfying a preset distribution characteristic from the first corrected image and the second corrected image as the corrected image on the back side of the identification card according to the coordinates of the left vertex of each circumscribed rectangle in the first corrected image and the coordinates of the left vertex of each circumscribed rectangle in the second corrected image comprises:
dividing the long edge of the first correction image into a plurality of length intervals at equal intervals by taking a preset length as an interval, classifying the X-axis coordinate of the left vertex of each circumscribed rectangle in the first correction image into the corresponding length interval, counting the number of the left vertices classified into each interval, and acquiring the maximum value of the counted number as a first maximum value;
dividing the long edge of the second correction image into a plurality of length intervals at equal intervals by taking the preset length as an interval, classifying the X-axis coordinate of the left vertex of each circumscribed rectangle in the second correction image into the corresponding length interval, counting the number of the left vertices classified into each interval, and acquiring the maximum value of the counted number as a second maximum value;
calculating the variance of the X-axis coordinate of the left vertex of each circumscribed rectangle in the first corrected image to obtain a first variance;
calculating the variance of the X-axis coordinates of the left vertex of each circumscribed rectangle in the second correction image to obtain a second variance;
if a first condition is met, taking the first corrected image as the corrected back image of the identity card, wherein the first condition is as follows: the first maximum is greater than 2 and the first variance is less than 1/3 of the second variance; or if a second condition is met, taking the second corrected image as the identity card back image after correction, wherein the second condition is as follows: the second maximum is greater than 2 and the second variance is less than 1/3 of the first variance.
4. The method for correcting the image on the back of the identity card according to claim 1, wherein the step of correcting the image on the back of the identity card according to the first rotation angle, the second rotation angle and the relative position relationship between the circumscribed rectangles after correction comprises:
according to the first rotation angle, clockwise rotating the image on the back of the identity card to obtain a third corrected image;
according to the second rotation angle, anticlockwise rotating the image on the back side of the identity card to obtain a fourth corrected image;
acquiring the minimum circumscribed rectangles of all the circumscribed rectangles in the third corrected image as a first image area, and acquiring the minimum circumscribed rectangles of all the circumscribed rectangles in the fourth corrected image as a second image area;
acquiring the central position of the first image area and the central position of each circumscribed rectangle in the first image area, and counting the number of the circumscribed rectangles with the central positions positioned on the left side of the central position of the first image area as a first number;
acquiring the central position of the second image area and the central position of each circumscribed rectangle in the second image area, and counting the number of the circumscribed rectangles with the central positions positioned on the left side of the central position of the second image area as a second number;
and if the first number is greater than the second number, taking the third corrected image as the corrected back image of the identity card, and if the first number is less than the second number, taking the fourth corrected image as the corrected back image of the identity card.
5. The method for correcting the image on the back of the identity card according to any one of claims 1 to 4, wherein after obtaining the respective circumscribed rectangle of each text line, before obtaining the respective clockwise rotation angle and the respective counterclockwise rotation angle of each circumscribed rectangle according to the respective rotation angle of each circumscribed rectangle, the method further comprises:
acquiring a rotation angle of each circumscribed rectangle relative to a reference direction, and acquiring a height of each circumscribed rectangle, wherein the reference direction is an X-axis direction of a predefined reference coordinate system;
dividing angle intervals by taking a preset angle value as an interval, classifying each external rectangle into the corresponding angle interval according to a rotation angle, counting the number of the external rectangles classified into each angle interval, and acquiring the external rectangles with the largest number in the angle intervals to serve as alternative external rectangles;
dividing height intervals by taking a preset height value as an interval, classifying each alternative external rectangle into the corresponding height interval according to the height value, counting the number of the alternative external rectangles classified into each height interval, acquiring the alternative external rectangles with the largest number in the height intervals, and taking the alternative external rectangles as the effective external rectangles obtained after filtering.
6. The method for correcting the image on the back of the identity card according to claim 3, wherein if it is determined that the first condition is not satisfied and the second condition is not satisfied, the method further comprises:
acquiring the minimum circumscribed rectangle of all the circumscribed rectangles in the first corrected image as a third image area, and acquiring the minimum circumscribed rectangle of all the circumscribed rectangles in the second corrected image as a fourth image area;
acquiring the central position of the third image area and the central position of each circumscribed rectangle in the third image area, and counting the number of the circumscribed rectangles with the central positions positioned on the left side of the central position of the third image area as a third number;
acquiring the central position of the fourth image area and the central position of each circumscribed rectangle in the fourth image area, and counting the number of the circumscribed rectangles with the central positions positioned on the left side of the central position of the fourth image area as a fourth number;
and if the third number is greater than the fourth number, taking the first corrected image as the corrected ID card back image, and if the third number is less than the fourth number, taking the second corrected image as the corrected ID card back image.
7. The method for correcting the image on the back of the identity card according to claim 1, wherein the clockwise rotation angle is equal to the rotation angle, and the counterclockwise rotation angle is equal to an angle value obtained by subtracting the rotation angle from 180 degrees.
8. A correction device for an image on the back side of an identity card is characterized by comprising:
the acquisition module is used for acquiring the back image of the identity card;
the detection module is used for detecting and obtaining all text lines in the back image of the identity card and obtaining respective external rectangles of each text line;
the selection module is used for acquiring the respective clockwise rotation angle and the respective anticlockwise rotation angle of each circumscribed rectangle according to the respective rotation angle of each circumscribed rectangle, acquiring the median of all the clockwise rotation angles as a first rotation angle, and acquiring the median of all the anticlockwise rotation angles as a second rotation angle;
and the correction module is used for correcting the image on the back side of the identity card according to the first rotation angle, the second rotation angle and the relative position relationship between the external rectangles after correction.
9. An electronic device, comprising: the system comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus; the memory for storing a computer program; the processor is used for executing the program stored in the memory to realize the method for correcting the identity card back image in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, wherein the computer program is executed by a processor to implement the method for correcting the image on the back side of the identification card according to any one of claims 1 to 7.
CN202010398820.6A 2020-05-12 2020-05-12 Correction method, device, equipment and storage medium for identity card back image Active CN111768345B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010398820.6A CN111768345B (en) 2020-05-12 2020-05-12 Correction method, device, equipment and storage medium for identity card back image

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010398820.6A CN111768345B (en) 2020-05-12 2020-05-12 Correction method, device, equipment and storage medium for identity card back image

Publications (2)

Publication Number Publication Date
CN111768345A true CN111768345A (en) 2020-10-13
CN111768345B CN111768345B (en) 2023-07-14

Family

ID=72719130

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010398820.6A Active CN111768345B (en) 2020-05-12 2020-05-12 Correction method, device, equipment and storage medium for identity card back image

Country Status (1)

Country Link
CN (1) CN111768345B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113538291A (en) * 2021-08-02 2021-10-22 广州广电运通金融电子股份有限公司 Card image tilt correction method and device, computer equipment and storage medium
CN115457559A (en) * 2022-08-19 2022-12-09 上海通办信息服务有限公司 Method, device and equipment for intelligently correcting text and license pictures

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2000113106A (en) * 1998-10-09 2000-04-21 Fuji Xerox Co Ltd Document image processor
JP2008234223A (en) * 2007-03-19 2008-10-02 Ricoh Co Ltd Image processing apparatus, image processing method, program, and recording medium
US20130194448A1 (en) * 2012-01-26 2013-08-01 Qualcomm Incorporated Rules for merging blocks of connected components in natural images
CN107169493A (en) * 2017-05-31 2017-09-15 北京小米移动软件有限公司 information identifying method and device
CN109034165A (en) * 2018-07-06 2018-12-18 北京中安未来科技有限公司 A kind of cutting method of certificate image, device, system and storage medium
CN110136069A (en) * 2019-05-07 2019-08-16 语联网(武汉)信息技术有限公司 Text image antidote, device and electronic equipment
CN110427939A (en) * 2019-08-02 2019-11-08 泰康保险集团股份有限公司 Method, apparatus, medium and the electronic equipment of correction inclination text image
CN110647882A (en) * 2019-09-20 2020-01-03 上海眼控科技股份有限公司 Image correction method, device, equipment and storage medium
CN110807454A (en) * 2019-09-19 2020-02-18 平安科技(深圳)有限公司 Character positioning method, device and equipment based on image segmentation and storage medium

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2000113106A (en) * 1998-10-09 2000-04-21 Fuji Xerox Co Ltd Document image processor
JP2008234223A (en) * 2007-03-19 2008-10-02 Ricoh Co Ltd Image processing apparatus, image processing method, program, and recording medium
US20130194448A1 (en) * 2012-01-26 2013-08-01 Qualcomm Incorporated Rules for merging blocks of connected components in natural images
CN107169493A (en) * 2017-05-31 2017-09-15 北京小米移动软件有限公司 information identifying method and device
CN109034165A (en) * 2018-07-06 2018-12-18 北京中安未来科技有限公司 A kind of cutting method of certificate image, device, system and storage medium
CN110136069A (en) * 2019-05-07 2019-08-16 语联网(武汉)信息技术有限公司 Text image antidote, device and electronic equipment
CN110427939A (en) * 2019-08-02 2019-11-08 泰康保险集团股份有限公司 Method, apparatus, medium and the electronic equipment of correction inclination text image
CN110807454A (en) * 2019-09-19 2020-02-18 平安科技(深圳)有限公司 Character positioning method, device and equipment based on image segmentation and storage medium
CN110647882A (en) * 2019-09-20 2020-01-03 上海眼控科技股份有限公司 Image correction method, device, equipment and storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
NEHA AGRAWAL等: "An Algorithmic Approach for Text Recognition from Printed/Typed Text Images", IEEE XPLORE, pages 876 - 879 *
隋清圣: "基于EmguCV的文档图像预处理研究", 万方数据库 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113538291A (en) * 2021-08-02 2021-10-22 广州广电运通金融电子股份有限公司 Card image tilt correction method and device, computer equipment and storage medium
CN113538291B (en) * 2021-08-02 2024-05-14 广州广电运通金融电子股份有限公司 Card image inclination correction method, device, computer equipment and storage medium
CN115457559A (en) * 2022-08-19 2022-12-09 上海通办信息服务有限公司 Method, device and equipment for intelligently correcting text and license pictures
CN115457559B (en) * 2022-08-19 2024-01-16 上海通办信息服务有限公司 Method, device and equipment for intelligently correcting texts and license pictures

Also Published As

Publication number Publication date
CN111768345B (en) 2023-07-14

Similar Documents

Publication Publication Date Title
CN102667810B (en) Face recognition in digital images
US9679354B2 (en) Duplicate check image resolution
CN113808131B (en) Method, system, device and medium for identifying connector defects
TW202042105A (en) Method, device and electronic device for document identification and computer readable storage medium thereof
CN110827248A (en) Method and device for identifying screen area of electronic device
CN110708568B (en) Video content mutation detection method and device
CN111768345A (en) Method, device and equipment for correcting back image of identity card and storage medium
CN110738204A (en) Method and device for positioning certificate areas
CN111768346B (en) Correction method, device, equipment and storage medium for identity card back image
CN111695410A (en) Violation reporting method and device, computer equipment and storage medium
CN112270356A (en) Image identification method and device and electronic equipment
CN116935430A (en) Picture frame identification method and device, electronic equipment and storage medium
CN108960246B (en) Binarization processing device and method for image recognition
CN109978903B (en) Identification point identification method and device, electronic equipment and storage medium
CN112629828B (en) Optical information detection method, device and equipment
CN117496560A (en) Fingerprint line identification method and device based on multidimensional vector
CN111768344B (en) Correction method, device, equipment and storage medium for front image of identity card
CN109213515B (en) Multi-platform lower buried point normalization method and device and electronic equipment
CN108256530B (en) Image recognition method, device and equipment
CN111178347A (en) Method, device and equipment for detecting fuzziness of certificate image and storage medium
CN112101059B (en) Bar code positioning method, bar code positioning device, terminal equipment and storage medium
CN110929708A (en) Method, equipment and storage medium for identifying national flag in Thai identity card
CN111178346B (en) Text region positioning method, text region positioning device, text region positioning equipment and storage medium
CN111767787B (en) Method, device, equipment and storage medium for judging front and back sides of identity card image
CN111160093A (en) Method, device, equipment and storage medium for identifying certificate photo camouflage in certificate

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
GR01 Patent grant
GR01 Patent grant