Method for fully automatically generating standard identification photo

By performing face alignment and formalization of self-portrait, combined with semantic segmentation and interpolation algorithms, the problem of self-portrait ID photos is solved, and the effect of automatically generating a standard ID photos is achieved.

CN119763170AActive Publication Date: 2025-04-04FUZHOU UNIV +1

Patent Information

Application Number
CN202411842778.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-13
Publication Date
2025-04-04
Estimated Expiration
2044-12-13

AI Technical Summary

Technical Problem

The prior art is difficult to solve the problem of unstandard self-portrait photos of users, especially the problem of left and right or upper and lower face shifts.

Method used

By performing key points calculations, face alignment, head pose estimation and deep neural network for selfies, face-to-facing images are generated, face-to-facing images are repaired and cropped with semantic segmentation model and interpolation algorithm, and finally background replacement and size cropping are realized.

Benefits of technology

It realizes automatic adjustment of the face angle and generates document photos that meet the requirements of standard document photos, solving the problem of self-portrait photos that are not standard.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119763170A_ABST
    Figure CN119763170A_ABST
Patent Text Reader

Abstract

The invention provides a method for fully automatically generating a standard identification photo, which comprises the following steps of: firstly, carrying out key point calculation on an acquired source image, constructing an auxiliary vector and an alignment center, and obtaining a face alignment image at a far view angle and a near view angle; secondly, estimating a head posture, and generating a face correction image by adopting a deep neural network; and finally, splicing the corrected image into a far-view-angle alignment image, and carrying out repairing and cutting to generate a standard identification photo. According to the method and the device, the identification photo meeting the face authentication requirement standard can be obtained by processing the self-shooting photo, and the generated identification photo meets the requirement of a standard identification photo by automatically adjusting the angle of the face and simultaneously realizing the functions of size cutting and background replacement.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular to a method for fully automatically generating a standard ID photo. Background Art

[0002] In recent years, with the rapid development of Internet technology and the rise of e-government, people's demand for electronic ID photos has become more frequent. In daily life, ID photos usually require users to go to professional photography studios, take photos in a fixed background, and then go through a long post-processing time to obtain them. With the ID photo generation system currently on the market, users only need to use their mobile phones to take photos of themselves and input the pictures containing the user's portraits into the system. The system can replace the background of the input pictures and crop the ID photos to generate ID photos that meet the standards for users. Compared with traditional methods, this method makes the acquisition of ID photos no longer restricted by time and place, and users can obtain customized ID photos according to their needs. However, due to the constraints of shooting environment and shooting skills, in most cases, the photos taken by users cannot meet the requirements of standard ID photos, so it is necessary to process the ID photos to make them standard.

[0003] It is a challenging task to process the user's selfie photos to meet the standards of ID photos. Existing online ID photo apps or mini-programs can only replace the background of the input image and crop the ID photo, but cannot solve the problem of users taking non-standard ID photos. The most important problem is that when users take selfies, their faces may shift left or right or up or down due to technical reasons. Summary of the invention

[0004] The present invention proposes a method for fully automatically generating a standard ID photo, which can obtain an ID photo that meets the requirements of face authentication by processing a selfie, and automatically adjusts the angle of the face and simultaneously realizes the size cropping and background replacement functions, so that the generated ID photo meets the requirements of the standard ID photo.

[0005] The present invention adopts the following technical solutions.

[0006] A method for fully automatically generating a standard ID photo, firstly, calculating the key points of the collected source image, constructing auxiliary vectors and alignment centers, and obtaining face alignment images at far and near angles; secondly, estimating the head posture, and using a deep neural network to generate a face correction image; finally, splicing the correction image into the far-angle alignment image, repairing and cropping it, and generating a standard ID photo.

[0007] The method for fully automatically generating a standard ID photo comprises the following steps:

[0008] Step S1: Two-stage face alignment using key point model;

[0009] Step S2: Estimate the head posture of the character and determine the next operation;

