A method for automatically generating a standard ID photo

By using a fully automated method to generate standard ID photos, key point calculation and deep neural networks are used to generate face-aligned images. Combined with semantic segmentation models and interpolation algorithms for repair and cropping, the problem of face offset in selfie images is solved, and standardized generation of ID photos is achieved.

CN119763170BActive Publication Date: 2026-01-16FUZHOU UNIV +1
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Existing online ID photo generation systems cannot effectively solve the problem of facial misalignment in user selfies, resulting in generated ID photos that do not meet standards.

Method used

A fully automated method for generating standard ID photos is adopted. This method generates face-corrected images through key point calculation, head pose estimation, and deep neural networks. It also combines semantic segmentation models and interpolation algorithms for repair and cropping, achieving background replacement and size adjustment.

Benefits of technology

It automatically adjusts the angle of the face and performs size cropping to generate standard ID photos, solving the problems of selfie image offset and non-standardization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119763170B_ABST
    Figure CN119763170B_ABST
Patent Text Reader

Abstract

The application provides a method for automatically generating a standard ID photo, which comprises the following steps: firstly, key point calculation is performed on a source image, an auxiliary vector and an alignment center are constructed, and a far-view and a near-view face alignment image are obtained; secondly, head posture estimation is performed, and a deep neural network is used to generate a face front image; finally, the face front image is spliced into the far-view face alignment image, and repair and cutting are performed to generate a standard ID photo; the application can obtain an ID photo meeting the face authentication requirement standard through processing of a selfie, and can automatically adjust the angle of the face, and simultaneously realize the functions of size cutting and background replacement, so that the generated ID photo meets the requirement of a standard ID photo.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

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

