WO2020252920A1 - 图片校正方法、装置、计算机设备及计算机可读存储介质 - Google Patents

图片校正方法、装置、计算机设备及计算机可读存储介质 Download PDF

Info

Publication number
WO2020252920A1
WO2020252920A1 PCT/CN2019/103350 CN2019103350W WO2020252920A1 WO 2020252920 A1 WO2020252920 A1 WO 2020252920A1 CN 2019103350 W CN2019103350 W CN 2019103350W WO 2020252920 A1 WO2020252920 A1 WO 2020252920A1
Authority
WO
WIPO (PCT)
Prior art keywords
picture
straight line
contour
tested
line segment
Prior art date
Application number
PCT/CN2019/103350
Other languages
English (en)
French (fr)
Inventor
刘克亮
卢波
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2020252920A1 publication Critical patent/WO2020252920A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/20Image enhancement or restoration using local operators
    • G06T5/30Erosion or dilatation, e.g. thinning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/70Denoising; Smoothing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/13Edge detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/60Analysis of geometric attributes

Definitions

  • This application relates to the field of image processing technology, and in particular to a picture correction method, device, computer equipment, and computer-readable storage medium.
  • the requirements for taking the ID card photo are relatively high.
  • the camera needs to face the ID card without tilting.
  • photos that do not meet the requirements are often received, resulting in the inability to accurately identify the information in the ID card photos.
  • an embodiment of the present application also provides a picture correction device, which includes:
  • a conversion unit configured to convert the picture to be tested into a binary picture if the picture to be tested is received
  • a contour detection processing unit configured to perform contour detection processing on the binarized picture to obtain contour lines in the binarized picture
  • a straight line detection processing unit configured to perform straight line detection processing on the contour line to obtain a straight line segment in the contour line;
  • the first determining unit the user determines the identification card range in the picture to be tested according to the straight line segment of the contour line;
  • the first perspective transformation unit is used to perspectively transform the picture within the scope of the ID card into a preset rectangular area to obtain a corrected picture.
  • the embodiments of the present application also provide a computer-readable storage medium, the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the following steps:
  • FIG. 1 is a schematic flowchart of a picture correction method provided by an embodiment of this application
  • FIG. 2 is a schematic diagram of a sub-flow of a picture correction method provided by an embodiment of this application;
  • FIG. 3 is a schematic diagram of a sub-flow of a picture correction method provided by an embodiment of this application.
  • FIG. 4 is a schematic flowchart of a picture correction method provided by another embodiment of this application.
  • FIG. 5 is a schematic block diagram of a picture correction device provided by an embodiment of this application.
  • FIG. 6 is a schematic block diagram of a conversion unit of a picture correction device provided by an embodiment of the application.
  • FIG. 7 is a schematic block diagram of a first determining unit of a picture correction device provided by an embodiment of this application.
  • FIG. 11 is a schematic block diagram of a computer device provided by an embodiment of this application.
  • the term “if” can be interpreted as “when” or “once” or “in response to determination” or “in response to detection” depending on the context .
  • the phrase “if determined” or “if detected [described condition or event]” can be interpreted as meaning “once determined” or “response to determination” or “once detected [described condition or event]” depending on the context ]” or “in response to detection of [condition or event described]”.
  • FIG. 1 is a schematic flowchart of an image correction method provided by an embodiment of this application.
  • the image correction method proposed in this embodiment of the application is applied to a server. As shown in the figure, the method includes the following steps S1-S5.
  • Binarization is to set the gray value of the pixels on the picture to 0 or 255, which means that the entire picture presents an obvious visual effect of only black and white.
  • the most common method is to set a threshold T, and use T to divide the image data into two parts: the pixel group larger than T and the pixel group smaller than T.
  • step S1 specifically includes the following steps S11-S13.
  • the image to be tested is grayed out.
  • the process of converting a color picture into a grayscale picture becomes the grayscale processing of the picture.
  • the color of each pixel in a color picture is determined by the three components of R, G, and B, and each component has 255 possible values, so a pixel can have more than 16 million (255*255*255) color changes range.
  • the gray-scale picture is a special color picture with the same three components of R, G, and B.
  • the variation range of one pixel is 255. Therefore, in digital picture processing, pictures in various formats are generally converted to gray. In order to make the calculation of subsequent pictures less.
  • the grayscale processing of the picture can be achieved by the following methods:
  • S12 Perform Gaussian filtering processing on the picture to be tested after the grayscale processing.
  • Gaussian filtering is performed on the picture to be tested after the gray-scale processing.
  • Gaussian filtering is a process of weighted average of the entire image. The value of each pixel in the picture is obtained by weighted average of itself and other pixel values in the neighborhood.
  • Gaussian filtering is to scan each pixel in the image with a template (or convolution, mask), and use the weighted average gray value of the pixels in the neighborhood determined by the template to replace the value of the center pixel of the template.
  • binarization processing is performed on the picture to be tested after Gaussian filtering.
  • the image binarization process is to set the gray scale of the points on the image to 0 or 255, that is, to present the entire image with a clear black and white effect. That is to say, a grayscale image with 256 brightness levels is selected through an appropriate threshold to obtain a binarized image that can still reflect the overall and local characteristics of the image.
  • contour detection processing is performed on the binarized picture to obtain contour lines in the binarized picture.
  • Contour detection processing refers to the process of extracting contour lines from a binary image.
  • the contour lines in the binarized picture can be extracted by a preset contour line extraction tool.
  • a straight line detection process is performed on the contour line to obtain a straight line segment in the contour line.
  • the straight line segment in the contour line is recognized and acquired by the Hough straight line detection method.
  • the Hough transform (Hough) straight line detection method specifically realizes the fitting of the straight line by transforming the image coordinate space to the parameter space.
  • S4 Determine the ID card range in the picture to be tested according to the straight line segment of the contour line.
  • the identification card range in the picture to be tested is determined according to the straight line segment of the contour line.
  • the scope of the ID card refers to the scope of the image of the ID card in the picture to be tested.
  • the ID card is quadrilateral
  • the ID card range is a range enclosed by four straight line segments. Therefore, the quadrilateral area enclosed by the straight line segment of the contour line is first acquired, and then the identification card range in the picture to be tested is determined according to the acquired quadrilateral area.
  • step S4 specifically includes the following steps S41-S46.
  • the length threshold can be set by those skilled in the art based on experience.
  • the length threshold is set to 3 cm.
  • 3cm the side length of the ID card is usually greater than 3cm
  • the straight line segments whose included angles are less than a preset included angle threshold in the first straight line segment set are combined to obtain the second straight line segment set.
  • two straight line segments whose included angles are less than a preset included angle threshold may be merged into an angle bisector of the angle formed by the two straight lines.
  • the straight line segments whose intersection points are outside the range of the picture to be measured in the second straight line segment set are deleted to obtain the third straight line segment set. If the intersection of the two straight line segments is outside the range of the picture to be tested, the two straight lines cannot be the edge lines of the ID card, so the two straight line segments are deleted.
  • a quadrilateral area enclosed by the straight line segments in the third straight line segment set is obtained.
  • the straight line segments in the third set of straight line segments can be extended to both ends.
  • the range enclosed by the quadrilateral area is determined as the ID card range.
  • the straight line segments in the third straight line segment set enclose multiple quadrilateral areas
  • the range enclosed by the quadrilateral area with the largest area among the multiple quadrilateral areas is determined as the ID card range.
  • the picture within the scope of the ID card in the picture to be tested is perspectively transformed into a preset rectangular area to obtain a corrected picture.
  • the preset rectangular area is the size of a standard ID card, which realizes the automatic perspective transformation of the picture to be tested input by the user into a standard ID card picture, which reduces the difficulty of shooting for the user and improves the user Experience.
  • Perspective transformation is to project the picture to a new viewing plane (Viewing Plane), also known as Projective Mapping.
  • Perspective transformation refers to the use of the three-point collinear condition of the perspective center, the image point and the target point to rotate the bearing surface (perspective surface) around the trace (perspective axis) by a certain angle according to the perspective rotation law, destroying the original projection light
  • the wiring harness can still maintain the constant transformation of the projection geometry on the bearing surface.
  • (u, v) are the coordinates of each pixel in the picture (ie, the original picture) within the scope of the ID card, and (x, y) are the coordinates of each pixel in the corresponding rectangular area.
  • the picture to be tested is processed as a binarized picture; contour detection processing is performed on the binarized picture to obtain the binarized picture
  • the contour line of the contour line; the contour line is subjected to straight line detection processing to obtain the straight line segment in the contour line; the identification card range in the picture to be tested is determined according to the straight line segment of the contour line; the picture to be tested
  • the image in the ID card range in the ID card is transformed into the preset rectangular area to obtain the corrected image, thus realizing the automatic conversion of the image to be tested input by the user into a standard ID card image, making it easier for the server to identify the ID card photo
  • FIG. 4 is a schematic flowchart of a picture correction method provided by another embodiment of the present application. As shown in FIG. 4, the picture correction method of this embodiment includes steps S51-S57.
  • the steps S51-S55 are similar to the steps S1-S5 in the foregoing embodiment, and will not be repeated here.
  • the steps S56-S57 added in this embodiment will be described in detail below.
  • image morphological expansion processing is performed on the binarized picture.
  • Image morphology processing includes image morphology dilation processing and image morphology erosion processing.
  • Image morphology processing is for the white part (highlight part) of the image.
  • Image morphology expansion processing refers to the expansion of the highlighted part of the image, similar to the field expansion, the effect picture after expansion processing has a larger highlight area than the original image.
  • the binarized picture after the image morphology expansion processing is subjected to image morphology corrosion processing.
  • the image morphology corrosion process is to corrode the highlight part of the original image, similar to the area being eroded, the effect image after the corrosion process has a smaller highlight area than the original image.
  • FIG. 5 is a schematic block diagram of a picture correction device 50 provided by an embodiment of the present application. As shown in FIG. 5, corresponding to the above picture correction method, the present application also provides a picture correction device 50.
  • the picture correction device 50 includes a unit for executing the above-mentioned picture correction method, and the device may be configured in a server. Specifically, referring to FIG. 5, the image correction device 50 includes a conversion unit 51, a contour detection processing unit 52, a straight line detection processing unit 53, a first determination unit 54, and a first perspective transformation unit 55.
  • the conversion unit 51 is configured to, if the picture to be tested is received, convert the picture to be tested into a binarized picture
  • the contour detection processing unit 52 is configured to perform contour detection processing on the binarized picture to obtain contour lines in the binarized picture;
  • the straight line detection processing unit 53 is configured to perform straight line detection processing on the contour line to obtain a straight line segment in the contour line;
  • the first determining unit 54 is for the user to determine the identification card range in the picture to be tested according to the straight line segment of the contour line;
  • the first perspective transformation unit 55 is configured to perspectively transform the picture within the scope of the ID card into a preset rectangular area to obtain a corrected picture.
  • the conversion unit 51 includes a grayscale processing unit 511, a Gaussian filter processing unit 512 and a binarization processing unit 513.
  • the grayscale processing unit 511 is configured to perform grayscale processing on the picture to be tested;
  • the Gaussian filter processing unit 512 is configured to perform Gaussian filter processing on the image to be tested after the grayscale processing;
  • the binarization processing unit 513 is configured to perform binarization processing on the picture to be tested after the Gaussian filtering process to obtain the binarized picture.
  • the first deleting unit 541 is configured to delete the straight line segments whose length is less than the preset length threshold among the straight line segments of the contour line to obtain the first straight line segment set;
  • the merging unit 542 is configured to merge the straight line segments whose included angles are less than a preset included angle threshold in the first straight line segment set to obtain a second straight line segment set;
  • the second deleting unit 543 is configured to delete the straight line segments whose intersection points are outside the range of the picture to be measured in the second straight line segment set to obtain a third straight line segment set;
  • the obtaining unit 544 is configured to obtain a quadrilateral area surrounded by straight line segments in the third straight line segment set;
  • the second determining unit 545 is configured to, if the straight line segments in the third straight line segment set only enclose a quadrilateral area, determine the range enclosed by the quadrilateral area as the ID card range;
  • the third determining unit 546 is configured to, if the straight line segments in the third straight line segment set enclose multiple quadrilateral areas, determine the range enclosed by the quadrilateral area with the largest area among the multiple quadrilateral areas as the ID card range.
  • the first perspective transformation unit 55 includes a second perspective transformation unit 551.
  • the second perspective transformation unit 551 is configured to perspectively transform the picture within the ID card area into a preset rectangular area through the following formula
  • the recognition unit 541 is configured to recognize and acquire the straight line segments in the contour line by the Hough transform straight line detection method.
  • the length threshold is 3 cm.
  • the included angle threshold is 1.5°.
  • FIG. 10 is a schematic block diagram of a picture correction device 50 according to another embodiment of the present application. As shown in FIG. 10, the image correction device 50 of this embodiment adds an expansion processing unit 56 and an erosion processing unit 57 on the basis of the foregoing embodiment.
  • the expansion processing unit 56 is configured to perform image morphological expansion processing on the binarized picture
  • the corrosion processing unit 57 is configured to perform image morphology corrosion processing on the binarized picture after the image morphology expansion processing.
  • the above-mentioned picture correction device 50 may be implemented in the form of a computer program, and the computer program may be run on a computer device as shown in FIG. 11.
  • FIG. 11 is a schematic block diagram of a computer device according to an embodiment of the present application.
  • the computer device 500 is a server, where the server may be an independent server or a server cluster composed of multiple servers.
  • the computer device 500 includes a processor 502, a memory, and a network interface 505 connected through a system bus 501, where the memory may include a non-volatile storage medium 503 and an internal memory 504.
  • the non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032.
  • the processor 502 can execute a picture correction method.
  • the processor 502 is used to provide calculation and control capabilities to support the operation of the entire computer device 500.
  • the internal memory 504 provides an environment for the running of the computer program 5032 in the non-volatile storage medium 503.
  • the processor 502 can execute a picture correction method.
  • the network interface 505 is used for network communication with other devices.
  • the structure shown in FIG. 11 is only a block diagram of part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 500 to which the solution of the present application is applied.
  • the specific computer device 500 may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
  • the processor 502 is configured to run a computer program 5032 stored in the memory to implement the following steps:
  • the processor 502 when the processor 502 implements the step of converting the picture to be tested into a binarized picture, it specifically implements the following steps:
  • the processor 502 when the processor 502 implements the step of determining the ID card range in the picture to be tested according to the straight line segment of the contour line, the following steps are specifically implemented:
  • the straight line segments in the third straight line segment set enclose multiple quadrilateral areas
  • the range enclosed by the quadrilateral area with the largest area among the multiple quadrilateral areas is determined as the ID card range.
  • the processor 502 when the processor 502 implements the step of transforming the image within the scope of the ID card into a preset rectangular area to obtain a corrected image, the processor 502 specifically implements the following steps:
  • the processor 502 further implements the following steps before implementing the step of performing contour detection processing on the binarized picture to obtain contour lines in the binarized picture:
  • the processor 502 when the processor 502 implements the step of performing straight line detection processing on the contour line to obtain a straight line segment in the contour line, the processor 502 specifically implements the following steps:
  • the straight line segment in the contour line is recognized and acquired by the Hough transform straight line detection method.
  • the length threshold is 3 cm.
  • the computer program may be stored in a storage medium, and the storage medium is a computer-readable storage medium.
  • the computer program is executed by at least one processor in the computer system to implement the process steps of the foregoing method embodiment.
  • the storage medium is a physical, non-transitory storage medium, such as a U disk, a mobile hard disk, a read-only memory (Read-Only Memory, ROM), a magnetic disk, or an optical disk that can store program codes. medium.
  • the storage medium may be a computer-readable storage medium.
  • the storage medium stores a computer program. When the computer program is executed by the processor, the processor executes the following steps:
  • the processor executes the computer program to implement the step of determining the ID card range in the picture to be tested according to the straight line segment of the contour line, the following steps are specifically implemented:
  • the straight line segments in the third straight line segment set only enclose a quadrilateral area is determined as the ID card range
  • the straight line segments in the third straight line segment set enclose multiple quadrilateral areas
  • the range enclosed by the quadrilateral area with the largest area among the multiple quadrilateral areas is determined as the ID card range.
  • the processor executes the computer program to realize the step of transforming the picture within the scope of the ID card into a preset rectangular area to obtain a corrected picture
  • the following steps are specifically implemented:
  • the processor further implements the following steps before executing the computer program to implement the step of performing contour detection processing on the binarized picture to obtain contour lines in the binarized picture :
  • the straight line segment in the contour line is recognized and acquired by the Hough transform straight line detection method.
  • the length threshold is 3 cm.
  • the included angle threshold is 1.5°.
  • the storage medium may be a U disk, a mobile hard disk, a read-only memory (Read-Only Memory, ROM), a magnetic disk or an optical disk, and other computer-readable storage media that can store program codes.
  • ROM Read-Only Memory
  • the disclosed device and method may be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of each unit is only a logical function division, and there may be other division methods in actual implementation.
  • multiple units or components can be combined or integrated into another system, or some features can be omitted or not implemented.
  • the steps in the method of the embodiment of the present application can be adjusted, merged, and deleted in order according to actual needs.
  • the units in the devices in the embodiments of the present application may be combined, divided, and deleted according to actual needs.
  • the functional units in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium.
  • the technical solution of this application is essentially or the part that contributes to the existing technology, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium It includes several instructions to make a computer device (which may be a personal computer, a terminal, or a network device, etc.) execute all or part of the steps of the method described in each embodiment of the present application.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Geometry (AREA)
  • Image Analysis (AREA)
  • Image Processing (AREA)