[0010] Step S3: Use a deep neural network to perform face correction;

[0011] Step S4: Use the semantic segmentation model and interpolation algorithm to repair the transformed image;

[0012] Step S5: Background replacement and size cropping.

[0013] Step S1 specifically includes the following steps:

[0014] Step S11: using the facial key point model to obtain the coordinates of the facial key points of the captured image, and constructing auxiliary vectors: using the left eye to the right eye as the auxiliary vector in the horizontal direction, using the eye center to the mouth center as the auxiliary vector in the vertical direction, and determining the alignment center; the direction of the auxiliary vector determines the direction of the alignment rectangular box, the modulus of the auxiliary vector determines the side length of the alignment rectangular box, and the alignment center determines the center of the alignment rectangular box, and the first stage of the telescopic face alignment operation is performed, so as to preliminarily correct the captured image in the image plane;

[0015] Step S12: Repeat step S11 on the far-view alignment image to perform the second stage of near-view standard face alignment operation; during the operation, reduce the side length of the alignment rectangle to meet the requirements of standard face alignment; and save the coordinates of the relative position of the near-view alignment image in the far-view alignment image, that is, the coordinates of the alignment rectangle.

[0016] Step S2 specifically includes: using a deep neural network to measure the horizontal deflection and vertical deflection angles of the person's head in the close-angle alignment image; and determining the next operation based on the measured deflection angles.

[0017] In step S2, the criteria for determining the next operation are: when the deflection angles in two directions are both small, the face is not rotated and step S5 is performed directly; when the deflection angle in only one direction is small, the face is not rotated in that direction and step S3 is performed sequentially; when the deflection angles in two directions are not too small and the deflection angles are within the adjustable range, step S3 is performed sequentially.

[0018] Step S3 specifically includes the following steps:

[0019] Step S31: Use a pre-trained autoencoder model to invert the near-view aligned image from the image space to the latent space to obtain an image latent code that is easy to semantically edit; the image latent code can control the semantic attributes of the generated image by compressing the image and retaining its important features, and by editing the latent code, the formula is:

[0020] C I =E(I)

[0021] Where I is the near-view aligned image, E(*) is the encoder model, and C I is the image latent code;

[0022] Step S32: Performing posture semantic editing on the image latent code using the posture information boundaries of the horizontal and vertical methods; the posture information boundaries are two binary classification boundaries in the latent space obtained by training the support vector machine, and when the latent code moves on the boundary, its posture semantic information will change accordingly; performing semantic editing on the image latent code, the formula for semantic editing is:

[0023] C o =C I +αB h +βB V

[0024] Among them, C o is the latent code after semantic editing, B h and B V are the vector representations of the horizontal and vertical boundaries of the posture information, respectively. The parameters α and β are based on the horizontal deflection and vertical deflection angles obtained in step S3, respectively. Step S33: input the semantically edited latent code into the generator model after weight fine-tuning to generate a normalized image.

[0025] I o =G(C o )

[0026] Among them, G(*) is the generator, I o is the image after normalization;

[0027] Step S34: Use the face verification model to perform face verification on the normalized image and the collected image to ensure that the identity information of the person used for face verification remains unchanged after the face is normalized.

[0028] Step S4 specifically includes the following steps:

[0029] Step S41: using the facial key point model provided by the dlib library, determining the coordinates of the chin of the face in the normalized image;

[0030] Step S42: Use the semantic segmentation model to extract the masks of the neck area of ​​the near-view alignment image and the normalized image, and then traverse the masks to obtain the boundary points of the neck area at the height of the chin position; for the normalized image, use the transformation matrix constructed by the two sets of neck boundary point coordinates to perform an affine transformation on it, so that the texture of the transformed normalized image and the near-view alignment image in the neck area is aligned; finally, replace the pixels below the chin position of the transformed normalized image with the pixels at the same position of the near-view alignment image; the formula is:

[0031] I o '=f(I o ,A)

[0032] I o '(:,y l :,:)=I(:,y l :,:)

[0033] Among them, I o is the image after normalization, I is the near-view alignment image, and y l is the vertical coordinate of the chin of the face in the image after normalization, f(,A) is the affine transformation with A as the transformation matrix, I o ′ is the image after pixel replacement;

[0034] Step S43: using an interpolation algorithm at the chin position of the pixel-replaced image to eliminate the visual boundary effect caused by the pixel replacement operation; the interpolation algorithm first calculates the vertical interpolation weight within the interpolation area, and then performs linear interpolation on each pixel point within the interpolation area.

[0035]

[0036] I i (x,y i )=w y I o ′(x,y i )+(1-w y )I o ′(x,y i +1)

[0037] Among them, w y is the interpolation weight in the vertical direction, h is the width of the interpolation area, y l is the ordinate of the chin of the face in the image after rotation, y i is the ordinate of each pixel, x is the abscissa, I o ′ is the normalized image after pixel replacement, I i is the interpolated image;

[0038] Step S44: Based on the relative position coordinates saved in step S12, the interpolated image is stitched back to the position in the telescopic alignment image obtained in step S11.

[0039] Step S5 specifically includes the following steps:

[0040] Step S51: Use the cutout model to cut out the portrait and replace it with the required ID photo background;

[0041] Step S52: Use a face detector to detect the face area, and use a semantic segmentation model to obtain a mask of the hair area. Then, traverse the mask of the hair area to find the vertices of the hair area, and determine the length, width and vertex coordinates of the head area of ​​the person in combination with the information of the face area; adjust the upper, lower, left and right boundaries of the ID photo cropping area according to the information of the head area and the required aspect ratio of the ID photo.

[0042] The method is used to solve the problem of non-standard deviation and tilt of self-portrait images during the ID photo collection process.

[0043] The method automatically adjusts the angle of the face of the self-portrait image and performs size cropping and background replacement functions, so that the ID photo generated from the self-portrait image meets the requirements of the standard ID photo.

[0044] Compared with the prior art, the present invention has the following beneficial effects: In view of the shortcomings of the existing ID photo production methods on the market, the present invention proposes a method for fully automatically generating standard ID photos, which can automatically adjust the angle of the face and realize automatic size cropping and background replacement functions. The generated ID photos meet the requirements of standard ID photos. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments:

[0046] Attached Figure 1 1 is a schematic diagram of realizing two-stage face alignment according to an embodiment of the present invention (part a is a schematic diagram of a captured image, part b is a schematic diagram of long-angle face alignment in the first stage, and part c is a schematic diagram of close-angle face alignment in the second stage);

[0047] Attached Figure 2 1 is a flowchart of an algorithm implementation from near-view alignment image to normalized image according to an embodiment of the present invention (part a is a schematic diagram of image inversion, part b is a schematic diagram of gesture semantic information boundary, part c is a schematic diagram of latent coding editing, and part d is a schematic diagram of image reconstruction);

[0048] Attached Figure 3 It is a schematic diagram of the process of the present invention. DETAILED DESCRIPTION

[0049] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.

[0050] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present application belongs.

[0051] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.

[0052] As shown in the figure, a method for fully automatically generating a standard ID photo first calculates the key points of the collected source image, constructs auxiliary vectors and alignment centers, and obtains face alignment images at far and near angles; secondly, it estimates the head posture and uses a deep neural network to generate a face correction image; finally, the correction image is spliced ​​into the far-angle alignment image, repaired and cropped, and a standard ID photo is generated.

[0053] The method for fully automatically generating a standard ID photo comprises the following steps:

[0054] Step S1: Two-stage face alignment using key point model;

[0055] Step S2: Estimate the head posture of the character and determine the next operation;

[0056] Step S3: Use a deep neural network to perform face correction;

[0057] Step S4: Use the semantic segmentation model and interpolation algorithm to repair the transformed image;