[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 photo studios to complete the shooting in a fixed color background, and then a long post-processing time is required to obtain the ID photo. Through the current ID photo generation system on the market, users only need to take a photo of themselves using a mobile phone and input the picture containing the user's portrait into the system, and the system can generate a standard ID photo for the user by replacing the background and cutting the ID photo. Compared with the traditional method, this method makes the acquisition of ID photos no longer limited by time and place, and users can obtain customized ID photos according to their needs. However, due to the constraints of the shooting environment and shooting skills, in most cases, the photos taken by users cannot meet the requirements of standard ID photos, so the ID photos need to be processed to meet the standard.

[0003] The above-mentioned processing of the user's selfie photo to meet the standard of ID photo is a challenging task. The existing online ID photo APP or small program can only replace the background and cut the ID photo of the input picture, and cannot solve the problem of non-standard user shooting ID photos. The most important problem is that when the user takes a selfie, the face is shifted left or right or up and down due to technical reasons. SUMMARY

[0004] The present application proposes a method for automatically generating a standard ID photo, which can obtain an ID photo meeting the requirements of face authentication by processing a selfie, automatically adjust the angle of the face, and realize the functions of size cutting and background replacement to generate an ID photo meeting the requirements of a standard ID photo.

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

[0006] A method for automatically generating a standard ID photo, which first calculates key points of a source image, constructs an auxiliary vector and an alignment center, and obtains a face alignment image at a far and near angle; secondly, estimates the head posture and generates a face front image using a deep neural network; and finally, splices the front image into the far-angle alignment image, performs repair and cutting, and generates a standard ID photo.

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

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

[0009] Step S2: estimate the head pose of the person, determine the next operation;

[0010] Step S3: face frontalization using deep neural network;

[0011] Step S4: repair the frontalized image using semantic segmentation model and interpolation algorithm;

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

[0013] Step S1 specifically comprises the following steps:

[0014] Step S11: obtain the face key point coordinates of the collected image using the face key point model, and construct an auxiliary vector: take the left eye to the right eye as the auxiliary vector in the horizontal direction, take the eye center to the mouth center as the auxiliary vector in the vertical direction, and determine the alignment center; the direction of the auxiliary vector determines the direction of the alignment rectangular frame, the modulus of the auxiliary vector determines the side length of the alignment rectangular frame, and the alignment center determines the center of the alignment rectangular frame, to perform the first-stage far-view-angle face alignment operation, thereby preliminarily correcting the collected image in the image plane;

[0015] Step S12: repeat step S11 on the far-view-angle aligned image to perform the second-stage near-view-angle standard face alignment operation; when operating, the side length of the alignment rectangular frame is reduced to meet the requirements of the standard face alignment; and save the coordinates of the relative position of the near-view-angle aligned image in the far-view-angle aligned image, that is, the coordinates of the alignment rectangular frame.

[0016] Step S2 specifically comprises: using a deep neural network to measure the horizontal deflection and vertical deflection angles of the head of the person in the near-view-angle aligned image; and determining the next operation according to the measured deflection angles.

[0017] In step S2, the standard for determining the next operation is: when the deflection angles in both directions are small, do not perform face frontalization, and directly proceed to step S5; when the deflection angle in only one direction is small, do not perform face frontalization in that direction, and sequentially proceed to step S3; when the deflection angles in both directions are not small, and the deflection angles are within an adjustable range, sequentially proceed to step S3.

[0018] Step S3 specifically comprises the following steps:

[0019] Step S31: use a pre-trained auto-encoder model to reverse the near-view-angle aligned image from the image space to the latent space, to obtain an image latent code that is easy to perform semantic editing; the image latent code can control the semantic attributes of the generated image by editing the latent code through compression of the image while preserving its important features, and the formula is:

[0020] C I = E(I)

[0021] where I is the myopic angle alignment image, E(*) is the encoder model, C I is the image latent code;

[0022] Step S32: using the pose information boundary of the horizontal and vertical method to edit the pose semantics of the image latent code; the pose information boundary is obtained by training two binary classification boundaries in the latent space using a support vector machine, when the latent code moves on the boundary, its pose semantic information will change; the semantic editing formula of the image latent code is:

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

[0024] where C o is the semantic edited latent code, B h and B V are the vector representations of the horizontal and vertical boundaries of the pose information, and parameters α and β are based on the horizontal and vertical deflection angles obtained in step S3; step S33: input the semantic edited latent code into the generator model with weight fine-tuning to generate the orthotropic image.

[0025] I o = G(C o )

[0026] where G(*) is the generator, and I o is the orthotropic image;

[0027] Step S34: using a face verification model to verify the face of the orthotropic image and the collected image, to ensure that the identity information of the person used for face verification does not change after face orthotropism.

[0028] Step S4 specifically includes the following steps:

[0029] Step S41: using the face key point model provided by the dlib library to determine the coordinates of the chin of the face in the orthotropic image;

[0030] Step S42: Use a semantic segmentation model to extract the mask of the neck region in the near-view aligned image and the straightened image. Then, traverse the mask to obtain the neck region boundary points at the chin height. For the straightened image, perform an affine transformation using a transformation matrix constructed from the coordinates of the two sets of neck boundary points, ensuring that the texture of the transformed straightened image is aligned with the near-view aligned image in the neck region. Finally, replace the pixels below the chin position in the transformed straightened image with the pixels at the same position in the near-view aligned image. The formula is:

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

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

[0033] Among them, I o This is the image after straightening; I is the close-up aligned image; y... l It is the ordinate of the chin of the face in the image after straightening, f(,A) is the affine transformation with A as the transformation matrix, I o ' is the image after pixel replacement;

[0034] Step S43: Use an interpolation algorithm at the chin position of the pixel-replaced image to eliminate the visual boundary line effect caused by the pixel replacement operation; the interpolation algorithm first calculates the vertical interpolation weight in the interpolation area, and then performs linear interpolation on each pixel in 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 The vertical interpolation weights are h and y. l It is the y-coordinate of the chin of the face in the image after it has been corrected. i x is the ordinate of each pixel, and x is the abscissa. o ′ is the corrected image after pixel replacement, I i It is the interpolated image;

[0038] Step S44: Based on the relative position coordinates saved in step S12, stitch the interpolated image back to the position in the far-view aligned 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 region and use a semantic segmentation model to obtain the mask of the hair region. Then, traverse the mask of the hair region to find the vertices of the hair region and combine the information of the face region to determine the length, width and vertex coordinates of the person's head region. Adjust the top, bottom, left and right boundaries of the ID photo cropping area according to the information of the head region and the aspect ratio of the required ID photo.

[0042] The method described above is used to solve the problem of non-standard self-taken images being skewed or tilted during the ID photo collection process.

[0043] The method automatically adjusts the angle of the face in the selfie image and performs size cropping and background replacement functions to make the ID photo generated from the selfie image meet the requirements of a standard ID photo.

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

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

[0046] Appendix Figure 1 This is a schematic diagram of the two-stage face alignment implementation in an embodiment of the present invention (part a is a schematic diagram of the acquired image, part b is a schematic diagram of the far-view face alignment in the first stage, and part c is a schematic diagram of the near-view face alignment in the second stage).

[0047] Appendix Figure 2 This is a flowchart of the algorithm implementation from close-view aligned image to upright image in an embodiment of the present invention (part a is an illustration of image reflection, part b is an illustration of pose semantic information boundary, part c is an illustration of latent coding editing, and part d is an illustration of image reconstruction).

[0048] Appendix Figure 3 This is a flowchart illustrating the present invention. Detailed Implementation

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

[0050] It should be noted that the following detailed description is exemplary in nature and is intended to provide further description of the application. Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs.

[0051] It is also important to note that the terms "or" and "and" as used herein, unless otherwise indicated, are used to mean either phonetic "or", that is, any or all possible combinations of one or more items listed with the terms, or phonetic "and" that is, any combination of one or more items listed with the term. As used herein, the term "about" means that quantities, dimensions, and other parameters are not exact, but have a value that approaches the specified value and can include the specified value.

[0052] As shown in the figure, a method for automatically generating a standard ID photo, first, the key point calculation is performed on the collected source image, the auxiliary vector and the alignment center are constructed, and the far and near angle face alignment images are obtained; second, the head pose estimation is performed, and the deep neural network is used to generate the face front image; finally, the front image is spliced into the far angle alignment image, and the repair and cutting are performed to generate the standard ID photo.

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

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

[0055] Step S2: estimate the head pose of the person and determine the next operation;

[0056] Step S3: face front using deep neural network;

[0057] Step S4: repair the front image using semantic segmentation model and interpolation algorithm;

[0058] Step S5: background replacement and size cutting.

[0059] Step S1 specifically includes the following steps:

[0060] Step S11: use the face key point model to obtain the face key point coordinates of the collected image, and construct the auxiliary vector: take the left eye to the right eye as the horizontal direction auxiliary vector, take the eye center to the mouth center as the vertical direction auxiliary vector, and determine the alignment center; the direction of the auxiliary vector determines the direction of the alignment rectangular frame, the modulus of the auxiliary vector determines the side length of the alignment rectangular frame, and the alignment center determines the center of the alignment rectangular frame, and the first stage of the far angle face alignment operation is performed, so as to preliminarily correct the collected image in the image plane;

[0061] Step S12: repeating step S11 on the far vision angle aligned image, performing a second stage of near vision angle standard face alignment operation; when operating, the side length of the alignment rectangular frame is reduced to meet the requirements of standard face alignment; and the coordinates of the relative position of the near vision angle aligned image in the far vision angle aligned image, i.e. the coordinates of the alignment rectangular frame, are saved.

[0062] Step S2 specifically comprises: using a deep neural network to measure the horizontal deflection and vertical deflection angles of the head of the person in the near vision angle aligned image; and determining the next operation according to the measured deflection angles.

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

[0064] Step S3 specifically comprises the following steps:

[0065] Step S31: using a pre-trained auto-encoder model to reverse the near vision angle aligned image from the image space to the latent space, obtaining an image latent code that is easy to perform semantic editing; the image latent code can control the semantic attributes of the generated image by editing the latent code by compressing the image and retaining its important features, and the formula is:

[0066] C I =E(I)

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

[0068] Step S32: using the pose information boundary of the horizontal direction and the vertical method to perform pose semantic editing on the image latent code; the pose information boundary is obtained by training a support vector machine, which is two binary boundaries in the latent space, when the latent code moves on the boundary, its pose semantic information will change; the image latent code is semantically edited, and the formula for semantic editing is:

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

[0070] Where C o is the latent code after semantic editing, B h and B Vrespectively, are vector representations of the horizontal and vertical boundaries of the pose information, and parameters a and b are based on the horizontal and vertical deflection angles obtained in step S3 respectively; step S33: input the semantic edited latent code into the generator model after weight fine-tuning to generate the rectified image.

[0071] I o = G(C o )

[0072] where G(*) is a generator, I o is the rectified image;

[0073] Step S34: use the face verification model to perform face verification on the rectified image and the collected image to ensure that the identity information of the person used for face verification does not change after face rectification.

[0074] Step S4 specifically includes the following steps:

[0075] Step S41: use the face key point model provided by the dlib library to determine the coordinates of the chin in the rectified image;

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

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

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

[0079] where I o is the rectified image, I is the near-view angle alignment image, y l is the vertical coordinate of the chin of the rectified image, f(, A) is an affine transformation with A as the transformation matrix, and I o ' is the image after pixel replacement;

[0080] Step S43: using an interpolation algorithm to eliminate the visual boundary line caused by the pixel replacement operation at the chin position of the image after pixel replacement; the interpolation algorithm is to first calculate the vertical interpolation weight in the interpolation region, and then perform linear interpolation on each pixel point in the interpolation region.

[0081]

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

[0083] wherein w y is the vertical interpolation weight, h is the width of the interpolation region, y i is the vertical coordinate of the chin of the upright image, y i is the vertical coordinate of each pixel point, x is the horizontal coordinate, I o ′ is the upright image after pixel replacement, and I i is the interpolated image.

[0084] Step S44: according to the relative position coordinates saved in step S12, splice the interpolated image back to the position in the far-view angle alignment image obtained in step S11.

[0085] Step S5 specifically includes the following steps:

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

[0087] Step S52: use the face detector to detect the face region, and use the semantic segmentation model to obtain the mask of the hair region, then traverse the mask of the hair region to find the top point of the hair region, and determine the length, width and top point coordinates of the head region of the figure in combination with the information of the face region; adjust the upper, lower, left and right boundaries of the ID photo cropping region according to the information of the head region and the aspect ratio of the required ID photo.

[0088] The method is used to solve the problem of non-standard selfie images in the process of ID photo collection,

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

[0090] Embodiment:

[0091] This embodiment provides a method for automatically generating standard ID photos, specifically including the following steps:

[0092] Step S1: Perform two-stage face alignment using a keypoint model.

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

[0094] Step S3: Use a deep neural network to straighten the face.

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

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

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

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

[0099] Step S11: Obtain the acquired image using a facial landmark model (e.g., Figure 1 The coordinates of the facial key points shown in (a) are determined, and auxiliary vectors are constructed: the horizontal auxiliary vector is from the left eye to the right eye, and the vertical auxiliary vector is from the center of the eye to the center of the mouth. The alignment center is also determined. The direction of the auxiliary vectors determines the direction of the alignment rectangle, the magnitude of the auxiliary vectors determines the side length of the alignment rectangle, and the alignment center determines the center of the alignment rectangle. The first stage of far-view face alignment is then performed (e.g., ...). Figure 1 (as shown in (b)).

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

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

[0102] In this embodiment, the judgment criteria are as follows: when the deflection angles in both directions are small, face straightening is not performed, and step S5 is performed directly; when the deflection angle in one direction is small, face straightening is not performed in that direction, and step S3 is performed sequentially; when the deflection angles in both 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: Using a pre-trained autoencoder model, the near-viewpoint aligned image is inverted from the image space to the latent space to obtain an image latent code that is easy to semantically edit (e.g., ...). Figure 2 As shown in (a)); the latent coding compresses the image while preserving its important features, and the semantic attributes 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 It is image latent coding.

[0107] Step S32: Perform pose semantic editing on the image latent code using pose information boundaries obtained from horizontal and vertical methods; the pose information boundaries are two binary classification boundaries in the latent space obtained by training a support vector machine. When the latent code moves along the boundaries, its pose semantic information changes accordingly (e.g., ...). Figure 2 (as shown in (b)); semantic editing of the image latent code (such as...) 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 It is the latent encoding after semantic editing, B h and B V These are the vector representations of the horizontal and vertical boundaries of the attitude information, respectively, with parameters α and β based on the horizontal and vertical deflection angles obtained in step S3, respectively.

[0110] Step S33: Input the semantically edited latent code into the generator model with fine-tuned weights to generate the corrected image (e.g., ...). Figure 2 (as shown in (d)).

[0111] I o =G(C o )

[0112] where G(*) is a generator, I o is the frontal image.

[0113] Step S34: face verification is performed on the frontal image and the collected image using a face verification model, to ensure that the identity information of the person in the frontal image is unchanged.

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

[0115] Step S41: a face key point model provided by a dlib library is used to determine the coordinates of the chin of the face in the frontal image.

[0116] Step S42: a semantic segmentation model is used to extract masks of the neck region of the near-view angle alignment image and the frontal image, and then the masks are traversed respectively to obtain boundary points of the neck region at the height of the chin; for the frontal image, an affine transformation is performed on it using a transformation matrix constructed by two groups of neck boundary point coordinates, so that the textures of the transformed frontal image and the near-view angle alignment image on the neck region are aligned. Finally, the pixels below the chin position of the transformed frontal image are replaced by the pixels at the same position of the near-view angle alignment image.

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

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

[0119] where I o is the frontal image, I is the near-view angle alignment image, y l is the vertical coordinate of the chin of the face in the frontal image, f(, A) is an affine transformation with A as the transformation matrix, and I o ' is the image after pixel replacement.

[0120] Step S43: an interpolation algorithm is used to eliminate the visual "division line" effect caused by the pixel replacement operation at the chin position of the image after pixel replacement; the interpolation algorithm is to first calculate the vertical interpolation weight in the interpolation region, and then perform linear interpolation on each pixel point in the interpolation region.

[0121]

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

[0123] wherein w y is the interpolation weight in the vertical direction, h is the width of the interpolation region, y l is the vertical coordinate of the chin of the face in the rectified image, y i is the vertical coordinate of each pixel, x is the horizontal coordinate, I o ′ is the rectified image after replacing the pixels, and I i is the interpolated image.

[0124] Step S44: according to the relative position coordinates saved in step S12, the interpolated image is spliced back to the position in the far-view angle alignment image obtained in step S11.

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

[0126] Step S51: the portrait is cut out using a cutout model, and the required background of the ID photo is replaced.

[0127] Step S52: the face region is detected using a face detector, and a mask of the hair region is obtained using a semantic segmentation model, then the vertex of the hair region is found by traversing the mask of the hair region, and the length, width and vertex coordinates of the head region of the figure are determined in combination with the information of the face region; the upper, lower, left and right boundaries of the ID photo cutting region are adjusted according to the information of the head region and the length-width ratio of the required ID photo.

[0128] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system or a computer program product. Therefore, the present application can adopt a completely hardware embodiment, a completely software embodiment or an embodiment combining software and hardware aspects. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer usable storage media containing computer usable program codes (including but not limited to disk storage, CD-ROM, optical storage, etc.).

Claims

1. A method for automatically generating a standard ID photo, characterized in that: First, the key point calculation is performed on the collected source image, an auxiliary vector and an alignment center are constructed, and a face alignment image of far and near view angles is obtained; Secondly, head pose estimation is performed, and a deep neural network is used to generate a face frontal image; finally, the frontal image is spliced into the far view angle alignment image, repaired and cropped to generate a standard ID photo; The method comprises the following steps: Step S1: two-stage face alignment using a key point model; Step S2: estimating the head pose of the person and determining the next operation; Step S3: using a deep neural network to perform face frontalization; Step S4: repairing the frontal image using a semantic segmentation model and an interpolation algorithm; Step S5: background replacement and size cropping; Step S3 specifically comprises the following steps: Step S31: using a pre-trained autoencoder model to reverse the near view angle alignment image from the image space to the latent space to obtain an image latent code that is easy to perform semantic editing; the image latent code can control the semantic attributes of the generated image by editing the latent code through compression of the image while retaining its important features, and the formula is: C I = E(I) where I is the myopic angle alignment image, E(*) is the encoder model, C I is the image latent encoding; Step S32: using the pose information boundary of the horizontal and vertical methods to perform pose semantic editing on the image latent code; the pose information boundary is obtained by training a support vector machine, and when the latent code moves on the boundary, its pose semantic information will change; the formula for semantic editing of the image latent code is: C o = C I + αB h + βB V where C o is the latent encoding after semantic editing, B h and B V are the vector representation of the horizontal and vertical boundaries of the pose information, respectively, and parameters a and b are based on the horizontal and vertical deflection angles obtained in step S3, respectively. Step S33: inputting the semantic edited latent code into the generator model with weight fine-tuning to generate a frontal image, I o = G(C o ) where G(*) is a generator, I o is the rotated image; Step S34: using a face verification model to perform face verification on the frontal image and the collected image to ensure that the identity information of the person used for face verification does not change after face frontalization; Step S4 specifically comprises the following steps: Step S41: using a face key point model provided by the dlib library to determine the coordinates of the chin in the frontal image; Step S42: using a semantic segmentation model to extract the mask of the neck region of the near view angle alignment image and the frontal image, and then traversing the masks respectively to obtain the boundary points of the neck region at the chin position height; for the frontal image, an affine transformation is performed using the transformation matrix constructed by the two groups of neck boundary point coordinates, so that the textures of the transformed frontal image and the near view angle alignment image are aligned in the neck region; finally, the pixels below the chin position of the transformed frontal image are replaced with the same position pixels of the near view angle alignment image; the formula is: I o '=f(I o ,A) I o '(:,y l :,:)=I(:,y l :,:) wherein I o is the rectified image, I is the near angle aligned image, y l is the vertical coordinate of the chin of the rectified image, f(A) is an affine transformation with A as the transformation matrix, I o ′ is the image after pixel replacement; Step S43: using an interpolation algorithm to eliminate the visual dividing line caused by the pixel replacement operation at the chin position of the pixel replaced image; the interpolation algorithm is to first calculate the vertical direction interpolation weight in the interpolation region, and then perform linear interpolation on each pixel point in the interpolation region, I i (x, y i ) = w y I o ′(x,y i )+(1-w y )I o ′(x,y i +1) wherein w y is the interpolation weight in the vertical direction, h is the width of the interpolation region, y l is the vertical coordinate of the chin of the face in the rectified image, y i is the vertical coordinate of the pixel, x is the horizontal coordinate, I o ' is the rectified image after pixel replacement, I i is the interpolated image; Step S44: according to the relative position coordinates saved in step S12, the interpolated image is spliced back to the position in the far view angle alignment image obtained in step S11.

2. The method for automatically generating a standard ID photo entirely automatically according to claim 1, characterized in that: Step S1 specifically comprises the following steps: Step S11: using a face key point model to obtain face key point coordinates of the collected image, and constructing an auxiliary vector: taking the left eye to the right eye as the horizontal direction auxiliary vector, and taking the eye center to the mouth center as the vertical direction auxiliary vector, and determining the alignment center; the direction of the auxiliary vector determines the direction of the alignment rectangular frame, the modulus of the auxiliary vector determines the side length of the alignment rectangular frame, and the alignment center determines the center of the alignment rectangular frame, to perform a first-stage far-view-angle face alignment operation, so as to preliminarily correct the collected image in the image plane; Step S12: repeating step S11 on the far-view-angle aligned image to perform a second-stage near-view-angle standard face alignment operation; when operating, the side length of the alignment rectangular frame is reduced to meet the requirements of the standard face alignment; and the coordinates of the relative position of the near-view-angle aligned image in the far-view-angle aligned image, that is, the coordinates of the alignment rectangular frame, are saved.

3. The method for automatically generating a standard ID photo entirely automatically according to claim 1, characterized in that: Step S2 specifically comprises: using a deep neural network to measure the horizontal deflection and vertical deflection angles of the head of the person in the near-view-angle aligned image; and determining the next operation according to the measured deflection angles.

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

5. The method for automatically generating a standard ID photo entirely automatically according to claim 1, characterized in that: Step S5 specifically comprises the following steps: Step S51: using a matting model to cut out the portrait and replace it with the required background of the ID photo; Step S52: using a face detector to detect the face region, and using a semantic segmentation model to obtain a mask of the hair region, then traversing the mask of the hair region to find the top point of the hair region, and combining the information of the face region to determine the length, width and top point coordinates of the head region of the person; according to the information of the head region and the aspect ratio of the required ID photo, adjusting the upper, lower, left and right boundaries of the ID photo cutting region.

6. The method for automatically generating a standard ID photo entirely automatically according to claim 1, characterized in that: The method is used to solve the problem of non-standard selfie images in the process of collecting ID photos.

7. The method for automatically generating a standard ID photo entirely automatically according to claim 6, characterized in that: The method automatically adjusts the angle of the face of the selfie image, and performs size cutting and background replacement functions, so that the ID photo generated from the selfie image meets the requirements of the standard ID photo.

Citation Information

Patent Citations

  • 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