Abstract

一种图片校正方法、装置、计算机设备及计算机可读存储介质。所述方法包括:若接收到待测图片,将所述待测图片转换为二值化图片(S1);对所述二值化图片进行轮廓检测处理以获取所述二值化图片中的轮廓线(S2);对所述轮廓线进行直线检测处理以获取所述轮廓线中的直线段(S3);根据所述轮廓线的直线段确定所述待测图片中的身份证范围(S4);将所述身份证范围内的图片透视变换到预设的矩形区域内以得到校正图片(S5)。

Description

图片校正方法、装置、计算机设备及计算机可读存储介质
本申请要求于2019年6月18日提交中国专利局、申请号为201910527667.X,申请名称为“图片校正方法、装置、计算机设备及计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及图像处理技术领域,尤其涉及一种图片校正方法、装置、计算机设备及计算机可读存储介质。
背景技术
目前,越来越多的应用场景(例如,线上购买理财产品)需要用户上传身份证照片。
现有技术中,为了能够较好的识别身份证上面的信息,对身份证照片的拍摄要求较高,拍摄时需要相机正对身份证,并且不能倾斜。然而,限于用户拍摄水平的限制,常会接收到不符合要求的照片,导致无法准确识别身份证照片中的信息。
发明内容
本申请实施例提供了一种图片校正方法、装置、计算机设备及存储介质,旨在提高对身份证照片信息识别的准确性。
第一方面,本申请实施例提供了一种图片校正方法,其包括:
若接收到待测图片,将所述待测图片转换为二值化图片;
对所述二值化图片进行轮廓检测处理以获取所述二值化图片中的轮廓线;
对所述轮廓线进行直线检测处理以获取所述轮廓线中的直线段;
根据所述轮廓线的直线段确定所述待测图片中的身份证范围;
将所述身份证范围内的图片透视变换到预设的矩形区域内以得到校正图片。
第二方面,本申请实施例还提供了一种图片校正装置,其包括:
转换单元,用于若接收到待测图片,将所述待测图片转换为二值化图片;
轮廓检测处理单元,用于对所述二值化图片进行轮廓检测处理以获取所述二值化图片中的轮廓线;
直线检测处理单元,用于对所述轮廓线进行直线检测处理以获取所述轮廓线中的直线段;
第一确定单元,用户根据所述轮廓线的直线段确定所述待测图片中的身份证范围;
第一透视变换单元,用于将所述身份证范围内的图片透视变换到预设的矩形区域内以得到校正图片。
第三方面,本申请实施例还提供了一种计算机设备,其包括存储器以及与所述存储器相连的处理器;所述存储器用于存储计算机程序;所述处理器用于运行所述存储器中存储的计算机程序,以执行如下步骤:
若接收到待测图片,将所述待测图片转换为二值化图片;
对所述二值化图片进行轮廓检测处理以获取所述二值化图片中的轮廓线;
对所述轮廓线进行直线检测处理以获取所述轮廓线中的直线段;
根据所述轮廓线的直线段确定所述待测图片中的身份证范围;
将所述身份证范围内的图片透视变换到预设的矩形区域内以得到校正图片。
第四方面,本申请实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时使所述处理器执行以下步骤:
若接收到待测图片,将所述待测图片转换为二值化图片;
对所述二值化图片进行轮廓检测处理以获取所述二值化图片中的轮廓线;
对所述轮廓线进行直线检测处理以获取所述轮廓线中的直线段;
根据所述轮廓线的直线段确定所述待测图片中的身份证范围;
将所述身份证范围内的图片透视变换到预设的矩形区域内以得到校正图片。
附图说明
为了更清楚地说明本申请实施例技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本申请的一些实 施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本申请实施例提供的一种图片校正方法的流程示意图;
图2为本申请实施例提供的一种图片校正方法的子流程示意图;
图3为本申请实施例提供的一种图片校正方法的子流程示意图;
图4为本申请另一实施例提供的一种图片校正方法的流程示意图;
图5为本申请实施例提供的一种图片校正装置的示意性框图;
图6为本申请实施例提供的一种图片校正装置的转换单元的示意性框图;
图7为本申请实施例提供的一种图片校正装置的第一确定单元的示意性框图;
图8为本申请实施例提供的一种图片校正装置的第一投射变换单元的示意性框图;
图9为本申请实施例提供的一种图片校正装置的第一确定单元的示意性框图;
图10为本申请另一实施例提供的一种图片校正装置的示意性框图;以及
图11为本申请实施例提供的一种计算机设备的示意性框图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
应当理解,当在本说明书和所附权利要求书中使用时,术语“包括”和“包含”指示所描述特征、整体、步骤、操作、元素和/或组件的存在,但并不排除一个或多个其它特征、整体、步骤、操作、元素、组件和/或其集合的存在或添加。
还应当理解,在此本申请说明书中所使用的术语仅仅是出于描述特定实施例的目的而并不意在限制本申请。如在本申请说明书和所附权利要求书中所使用的那样,除非上下文清楚地指明其它情况,否则单数形式的“一”、“一个”及“该”意在包括复数形式。
还应当进一步理解,在本申请说明书和所附权利要求书中使用的术语“和/ 或”是指相关联列出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。
如在本说明书和所附权利要求书中所使用的那样,术语“如果”可以依据上下文被解释为“当...时”或“一旦”或“响应于确定”或“响应于检测到”。类似地,短语“如果确定”或“如果检测到[所描述条件或事件]”可以依据上下文被解释为意指“一旦确定”或“响应于确定”或“一旦检测到[所描述条件或事件]”或“响应于检测到[所描述条件或事件]”。
请参阅图1,图1为本申请实施例提供的图片校正方法的示意性流程图。本申请实施例提出的图片校正方法应用于服务器中,如图所示,该方法包括以下步骤S1-S5。
S1,若接收到待测图片,将所述待测图片转换为二值化图片。
具体实施中,若接收到用户上传的待测图片(即身份证照片),则首先将该待测图片处理为二值化图片。
二值化,就是将图片上的像素点的灰度值设置为0或255,也就是将整个图片呈现出明显的只有黑和白的视觉效果。最常用的方法就是设定一个阈值T,用T将图像的数据分成两部分:大于T的像素群和小于T的像素群。
参见图2,在一实施例中,以上步骤S1具体包括以下步骤S11-S13。
S11,对待测图片进行灰度化处理。
具体实施中,对待测图片进行灰度化处理。将彩色图片转化成为灰度图片的过程成为图片的灰度化处理。彩色图片中的每个像素的颜色有R、G、B三个分量决定,而每个分量有255种值可取,这样一个像素点可以有1600多万(255*255*255)的颜色的变化范围。而灰度图片是R、G、B三个分量相同的一种特殊的彩色图片,其一个像素点的变化范围为255种,所以在数字图片处理种一般先将各种格式的图片转变成灰度图片以使后续的图片的计算量变得少一些。灰度图片的描述与彩色图片一样仍然反映了整幅图片的整体和局部的色度和亮度等级的分布和特征。图片的灰度化处理可用以下方法来实现:
首先求出每个像素点的R、G、B三个分量的平均值,然后将这个平均值赋予给这个像素的三个分量。
S12,对灰度化处理后的待测图片进行高斯滤波处理。
具体实施中,对灰度化处理后的待测图片进行高斯滤波处理。高斯滤波处 理为对整幅图像进行加权平均的过程。图片中每一个像素点的值,都由其本身和邻域内的其他像素值经过加权平均后得到。
高斯滤波的具体操作是:用一个模板(或称卷积、掩模)扫描图像中的每一个像素,用模板确定的邻域内像素的加权平均灰度值去替代模板中心像素点的值。
S13,对高斯滤波处理后的待测图片进行二值化处理。
具体实施中,对高斯滤波处理后的待测图片进行二值化处理。
图像的二值化处理就是将图像上的点的灰度置为0或255,也就是将整个图像呈现出明显的黑白效果。即将256个亮度等级的灰度图像通过适当的阈值选取而获得仍然可以反映图像整体和局部特征的二值化图像。
S2,对所述二值化图片进行轮廓检测处理以获取所述二值化图片中的轮廓线。
具体实施中,对所述二值化图片进行轮廓检测处理以获取所述二值化图片中的轮廓线。轮廓检测处理是指从二值化图片提取轮廓线的过程。具体实施中,可通过预设的轮廓线提取工具提取二值化图片中的轮廓线。
需要说明的是,常用的轮廓线提取工具包括matlab(矩阵实验室)。
S3,对所述轮廓线进行直线检测处理以获取所述轮廓线中的直线段。
具体实施中,对所述轮廓线进行直线检测处理以获取所述轮廓线中的直线段。
具体地,在一实施例中,通过霍夫变换(Hough)直线检测方法识别获取所述轮廓线中的直线段。霍夫变换(Hough)直线检测方法具体是通过将图像坐标空间变换到参数空间,来实现直线的拟合。
S4,根据所述轮廓线的直线段确定所述待测图片中的身份证范围。
具体实施中,在获取了轮廓线中的直线段后,根据轮廓线的直线段确定所述待测图片中的身份证范围。身份证范围是指待测图片中身份证图片部分所处的范围。
具体地,由于身份证是四边形的,因此身份证范围是由四条直线段围成的范围。因此,首先获取所述轮廓线的直线段围成的四边形区域,再根据获取到的四边形区域确定所述待测图片中的身份证范围。
参见图3,在一实施例中,以上步骤S4具体包括如下步骤S41-S46。
S41,将所述轮廓线的直线段中长度小于预设的长度阈值的直线段删除以得 到第一直线段集合。
具体实施中,首先将所述轮廓线的直线段中长度小于预设的长度阈值的直线段删除以得到第一直线段集合。
需要说明的是,长度阈值可由本领域技术人员根据经验进行设定,例如,在一实施例中,长度阈值设定为3cm。通过设定长度阈值为3cm(身份证的边长通常大于3cm)可删除大部分无关的直线段,提高准确性。
S42,将所述第一直线段集合中夹角小于预设的夹角阈值的直线段进行合并以得到第二直线段集合。
具体实施中,将所述第一直线段集合中夹角小于预设的夹角阈值的直线段进行合并以得到第二直线段集合。具体地,可将夹角小于预设的夹角阈值的两直线段合并为该两条直线所成角的角平分线。
需要说明的是,夹角阈值可由本领域技术人员根据经验进行设定,例如,在一实施例中,夹角阈值设定为1.5°。通过设定夹角阈值为1.5°可合并大部分相近的直线段,提高了准确性。
S43,将所述第二直线段集合中交点在所述待测图片范围外的直线段删除以得到第三直线段集合。
具体实施中,将所述第二直线段集合中交点在所述待测图片范围外的直线段删除以得到第三直线段集合。若两直线段的交点在所述待测图片范围外,则该两条直线不可能为身份证的边缘线,因此将该两条直线段删除。
S44,获取由所述第三直线段集合中的直线段所围成的四边形区域。
具体实施中,获取由所述第三直线段集合中的直线段所围成的四边形区域。具体地,为了使各直线段相交,可将第三直线段集合中的直线段向两端延伸。
S45,若所述第三直线段集合中的直线段只围成了一个四边形区域,则将所述四边形区域所围成的范围确定为所述身份证范围。
具体实施中,如果所述第三直线段集合中的直线段只围成了一个四边形区域,则将所述四边形区域所围成的范围确定为所述身份证范围。
S46,若所述第三直线段集合中的直线段围成了多个四边形区域,将多个四边形区域中面积最大的四边形区域所围成的范围确定为所述身份证范围。
具体实施中,如果所述第三直线段集合中的直线段围成了多个四边形区域,将多个四边形区域中面积最大的四边形区域所围成的范围确定为所述身份证范 围。
S5,将所述待测图片中的身份证范围内的图片透视变换到预设的矩形区域内以得到校正图片。
具体实施中,将所述待测图片中的身份证范围内的图片透视变换到预设的矩形区域内以得到校正图片。
需要说明的是,预设的矩形区域即为标准身份证的大小的区域,从而实现了将用户输入的待测图片自动透视变换为标准的身份证图片,降低了用户的拍摄难度,提高了用户的使用体验。
透视变换(Perspective Transformation)是将图片投影到一个新的视平面(Viewing Plane),也称作投影映射(Projective Mapping)。透视变换是指利用透视中心、像点、目标点三点共线的条件,按透视旋转定律使承影面(透视面)绕迹线(透视轴)旋转某一角度,破坏原有的投影光线束,仍能保持承影面上投影几何图形不变的变换。
具体地,透视变换通用的变换公式为:
Figure PCTCN2019103350-appb-000001
其中,(u,v)为身份证范围内的图片(即原始图片)内各像素点的坐标,(x,y)为对应的矩形区域内的各像素点的坐标。
Figure PCTCN2019103350-appb-000002
为透视变换矩阵A,其包含总共8个未知数a11、a12、a13、a21、a22、a23、a31、以及a32;需要说明的是,透视变换矩阵中a33默认为1。
本实施例中,身份证范围内的图片的四个顶点分别为(u1,v1)、(u2,v2)、(u3,v3)以及(u4,v4);该四个顶点对应的预设的矩形区域的四个顶点的坐标分别为(x1,y1)、(x2,y2)、(x3,y3)以及(x4,y4)。
将以上四组对应的点带入到变换公式中可得到以下8个方程组成的方程组:
Figure PCTCN2019103350-appb-000003
Figure PCTCN2019103350-appb-000004
Figure PCTCN2019103350-appb-000005
Figure PCTCN2019103350-appb-000006
Figure PCTCN2019103350-appb-000007
Figure PCTCN2019103350-appb-000008
Figure PCTCN2019103350-appb-000009
Figure PCTCN2019103350-appb-000010
通过以上方程组可计算得到变换矩阵A的8个参数a11、a12、a13、a21、a22、a23、a31以及a32。在获取变换矩阵A后,再根据变换公式计算身份证范围内的图片(即原始图片)内各像素点的坐标在预设的矩形区域中对应的坐标,从而实现了将所述待测图片中的身份证范围内的图片透视变换到预设的矩形区域内。
通过应用本申请实施例的技术方案,若接收到待测图片,将所述待测图片处理为二值化图片;对所述二值化图片进行轮廓检测处理以获取所述二值化图片中的轮廓线;对所述轮廓线进行直线检测处理以获取所述轮廓线中的直线段;根据所述轮廓线的直线段确定所述待测图片中的身份证范围;将所述待测图片中的身份证范围内的图片透视变换到预设的矩形区域内以得到校正图片,从而实现了将用户输入的待测图片自动转换为标准的身份证图片,使得服务器更易于识别身份证照片中的信息,提高了对身份证信息识别的准确率。
图4是本申请另一实施例提供的一种图片校正方法的流程示意图。如图4所示,本实施例的图片校正方法包括步骤S51-S57。其中步骤S51-S55与上述实施例中的步骤S1-S5类似,在此不再赘述。下面详细说明本实施例中所增加的步骤S56-S57。
S56,对所述二值化图片进行图像形态学膨胀处理。
具体实施中,对所述二值化图片进行图像形态学膨胀处理。图像形态学处理包括图像形态学膨胀(dilation)处理和图像形态学腐蚀(erosion)处理。
图像形态学处理都是对图像的白色部分(高亮部分)而言。图像形态学膨胀处理是指图像中的高亮部分进行膨胀,类似于领域扩张,膨胀处理后的效果图拥有比原图更大的高亮区域。
S57,对图像形态学膨胀处理后的所述二值化图片进行图像形态学腐蚀处 理。
具体实施中,对图像形态学膨胀处理后的所述二值化图片进行图像形态学腐蚀处理。图像形态学腐蚀处理是对原图的高亮部分被腐蚀,类似于领域被蚕食,腐蚀处理后的效果图拥有比原图更小的高亮区域。
通过对二值化后的待测图片先进行图像形态学膨胀处理后再进行图像形态学腐蚀处理,能够减少二值化后的待测图片中的噪点。
图5是本申请实施例提供的一种图片校正装置50的示意性框图。如图5所示,对应于以上图片校正方法,本申请还提供一种图片校正装置50。该图片校正装置50包括用于执行上述图片校正方法的单元,该装置可以被配置于服务器中。具体地,请参阅图5,该图片校正装置50包括转换单元51、轮廓检测处理单元52、直线检测处理单元53、第一确定单元54以及第一透视变换单元55。
转换单元51,用于若接收到待测图片,将所述待测图片转换为二值化图片;
轮廓检测处理单元52,用于对所述二值化图片进行轮廓检测处理以获取所述二值化图片中的轮廓线;
直线检测处理单元53,用于对所述轮廓线进行直线检测处理以获取所述轮廓线中的直线段;
第一确定单元54,用户根据所述轮廓线的直线段确定所述待测图片中的身份证范围;
第一透视变换单元55,用于将所述身份证范围内的图片透视变换到预设的矩形区域内以得到校正图片。
在一实施例中,如图6所示,所述转换单元51包括灰度化处理单元511、高斯滤波处理单元512以及二值化处理单元513。
灰度化处理单元511,用于对待测图片进行灰度化处理;
高斯滤波处理单元512,用于对灰度化处理后的待测图片进行高斯滤波处理;
二值化处理单元513,用于对高斯滤波处理后的待测图片进行二值化处理以得到所述二值化图片。
在一实施例中,如图7所示,所述第一确定单元54包括第一删除单元541、合并单元542、第二删除单元543、获取单元544、第二确定单元545以及第三确定单元546。
第一删除单元541,用于将所述轮廓线的直线段中长度小于预设的长度阈值的直线段删除以得到第一直线段集合;
合并单元542,用于将所述第一直线段集合中夹角小于预设的夹角阈值的直线段进行合并以得到第二直线段集合;
第二删除单元543,用于将所述第二直线段集合中交点在所述待测图片范围外的直线段删除以得到第三直线段集合;
获取单元544,用于获取由所述第三直线段集合中的直线段所围成的四边形区域;
第二确定单元545,用于若所述第三直线段集合中的直线段只围成了一个四边形区域,将所述四边形区域所围成的范围确定为所述身份证范围;
第三确定单元546,用于若所述第三直线段集合中的直线段围成了多个四边形区域,将多个四边形区域中面积最大的四边形区域所围成的范围确定为所述身份证范围。
在一实施例中,如图8所示,所述第一透视变换单元55包括第二透视变换单元551。
第二透视变换单元551,用于通过以下公式|x y 1|=|u v 1|A将所述身份证范围内的图片透视变换到预设的矩形区域内,其中,(u,v)为所述身份证范围内的图片内各像素点的坐标,(x,y)为对应的矩形区域内的各像素点的坐标,A为透视变换矩阵。
在一实施例中,如图9所示,所述第一确定单元54包括识别单元541。
识别单元541,用于通过霍夫变换直线检测方法识别获取所述轮廓线中的直线段。
在一实施例中,所述长度阈值为3cm。
在一实施例中,所述夹角阈值为1.5°。
图10是本申请另一实施例提供的一种图片校正装置50的示意性框图。如图10所示,本实施例的图片校正装置50是上述实施例的基础上增加了膨胀处理单元56以及腐蚀处理单元57。
膨胀处理单元56,用于对所述二值化图片进行图像形态学膨胀处理;
腐蚀处理单元57,用于对图像形态学膨胀处理后的所述二值化图片进行图像形态学腐蚀处理。
需要说明的是,所属领域的技术人员可以清楚地了解到,上述图片校正装置50和各单元的具体实现过程,可以参考前述方法实施例中的相应描述,为了描述的方便和简洁,在此不再赘述。
上述图片校正装置50可以实现为一种计算机程序的形式,该计算机程序可以在如图11所示的计算机设备上运行。
请参阅图11,图11是本申请实施例提供的一种计算机设备的示意性框图。该计算机设备500是服务器,其中,服务器可以是独立的服务器,也可以是多个服务器组成的服务器集群。
参阅图11,该计算机设备500包括通过系统总线501连接的处理器502、存储器和网络接口505,其中,存储器可以包括非易失性存储介质503和内存储器504。
该非易失性存储介质503可存储操作系统5031和计算机程序5032。该计算机程序5032被执行时,可使得处理器502执行一种图片校正方法。
该处理器502用于提供计算和控制能力,以支撑整个计算机设备500的运行。
该内存储器504为非易失性存储介质503中的计算机程序5032的运行提供环境,该计算机程序5032被处理器502执行时,可使得处理器502执行一种图片校正方法。
该网络接口505用于与其它设备进行网络通信。本领域技术人员可以理解,图11中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备500的限定,具体的计算机设备500可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。
其中,所述处理器502用于运行存储在存储器中的计算机程序5032,以实现如下步骤:
若接收到待测图片,将所述待测图片转换为二值化图片;
对所述二值化图片进行轮廓检测处理以获取所述二值化图片中的轮廓线;
对所述轮廓线进行直线检测处理以获取所述轮廓线中的直线段;
根据所述轮廓线的直线段确定所述待测图片中的身份证范围;
将所述身份证范围内的图片透视变换到预设的矩形区域内以得到校正图 片。
在一实施例中,处理器502在实现所述将所述待测图片转换为二值化图片步骤时,具体实现如下步骤:
对待测图片进行灰度化处理;
对灰度化处理后的待测图片进行高斯滤波处理;
对高斯滤波处理后的待测图片进行二值化处理以得到所述二值化图片。
在一实施例中,处理器502在实现所述根据所述轮廓线的直线段确定所述待测图片中的身份证范围步骤时,具体实现如下步骤:
将所述轮廓线的直线段中长度小于预设的长度阈值的直线段删除以得到第一直线段集合;
将所述第一直线段集合中夹角小于预设的夹角阈值的直线段进行合并以得到第二直线段集合;
将所述第二直线段集合中交点在所述待测图片范围外的直线段删除以得到第三直线段集合;
获取由所述第三直线段集合中的直线段所围成的四边形区域;
若所述第三直线段集合中的直线段只围成了一个四边形区域,将所述四边形区域所围成的范围确定为所述身份证范围;
若所述第三直线段集合中的直线段围成了多个四边形区域,将多个四边形区域中面积最大的四边形区域所围成的范围确定为所述身份证范围。
在一实施例中,处理器502在实现所述将所述身份证范围内的图片透视变换到预设的矩形区域内以得到校正图片步骤时,具体实现如下步骤:
通过以下公式|x y 1|=|u v 1|A将所述身份证范围内的图片透视变换到预设的矩形区域内,其中,(u,v)为所述身份证范围内的图片内各像素点的坐标,(x,y)为对应的矩形区域内的各像素点的坐标,A为透视变换矩阵。
在一实施例中,处理器502在实现所述对所述二值化图片进行轮廓检测处理以获取所述二值化图片中的轮廓线步骤之前,还实现如下步骤:
对所述二值化图片进行图像形态学膨胀处理;
对图像形态学膨胀处理后的所述二值化图片进行图像形态学腐蚀处理。
在一实施例中,处理器502在实现所述对所述轮廓线进行直线检测处理以获取所述轮廓线中的直线段步骤时,具体实现如下步骤:
通过霍夫变换直线检测方法识别获取所述轮廓线中的直线段。
在一实施例中,所述长度阈值为3cm。
在一实施例中,所述夹角阈值为1.5°。
应当理解,在本申请实施例中,处理器502可以是中央处理单元(Central Processing Unit,CPU),该处理器502还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。其中,通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
本领域普通技术人员可以理解的是实现上述实施例的方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成。该计算机程序可存储于一存储介质中,该存储介质为计算机可读存储介质。该计算机程序被该计算机系统中的至少一个处理器执行,以实现上述方法的实施例的流程步骤。
因此,本申请还提供一种存储介质。所述存储介质为实体的、非瞬时性的存储介质,例如可以是U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、磁碟或者光盘等各种可以存储程序代码的实体存储介质。该存储介质可以为计算机可读存储介质。该存储介质存储有计算机程序。该计算机程序被处理器执行时使处理器执行如下步骤:
若接收到待测图片,将所述待测图片转换为二值化图片;
对所述二值化图片进行轮廓检测处理以获取所述二值化图片中的轮廓线;
对所述轮廓线进行直线检测处理以获取所述轮廓线中的直线段;
根据所述轮廓线的直线段确定所述待测图片中的身份证范围;
将所述身份证范围内的图片透视变换到预设的矩形区域内以得到校正图片。
在一实施例中,所述处理器在执行所述计算机程序而实现所述将所述待测图片转换为二值化图片步骤时,具体实现如下步骤:
对待测图片进行灰度化处理;
对灰度化处理后的待测图片进行高斯滤波处理;
对高斯滤波处理后的待测图片进行二值化处理以得到所述二值化图片。
在一实施例中,所述处理器在执行所述计算机程序而实现所述根据所述轮 廓线的直线段确定所述待测图片中的身份证范围步骤时,具体实现如下步骤:
将所述轮廓线的直线段中长度小于预设的长度阈值的直线段删除以得到第一直线段集合;
将所述第一直线段集合中夹角小于预设的夹角阈值的直线段进行合并以得到第二直线段集合;
将所述第二直线段集合中交点在所述待测图片范围外的直线段删除以得到第三直线段集合;
获取由所述第三直线段集合中的直线段所围成的四边形区域;
若所述第三直线段集合中的直线段只围成了一个四边形区域,将所述四边形区域所围成的范围确定为所述身份证范围;
若所述第三直线段集合中的直线段围成了多个四边形区域,将多个四边形区域中面积最大的四边形区域所围成的范围确定为所述身份证范围。
在一实施例中,所述处理器在执行所述计算机程序而实现所述将所述身份证范围内的图片透视变换到预设的矩形区域内以得到校正图片步骤时,具体实现如下步骤:
通过以下公式|x y 1|=|u v 1|A将所述身份证范围内的图片透视变换到预设的矩形区域内,其中,(u,v)为所述身份证范围内的图片内各像素点的坐标,(x,y)为对应的矩形区域内的各像素点的坐标,A为透视变换矩阵。
在一实施例中,所述处理器在执行所述计算机程序而实现所述对所述二值化图片进行轮廓检测处理以获取所述二值化图片中的轮廓线步骤之前,还实现如下步骤:
对所述二值化图片进行图像形态学膨胀处理;
对图像形态学膨胀处理后的所述二值化图片进行图像形态学腐蚀处理。
在一实施例中,所述处理器在执行所述计算机程序而实现所述对所述轮廓线进行直线检测处理以获取所述轮廓线中的直线段步骤时,具体实现如下步骤:
通过霍夫变换直线检测方法识别获取所述轮廓线中的直线段。
在一实施例中,所述长度阈值为3cm。
在一实施例中,所述夹角阈值为1.5°。
所述存储介质可以是U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、磁碟或者光盘等各种可以存储程序代码的计算机可读存储介质。
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的。例如,各个单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。
本申请实施例方法中的步骤可以根据实际需要进行顺序调整、合并和删减。本申请实施例装置中的单元可以根据实际需要进行合并、划分和删减。另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以是两个或两个以上单元集成在一个单元中。
该集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分,或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,终端,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详细描述的部分,可以参见其他实施例的相关描述。
显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的精神和范围。这样,尚且本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本申请的保护范围之内。 因此,本申请的保护范围应以权利要求的保护范围为准。