[0058] Step S5: Background replacement and size cropping.

[0059] Step S1 specifically includes the following steps:

[0060] Step S11: using the facial key point model to obtain the coordinates of the facial key points of the captured image, and constructing auxiliary vectors: using the left eye to the right eye as the auxiliary vector in the horizontal direction, using the eye center to the mouth center as the auxiliary vector in the vertical direction, and determining the alignment center; the direction of the auxiliary vector determines the direction of the alignment rectangular box, the modulus of the auxiliary vector determines the side length of the alignment rectangular box, and the alignment center determines the center of the alignment rectangular box, and the first stage of the telescopic face alignment operation is performed, so as to preliminarily correct the captured image in the image plane;

[0061] Step S12: Repeat step S11 on the far-view alignment image to perform the second stage of near-view standard face alignment operation; during the operation, reduce the side length of the alignment rectangle to meet the requirements of standard face alignment; and save the coordinates of the relative position of the near-view alignment image in the far-view alignment image, that is, the coordinates of the alignment rectangle.

[0062] Step S2 specifically includes: using a deep neural network to measure the horizontal deflection and vertical deflection angles of the person's head in the close-angle alignment image; and determining the next operation based on the measured deflection angles.

[0063] In step S2, the criteria for determining the next operation are: when the deflection angles in two directions are both small, the face is not rotated and step S5 is performed directly; when the deflection angle in only one direction is small, the face is not rotated in that direction and step S3 is performed sequentially; when the deflection angles in two directions are not too small and the deflection angles are within the adjustable range, step S3 is performed sequentially.

[0064] Step S3 specifically includes the following steps:

[0065] Step S31: Use a pre-trained autoencoder model to invert the near-view aligned image from the image space to the latent space to obtain an image latent code that is easy to semantically edit; the image latent code can control the semantic attributes of the generated image by compressing the image and retaining its important features, and by editing the latent code, the formula is:

[0066] C I =E(I)

[0067] Where I is the near-view aligned image, E(*) is the encoder model, and C I is the image latent code;

[0068] Step S32: Performing posture semantic editing on the image latent code using the posture information boundaries of the horizontal and vertical methods; the posture information boundaries are two binary classification boundaries in the latent space obtained by training the support vector machine, and when the latent code moves on the boundary, its posture semantic information will change accordingly; performing semantic editing on the image latent code, the formula for semantic editing is:

[0069] C o =C I +αB h +βB V

[0070] Among them, C o is the latent code after semantic editing, B h and B Vare the vector representations of the horizontal and vertical boundaries of the posture information, respectively. The parameters α and β are based on the horizontal deflection and vertical deflection angles obtained in step S3, respectively. Step S33: input the semantically edited latent code into the generator model after weight fine-tuning to generate a normalized image.

[0071] I o =G(C o )

[0072] Among them, G(*) is the generator, I o is the image after normalization;

[0073] Step S34: Use the face verification model to perform face verification on the normalized image and the collected image to ensure that the identity information of the person used for face verification remains unchanged after the face is normalized.

[0074] Step S4 specifically includes the following steps:

[0075] Step S41: using the facial key point model provided by the dlib library, determining the coordinates of the chin of the face in the normalized image;

[0076] Step S42: Use the semantic segmentation model to extract the masks of the neck area of ​​the near-view alignment image and the normalized image, and then traverse the masks to obtain the boundary points of the neck area at the height of the chin position; for the normalized image, use the transformation matrix constructed by the two sets of neck boundary point coordinates to perform an affine transformation on it, so that the texture of the transformed normalized image and the near-view alignment image in the neck area is aligned; finally, replace the pixels below the chin position of the transformed normalized image with the pixels at the same position of the near-view alignment image; the formula is:

[0077] I o '=f(I o ,A)

[0078] I o '(:,y l :,:)=I(:,y l :,:)