Claims (20)

  1. 一种图片校正方法,包括:
    若接收到待测图片,将所述待测图片转换为二值化图片;
    对所述二值化图片进行轮廓检测处理以获取所述二值化图片中的轮廓线;
    对所述轮廓线进行直线检测处理以获取所述轮廓线中的直线段;
    根据所述轮廓线的直线段确定所述待测图片中的身份证范围;
    将所述身份证范围内的图片透视变换到预设的矩形区域内以得到校正图片。
  2. 根据权利要求1所述的方法,其中,所述将所述待测图片转换为二值化图片,包括:
    对待测图片进行灰度化处理;
    对灰度化处理后的待测图片进行高斯滤波处理;
    对高斯滤波处理后的待测图片进行二值化处理以得到所述二值化图片。
  3. 根据权利要求1所述的方法,其中,在所述对所述二值化图片进行轮廓检测处理以获取所述二值化图片中的轮廓线之前,所述方法还包括:
    对所述二值化图片进行图像形态学膨胀处理;
    对图像形态学膨胀处理后的所述二值化图片进行图像形态学腐蚀处理。
  4. 根据权利要求1所述的方法,其中,所述根据所述轮廓线的直线段确定所述待测图片中的身份证范围,包括:
    将所述轮廓线的直线段中长度小于预设的长度阈值的直线段删除以得到第一直线段集合;
    将所述第一直线段集合中夹角小于预设的夹角阈值的直线段进行合并以得到第二直线段集合;
    将所述第二直线段集合中交点在所述待测图片范围外的直线段删除以得到第三直线段集合;
    获取由所述第三直线段集合中的直线段所围成的四边形区域;
    若所述第三直线段集合中的直线段只围成了一个四边形区域,将所述四边形区域所围成的范围确定为所述身份证范围。
  5. 根据权利要求4所述的方法,其中,所述根据所述轮廓线的直线段确定所述待测图片中的身份证范围,还包括:
    若所述第三直线段集合中的直线段围成了多个四边形区域,将多个四边形区域中面积最大的四边形区域所围成的范围确定为所述身份证范围。
  6. 根据权利要求4所述的方法,其中,所述长度阈值为3cm。
  7. 根据权利要求4所述的方法,其中,所述夹角阈值为1.5°。
  8. 根据权利要求1所述的方法,其中,所述将所述身份证范围内的图片透视变换到预设的矩形区域内以得到校正图片,包括:
    通过以下公式|x y 1|=|u v 1|A将所述身份证范围内的图片透视变换到预设的矩形区域内,其中,(u,v)为所述身份证范围内的图片内各像素点的坐标,(x,y)为对应的矩形区域内的各像素点的坐标,A为透视变换矩阵。
  9. 根据权利要求1所述的方法,其中,所述对所述轮廓线进行直线检测处理以获取所述轮廓线中的直线段,包括:
    通过霍夫变换直线检测方法识别获取所述轮廓线中的直线段。
  10. 一种图片校正装置,包括:
    转换单元,用于若接收到待测图片,将所述待测图片转换为二值化图片;
    轮廓检测处理单元,用于对所述二值化图片进行轮廓检测处理以获取所述二值化图片中的轮廓线;
    直线检测处理单元,用于对所述轮廓线进行直线检测处理以获取所述轮廓线中的直线段;
    第一确定单元,用户根据所述轮廓线的直线段确定所述待测图片中的身份证范围;
    第一透视变换单元,用于将所述身份证范围内的图片透视变换到预设的矩形区域内以得到校正图片。
  11. 一种计算机设备,包括存储器以及与所述存储器相连的处理器;所述存储器用于存储计算机程序;所述处理器用于运行所述存储器中存储的计算机程序,以执行如下步骤:
    若接收到待测图片,将所述待测图片转换为二值化图片;
    对所述二值化图片进行轮廓检测处理以获取所述二值化图片中的轮廓线;
    对所述轮廓线进行直线检测处理以获取所述轮廓线中的直线段;
    根据所述轮廓线的直线段确定所述待测图片中的身份证范围;
    将所述身份证范围内的图片透视变换到预设的矩形区域内以得到校正图 片。
  12. 根据权利要求11所述的计算机设备,其中,所述将所述待测图片转换为二值化图片的步骤,包括:
    对待测图片进行灰度化处理;
    对灰度化处理后的待测图片进行高斯滤波处理;
    对高斯滤波处理后的待测图片进行二值化处理以得到所述二值化图片。
  13. 根据权利要求11所述的计算机设备,其中,在所述对所述二值化图片进行轮廓检测处理以获取所述二值化图片中的轮廓线的步骤之前,所述处理器还执行如下步骤:
    对所述二值化图片进行图像形态学膨胀处理;
    对图像形态学膨胀处理后的所述二值化图片进行图像形态学腐蚀处理。
  14. 根据权利要求11所述的计算机设备,其中,所述根据所述轮廓线的直线段确定所述待测图片中的身份证范围的步骤,包括:
    将所述轮廓线的直线段中长度小于预设的长度阈值的直线段删除以得到第一直线段集合;
    将所述第一直线段集合中夹角小于预设的夹角阈值的直线段进行合并以得到第二直线段集合;
    将所述第二直线段集合中交点在所述待测图片范围外的直线段删除以得到第三直线段集合;
    获取由所述第三直线段集合中的直线段所围成的四边形区域;
    若所述第三直线段集合中的直线段只围成了一个四边形区域,将所述四边形区域所围成的范围确定为所述身份证范围。
  15. 根据权利要求14所述的的计算机设备,其中,所述根据所述轮廓线的直线段确定所述待测图片中的身份证范围的步骤,还包括:
    若所述第三直线段集合中的直线段围成了多个四边形区域,将多个四边形区域中面积最大的四边形区域所围成的范围确定为所述身份证范围。
  16. 根据权利要求14所述的的计算机设备,其中,所述长度阈值为3cm。
  17. 根据权利要求14所述的的计算机设备,其中,所述夹角阈值为1.5°。
  18. 根据权利要求1所述的的计算机设备,其中,所述将所述身份证范围内的图片透视变换到预设的矩形区域内以得到校正图片的步骤,包括:
    通过以下公式|x y 1|=|u v 1|A将所述身份证范围内的图片透视变换到预设的矩形区域内,其中,(u,v)为所述身份证范围内的图片内各像素点的坐标,(x,y)为对应的矩形区域内的各像素点的坐标,A为透视变换矩阵。
  19. 根据权利要求1所述的计算机设备,其中,所述对所述轮廓线进行直线检测处理以获取所述轮廓线中的直线段的步骤,包括:
    通过霍夫变换直线检测方法识别获取所述轮廓线中的直线段。
  20. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时使所述处理器执行以下步骤:
    若接收到待测图片,将所述待测图片转换为二值化图片;
    对所述二值化图片进行轮廓检测处理以获取所述二值化图片中的轮廓线;
    对所述轮廓线进行直线检测处理以获取所述轮廓线中的直线段;
    根据所述轮廓线的直线段确定所述待测图片中的身份证范围;
    将所述身份证范围内的图片透视变换到预设的矩形区域内以得到校正图片。
PCT/CN2019/103350 2019-06-18 2019-08-29 图片校正方法、装置、计算机设备及计算机可读存储介质 WO2020252920A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910527667.X 2019-06-18
CN201910527667.XA CN110415183A (zh) 2019-06-18 2019-06-18 图片校正方法、装置、计算机设备及计算机可读存储介质

Publications (1)

Publication Number Publication Date
WO2020252920A1 true WO2020252920A1 (zh) 2020-12-24

Family

ID=68359237

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/103350 WO2020252920A1 (zh) 2019-06-18 2019-08-29 图片校正方法、装置、计算机设备及计算机可读存储介质

Country Status (2)

Country Link
CN (1) CN110415183A (zh)
WO (1) WO2020252920A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114022569A (zh) * 2021-11-18 2022-02-08 湖北中烟工业有限责任公司 一种基于视觉测量箱体方正度的方法及装置
CN114311572A (zh) * 2021-12-31 2022-04-12 深圳市新科聚合网络技术有限公司 Smd led注塑支架在线检测装置及其检测方法

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111462035B (zh) * 2020-01-21 2024-03-08 北京明略软件系统有限公司 一种图片检测方法及装置
CN111464716B (zh) * 2020-04-09 2022-08-19 腾讯科技(深圳)有限公司 一种证件扫描方法、装置、设备及存储介质
CN111898610B (zh) * 2020-07-29 2024-04-19 平安科技(深圳)有限公司 卡片缺角检测方法、装置、计算机设备及存储介质
CN111915524B (zh) * 2020-08-04 2024-03-29 深圳企业云科技股份有限公司 一种基于交比运算的全自动图像透视校正方法
CN113034530A (zh) * 2021-04-02 2021-06-25 广州绿怡信息科技有限公司 手机摆放检测方法及装置
CN113763235A (zh) * 2021-09-08 2021-12-07 北京琥珀创想科技有限公司 一种将图片转换为扫描件的方法及智能移动终端
CN113936286B (zh) * 2021-11-29 2024-06-14 中国平安人寿保险股份有限公司 图像文本识别方法、装置、计算机设备及存储介质
CN115439524A (zh) * 2022-09-07 2022-12-06 北京爱科农科技有限公司 叶片的参数计算方法、介质及计算机设备

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101662581A (zh) * 2009-09-09 2010-03-03 谭洪舟 多功能证件信息采集系统
CN105260709A (zh) * 2015-09-28 2016-01-20 北京石油化工学院 基于图像处理的水表检定方法、装置及系统
US20160277613A1 (en) * 2015-03-20 2016-09-22 Pfu Limited Image processing apparatus, region detection method and computer-readable, non-transitory medium
CN108021913A (zh) * 2016-10-28 2018-05-11 北京嘀嘀无限科技发展有限公司 证件照片信息识别方法及装置

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4219542B2 (ja) * 2000-09-07 2009-02-04 富士ゼロックス株式会社 画像処理装置、画像処理方法および画像処理プログラムが格納された記録媒体
CN1685373B (zh) * 2003-03-14 2011-03-02 富士通株式会社 钞票的识别方法和识别装置
US8503813B2 (en) * 2010-12-22 2013-08-06 Arcsoft Hangzhou Co., Ltd. Image rectification method
CN102902945B (zh) * 2012-09-28 2015-04-15 南京汇兴博业数字设备有限公司 基于快速响应矩阵码外轮廓的畸变校正方法
CN108960062A (zh) * 2018-06-01 2018-12-07 平安科技(深圳)有限公司 校正发票图像的方法、装置、计算机设备和存储介质
CN109635628A (zh) * 2018-10-23 2019-04-16 深圳壹账通智能科技有限公司 身份证信息验证方法、装置、设备及计算机可读存储介质
CN109711415A (zh) * 2018-11-13 2019-05-03 平安科技(深圳)有限公司 证件轮廓确定方法、装置及存储介质、服务器
CN109684971B (zh) * 2018-12-18 2023-01-24 北京理工大学珠海学院 解魔方机器人算法执行方法
CN109886896B (zh) * 2019-02-28 2021-04-27 闽江学院 一种蓝色车牌分割与矫正方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101662581A (zh) * 2009-09-09 2010-03-03 谭洪舟 多功能证件信息采集系统
US20160277613A1 (en) * 2015-03-20 2016-09-22 Pfu Limited Image processing apparatus, region detection method and computer-readable, non-transitory medium
CN105260709A (zh) * 2015-09-28 2016-01-20 北京石油化工学院 基于图像处理的水表检定方法、装置及系统
CN108021913A (zh) * 2016-10-28 2018-05-11 北京嘀嘀无限科技发展有限公司 证件照片信息识别方法及装置

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114022569A (zh) * 2021-11-18 2022-02-08 湖北中烟工业有限责任公司 一种基于视觉测量箱体方正度的方法及装置
CN114022569B (zh) * 2021-11-18 2024-06-07 湖北中烟工业有限责任公司 一种基于视觉测量箱体方正度的方法及装置
CN114311572A (zh) * 2021-12-31 2022-04-12 深圳市新科聚合网络技术有限公司 Smd led注塑支架在线检测装置及其检测方法