[0079] Among them, I o is the image after normalization, I is the near-view alignment image, and y l is the vertical coordinate of the chin of the face in the image after normalization, f(,A) is the affine transformation with A as the transformation matrix, I o ′ is the image after pixel replacement;

[0080] Step S43: using an interpolation algorithm at the chin position of the pixel-replaced image to eliminate the visual boundary effect caused by the pixel replacement operation; the interpolation algorithm first calculates the vertical interpolation weight within the interpolation area, and then performs linear interpolation on each pixel point within the interpolation area.

[0081]

[0082] I i (x,y i )=w y I o ′(x,y i )+(1-w y )I o ′(x,y i +1)

[0083] Among them, w y is the interpolation weight in the vertical direction, h is the width of the interpolation area, y i is the ordinate of the chin of the face in the image after rotation, y i is the ordinate of each pixel, x is the abscissa, I o ′ is the normalized image after pixel replacement, I i is the interpolated image;

[0084] Step S44: Based on the relative position coordinates saved in step S12, the interpolated image is stitched back to the position in the telescopic alignment image obtained in step S11.

[0085] Step S5 specifically includes the following steps:

[0086] Step S51: Use the cutout model to cut out the portrait and replace it with the required ID photo background;

[0087] Step S52: Use a face detector to detect the face area, and use a semantic segmentation model to obtain a mask of the hair area. Then, traverse the mask of the hair area to find the vertices of the hair area, and determine the length, width and vertex coordinates of the head area of ​​the person in combination with the information of the face area; adjust the upper, lower, left and right boundaries of the ID photo cropping area according to the information of the head area and the required aspect ratio of the ID photo.

[0088] The method is used to solve the problem of non-standard deviation and tilt of self-portrait images during the ID photo collection process.

[0089] The method automatically adjusts the angle of the face of the self-portrait image and performs size cropping and background replacement functions, so that the ID photo generated from the self-portrait image meets the requirements of the standard ID photo.

[0090] Example:

[0091] This embodiment provides a method for fully automatically generating a standard ID photo, which specifically includes the following steps:

[0092] Step S1: Two-stage face alignment using key point model.

[0093] Step S2: Estimate the head posture of the character and determine the next operation.

[0094] Step S3: Use a deep neural network to perform face rotation.

[0095] Step S4: Use the semantic segmentation model and interpolation algorithm to repair the transformed image.

[0096] Step S5: Background replacement and size cropping.

[0097] Preferably, in this embodiment, in step S1, in order to ensure the image quality of the output ID photo, in this embodiment, it is required that the human body in the captured image does not have a large tilt, the deflection angle of the face should not be too large, and the image clarity is high enough.

[0098] In this embodiment, step S1 specifically includes the following steps:

[0099] Step S11: Use the facial key point model to obtain the captured image (such as Figure 1 The coordinates of the key points of the face are obtained by deriving the coordinates of the key points of the face (as shown in (a) in the figure), and constructing auxiliary vectors: the auxiliary vector from the left eye to the right eye is used as the auxiliary vector in the horizontal direction, and the auxiliary vector from the center of the eye to the center of the mouth is used as the auxiliary vector in the vertical direction, and the alignment center is determined; the direction of the auxiliary vector determines the direction of the alignment rectangle, the modulus of the auxiliary vector determines the side length of the alignment rectangle, and the alignment center determines the center of the alignment rectangle, and the first stage of the telescopic face alignment operation is performed (as shown in Figure 1 , as shown in (b) in the figure).

[0100] Step S12: Repeat step S11 on the far-angle alignment image to perform the second stage of near-angle face alignment operation. The difference is that the side length of the alignment rectangle needs to be reduced (such as Figure 1 and save the coordinates of the relative position of the near-view alignment image in the far-view alignment image.

[0101] In this embodiment, step S2 specifically includes: using a deep neural network to measure the horizontal deflection and vertical deflection angles of the person's head in the close-angle alignment image; and determining the next operation based on the measured deflection angles.

[0102] In this embodiment, the judgment criteria are: when the deflection angles in two directions are small, the face is not rotated and step S5 is performed directly; when the deflection angle in one direction is small, the face is not rotated in that direction and step S3 is performed sequentially; when the deflection angles in two directions are not too small and are still within the adjustable range, step S3 is performed sequentially.

[0103] In this embodiment, step S3 specifically includes the following steps:

[0104] Step S31: Use the pre-trained autoencoder model to invert the near-view aligned image from the image space to the latent space to obtain an image latent code that is easy to semantically edit (such as Figure 2 As shown in (a) in the figure); the latent coding compresses the image and retains its important features, and the semantic properties of the generated image can be controlled by editing the latent coding.

[0105] C I =E(I)

[0106] Where I is the near-view aligned image, E(*) is the encoder model, and C I is the image latent code.

[0107] Step S32: Use the horizontal and vertical gesture information boundaries to perform gesture semantic editing on the image latent code; the gesture information boundaries are two binary classification boundaries in the latent space obtained by training the support vector machine. When the latent code moves on the boundary, its gesture semantic information will change accordingly (such as Figure 2 (b) in the figure); semantic editing of the image latent code (as shown in Figure 2 As shown in (c) in the figure), the formula for semantic editing is:

[0108] C o =C I +aB h +βB V

[0109] Among them, C o is the latent code after semantic editing, B h and B V are vector representations of the horizontal and vertical boundaries of the posture information, respectively. Parameters α and β are based on the horizontal deflection and vertical deflection angles obtained in step S3, respectively.

[0110] Step S33: Input the semantically edited latent code into the generator model after weight fine-tuning to generate a normalized image (such as Figure 2 (as shown in (d) in the figure).

[0111] I o =G(C o )

[0112] Among them, G(*) is the generator, I o This is the image after normalization.

[0113] Step S34: Use the face verification model to perform face verification on the normalized image and the collected image to ensure that the identity information of the person remains unchanged after the face is normalized.

[0114] In this embodiment, step S4 specifically includes the following steps:

[0115] Step S41: Use the facial key point model provided by the dlib library to determine the coordinates of the chin of the face in the image after rotation.

[0116] Step S42: Use the semantic segmentation model to extract the masks of the neck area of ​​the near-view alignment image and the normalized image, and then traverse the masks to obtain the boundary points of the neck area at the height of the chin position; for the normalized image, use the transformation matrix constructed by the two sets of neck boundary point coordinates to perform an affine transformation on it, so that the texture of the transformed normalized image and the near-view alignment image in the neck area is aligned. Finally, replace the pixels below the chin position of the transformed normalized image with the pixels at the same position of the near-view alignment image.

[0117] I o '=f(I o ,A)

[0118] I o '(:,y l :,:)=I(:,y l :,:)

[0119] Among them, I o is the image after normalization, I is the near-view alignment image, and y l is the vertical coordinate of the chin of the face in the image after normalization, f(,A) is the affine transformation with A as the transformation matrix, I o ′ is the image after pixel replacement.

[0120] Step S43: using an interpolation algorithm at the chin position of the pixel-replaced image to eliminate the visual "dividing line" effect caused by the pixel replacement operation; the interpolation algorithm first calculates the vertical interpolation weight within the interpolation area, and then performs linear interpolation on each pixel point within the interpolation area.

[0121]

[0122] I i (x,y i )=w y I o ′(x,y i )+(1-wy )I o ′(x,y i +1)

[0123] Among them, w y is the interpolation weight in the vertical direction, h is the width of the interpolation area, y l is the ordinate of the chin of the face in the image after rotation, y i is the ordinate of each pixel, x is the abscissa, I o ′ is the normalized image after pixel replacement, I i is the interpolated image.

[0124] Step S44: Based on the relative position coordinates saved in step S12, the interpolated image is stitched back to the position in the telescopic alignment image obtained in step S11.

[0125] In this embodiment, step S5 specifically includes the following steps:

[0126] Step S51: Use the cutout model to cut out the portrait and replace it with the required ID photo background.

[0127] Step S52: Use a face detector to detect the face area, and use a semantic segmentation model to obtain a mask of the hair area. Then, traverse the mask of the hair area to find the vertices of the hair area, and determine the length, width and vertex coordinates of the head area of ​​the person in combination with the information of the face area; adjust the upper, lower, left and right boundaries of the ID photo cropping area according to the information of the head area and the required aspect ratio of the ID photo.

[0128] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

Claims

1. A method for fully automatically generating a standard ID photo, characterized in that: First, the key points of the collected source image are calculated, and the auxiliary vectors and alignment centers are constructed to obtain the face alignment images of far and near perspectives; secondly, the head posture is estimated, and a deep neural network is used to generate the face correction image; finally, the correction image is spliced ​​into the far-perspective alignment image, repaired and cropped, to generate a standard ID photo.

2. The method for fully automatically generating a standard ID photo according to claim 1, characterized in that: The following steps are involved: Step S1: Two-stage face alignment using key point model; Step S2: Estimate the head posture of the character and determine the next operation; Step S3: Use a deep neural network to perform face correction; Step S4: Use the semantic segmentation model and interpolation algorithm to repair the transformed image; Step S5: Background replacement and size cropping.

3. The method for fully automatically generating a standard ID photo according to claim 2, characterized in that: Step S1 specifically includes the following steps: Step S11: using the facial key point model to obtain the coordinates of the facial key points of the captured image, and constructing auxiliary vectors: using the left eye to the right eye as the auxiliary vector in the horizontal direction, using the eye center to the mouth center as the auxiliary vector in the vertical direction, and determining the alignment center; the direction of the auxiliary vector determines the direction of the alignment rectangular box, the modulus of the auxiliary vector determines the side length of the alignment rectangular box, and the alignment center determines the center of the alignment rectangular box, and the first stage of the telescopic face alignment operation is performed, so as to preliminarily correct the captured image in the image plane; Step S12: Repeat step S11 on the far-view alignment image to perform the second stage of near-view standard face alignment operation; during the operation, reduce the side length of the alignment rectangle to meet the requirements of standard face alignment; and save the coordinates of the relative position of the near-view alignment image in the far-view alignment image, that is, the coordinates of the alignment rectangle.

4. The method for fully automatically generating a standard ID photo according to claim 2, characterized in that: Step S2 specifically includes: using a deep neural network to measure the horizontal deflection and vertical deflection angles of the person's head in the close-angle alignment image; and determining the next operation based on the measured deflection angles.

5. The method for fully automatically generating a standard ID photo according to claim 4, characterized in that: In step S2, the criteria for determining the next operation are: when the deflection angles in two directions are both small, the face is not rotated and step S5 is performed directly; when the deflection angle in only one direction is small, the face is not rotated in that direction and step S3 is performed sequentially; when the deflection angles in two directions are not too small and the deflection angles are within the adjustable range, step S3 is performed sequentially.

6. The method for fully automatically generating a standard ID photo according to claim 2, characterized in that: Step S3 specifically includes the following steps: Step S31: Use a pre-trained autoencoder model to invert the near-view aligned image from the image space to the latent space to obtain an image latent code that is easy to semantically edit; the image latent code can control the semantic attributes of the generated image by compressing the image and retaining its important features, and by editing the latent code, the formula is: C I =E(I) Where I is the near-view aligned image, E(*) is the encoder model, and C I is the image latent code; Step S32: Performing posture semantic editing on the image latent code using the posture information boundaries of the horizontal and vertical methods; the posture information boundaries are two binary classification boundaries in the latent space obtained by training the support vector machine, and when the latent code moves on the boundary, its posture semantic information will change accordingly; performing semantic editing on the image latent code, the formula for semantic editing is: C o =C I +αB h +βB V Among them, C o is the latent code after semantic editing, B h and B V are vector representations of the horizontal and vertical boundaries of the attitude information, respectively, and the parameters α and β are based on the horizontal deflection and vertical deflection angles obtained in step S3, respectively; Step S33: input the semantically edited latent code into the generator model after weight fine-tuning to generate a normalized image. I o =G(C o ) Among them, G(*) is the generator, I o is the image after normalization; Step S34: Use the face verification model to perform face verification on the normalized image and the collected image to ensure that the identity information of the person used for face verification remains unchanged after the face is normalized.

7. The method for fully automatically generating a standard ID photo according to claim 2, characterized in that: Step S4 specifically includes the following steps: Step S41: using the facial key point model provided by the dlib library, determine the coordinates of the chin of the face in the normalized image; Step S42: Use the semantic segmentation model to extract the masks of the neck area of ​​the near-view alignment image and the normalized image, and then traverse the masks to obtain the boundary points of the neck area at the height of the chin position; for the normalized image, use the transformation matrix constructed by the two sets of neck boundary point coordinates to perform an affine transformation on it, so that the texture of the transformed normalized image and the near-view alignment image in the neck area is aligned; finally, replace the pixels below the chin position of the transformed normalized image with the pixels at the same position of the near-view alignment image; the formula is: I o '=f(I o ,A) I o '(:,y l :,:)=I(:,y l :,:) Among them, I o is the image after normalization, I is the near-view alignment image, and y l is the vertical coordinate of the chin of the face in the image after normalization, f(,A) is the affine transformation with A as the transformation matrix, I o ′ is the image after pixel replacement; Step S43: using an interpolation algorithm at the chin position of the pixel-replaced image to eliminate the visual boundary effect caused by the pixel replacement operation; the interpolation algorithm first calculates the vertical interpolation weight within the interpolation area, and then performs linear interpolation on each pixel point within the interpolation area. I i (x,y i )=w y I o ′(x,y i )+(1-w y )I o ′(x,y i +1) Among them, w y is the interpolation weight in the vertical direction, h is the width of the interpolation area, y i is the ordinate of the chin of the face in the image after rotation, y i is the ordinate of each pixel, x is the abscissa, I o ′ is the normalized image after pixel replacement, I i is the interpolated image; Step S44: Based on the relative position coordinates saved in step S12, the interpolated image is stitched back to the position in the telescopic alignment image obtained in step S11.

8. The method for fully automatically generating a standard ID photo according to claim 2, characterized in that: Step S5 specifically includes the following steps: Step S51: Use the cutout model to cut out the portrait and replace it with the required ID photo background; Step S52: Use a face detector to detect the face area, and use a semantic segmentation model to obtain a mask of the hair area. Then, traverse the mask of the hair area to find the vertices of the hair area, and determine the length, width and vertex coordinates of the head area of ​​the person in combination with the information of the face area; adjust the upper, lower, left and right boundaries of the ID photo cropping area according to the information of the head area and the required aspect ratio of the ID photo.

9. The method for fully automatically generating a standard ID photo according to claim 2, characterized in that: The method is used to solve the problem of non-standard deviation and tilt of self-portrait images during the ID photo collection process.

10. The method for fully automatically generating a standard ID photo according to claim 9, characterized in that: The method automatically adjusts the angle of the face of the self-portrait image and performs size cropping and background replacement functions, so that the ID photo generated from the self-portrait image meets the requirements of the standard ID photo.

Citation Information

Patent Citations

  • Identification photo generation and detection method and system based on intelligent three-dimensional portrait acquisition

    CN115620364A

  • Method and apparatus for taking identification photo, device and storage medium

    WO2021027537A1

  • Semantic segmentation-based face integrity measurement method and system, device and storage medium

    WO2022222766A1

Cited By

  • Automatic image cutting method and system based on face key points

    CN121330005A

  • Image automatic cropping method and system based on face key points

    CN121330005B