Also Published As

Publication number Publication date
CN110415183A (zh) 2019-11-05

Similar Documents

Publication Publication Date Title
WO2020252920A1 (zh) 图片校正方法、装置、计算机设备及计算机可读存储介质
US11120254B2 (en) Methods and apparatuses for determining hand three-dimensional data
CN111951290B (zh) 一种图像中物体的边缘检测方法及装置
CN111311482B (zh) 背景虚化方法、装置、终端设备及存储介质
CN111368717B (zh) 视线确定方法、装置、电子设备和计算机可读存储介质
EP3273388A1 (en) Image information recognition processing method and device, and computer storage medium
CN110648296B (zh) 一种瞳孔颜色修正方法、修正装置、终端设备及存储介质
CN109214996B (zh) 一种图像处理方法及装置
CN112396050B (zh) 图像的处理方法、设备以及存储介质
CN114298902A (zh) 一种图像对齐方法、装置、电子设备和存储介质
CN111290684A (zh) 图像显示方法、图像显示装置及终端设备
CN114037992A (zh) 仪表示数识别方法、装置、电子设备及存储介质
CN111383254A (zh) 一种深度信息获取方法、系统及终端设备
CN112651953A (zh) 图片相似度计算方法、装置、计算机设备及存储介质
CN114638294A (zh) 一种数据增强方法、装置、终端设备及存储介质
CN112419207A (zh) 一种图像矫正方法及装置、系统
JP6542230B2 (ja) 投影ひずみを補正するための方法及びシステム
CN111898610A (zh) 卡片缺角检测方法、装置、计算机设备及存储介质
WO2018027527A1 (zh) 一种光学系统成像质量的检测方法和装置
CN111340722B (zh) 图像处理方法、处理装置、终端设备及可读存储介质
CN108629219B (zh) 一种识别一维码的方法及装置
CN108304840B (zh) 一种图像数据处理方法以及装置
CN112580638B (zh) 文本检测方法、装置、存储介质及电子设备
CN112883762A (zh) 一种活体检测方法、装置、系统及存储介质
CN108270973B (zh) 一种拍照处理方法、移动终端及计算机可读存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19933773

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19933773

Country of ref document: EP

Kind code of ref document: A1