Distortion correction method and device and storage medium

By calculating the distortion correction confidence based on the object detection frame and center point during the selfie process, combined with optical and electronic anti-shake technology, and correcting the deformation grid frame by frame, the problem of image distortion and jelly effect caused by distortion during the selfie process is solved. for natural image correction effects.

CN118828232APending Publication Date: 2024-10-22BEIJING XIAOMI MOBILE SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310416832.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-04-18
Publication Date
2024-10-22

AI Technical Summary

Technical Problem

In the existing technology, during the selfie process, distortion introduced by lens manufacturing precision and assembly process deviations causes image distortion, and the distortion correction method has an obvious jelly effect, resulting in unnatural phenomena such as image stretching and holes.

Method used

By determining the object detection frame and object center of the object to be distorted, calculate the distortion correction confidence based on the object center point in the previous and subsequent frame images, remove the rolling shutter effect and lens distortion, and use a specific algorithm to combine optical and electronic anti-shake technology. The deformation mesh is corrected frame by frame to ensure that the object is de-distorted and the jelly effect is avoided.

Benefits of technology

It realizes the natural distortion correction of the object during the selfie process, avoids unnatural stretching and hollowing of the image, and ensures the effective removal of the jelly effect of the background, providing continuous and jump-free correction results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118828232A_ABST
    Figure CN118828232A_ABST
Patent Text Reader

Abstract

The invention relates to a distortion correction method and device and a storage medium. The method comprises the following steps: determining a corresponding object detection frame of an object to be subjected to distortion correction in an image and an object center of the object in the object detection frame; based on the object center points in the (i-1) th frame of image and the ith frame of image, determining the distortion correction confidence coefficient for performing distortion correction mapping on the object to a deformation grid in the image; the ith frame of image to be subjected to distortion correction is obtained, a to-be-corrected deformation grid in the image is obtained and serves as a first deformation grid, the rolling shutter effect of the first deformation grid is removed, a second deformation grid is obtained, and the first deformation grid is a grid obtained after optical image stabilization and lens distortion correction are conducted on the ith frame of image to be subjected to distortion correction; based on the distortion correction confidence, the first deformation grid and the second deformation grid, determining a third deformation grid without distortion correction; and carrying out distortion correction on the object in the ith frame of image based on the third deformation grid. According to the invention, distortion in the image is effectively removed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of EIS technology for terminal cameras, and in particular to a distortion correction method, device and storage medium. Background Art

[0002] With the development of smart terminals, users have higher and higher requirements for terminals with shooting functions. However, when users take selfies, distortion will be introduced due to deviations in lens manufacturing accuracy and assembly process, resulting in distortion of the original image.

[0003] In the related art, the distance between the camera and the face is generally used to determine a threshold. When the distance is above the threshold, face distortion correction is performed based on the distance, or face distortion is removed by separately correcting the foreground and background and then fusing them.

[0004] However, the image corrected by the above method will have obvious jello effect, unnatural stretching, holes and other phenomena. Summary of the invention

[0005] In order to overcome the problems existing in the related art, the present disclosure provides a distortion correction method, device and storage medium.

[0006] According to a first aspect of an embodiment of the present disclosure, a distortion correction method is provided, comprising: determining an object detection frame corresponding to an object to be distorted and corrected in an image, and an object center of the object in the object detection frame; determining a distortion correction confidence of a distortion correction mapped to a deformed mesh for the object in the i-th frame image based on the object center point in the i-1th frame image and the object center point in the i-th frame image; acquiring an i-th frame image to be distorted and corrected, obtaining a deformed mesh to be corrected in the i-th frame image to be distorted and corrected as a first deformed mesh, and removing a rolling shutter effect from the first deformed mesh to obtain a second deformed mesh, wherein the first deformed mesh is a mesh obtained after optical image stabilization and lens distortion correction are performed on the i-th frame image to be distorted and corrected; determining a third deformed mesh from which the distortion correction is removed based on the distortion correction confidence, the first deformed mesh and the second deformed mesh; and performing distortion correction on the object in the i-th frame image based on the third deformed mesh.

[0007] In one embodiment, the method of determining the distortion correction confidence of the object in the i-th frame image mapped to the deformable mesh by performing distortion correction on the object based on the center point of the object in the i-1th frame image and the center point of the object in the i-th frame image includes: determining the global initial distortion correction confidence of the object based on the center point of the object in the i-1th frame image and the center point of the object in the i-th frame image; determining the distortion correction confidence of the object in the i-th frame image mapped to the deformable mesh by performing distortion correction on the object based on the global initial distortion correction confidence and the discount factor of the grid point; the discount factor of the grid point is used to correct the distortion correction confidence of the grid point corresponding to it.

[0008] In one embodiment, the determining of the global initial distortion correction confidence of the object based on the object center point in the i-1th frame image and the object center point in the i-th frame image includes: obtaining an external parameter matrix corresponding to an object detection frame in the i-th frame image based on the object center point in the i-1th frame image and the object center point in the i-th frame image; obtaining a motion matrix of the object center point from the i-1th frame image to the i-th frame based on the projection position of the object detection frame in the i-1th frame image, the imaging exposure times corresponding to the object center point in the i-1th frame image and the image to be distorted and corrected where the object center point in the i-th frame image is located, and the external parameter matrix corresponding to the i-th frame object detection frame; determining a first object distortion correction confidence of the object detection frame based on the object center point in the i-1th frame image, the object center point of the i-th frame, and the motion matrix of the object center point from the i-1th frame image to the i-th frame.

[0009] In one embodiment, the discount factor of the grid point is determined in the following manner: the Euclidean distance between the grid point and the center point of the object is determined; if the Euclidean distance is less than or equal to the first distance, the discount factor is 1; if the Euclidean distance is greater than the first distance and less than or equal to the second distance, the discount factor is

[0010]

[0011] Among them, con2_discount i,j is the discount factor, BUFFER IEN is the parameter factor, dist is the Euclidean distance, and totalConRangeLen is the distance between the two vertices of the object detection box; if the Euclidean distance is greater than the second distance, the discount factor is 0; the first distance is the distance between the two vertices of the object detection box, and the second distance is the sum of the distance between the two vertices of the object detection box and the parameter factor.

[0012] In one embodiment, the determining a third deformed mesh from which the distortion correction is removed based on the distortion correction confidence, the first deformed mesh, and the second deformed mesh comprises: determining the third deformed mesh from which the distortion correction is removed based on the distortion correction confidence, the first deformed mesh, and the second deformed mesh according to the following formula:

[0013] grid final(i,j) =grid afterRSC(i,j) ×(1-final coni,j )+grid org(i,j) ×final coni,j

[0014] Among them, grid org(i,j) is the first deformed grid, grid afterRSC(i,j) For the second deformed mesh, grid final(i,j) is the third deformed mesh, final coni,j A confidence score is calculated for the distortion.

[0015] According to a second aspect of an embodiment of the present disclosure, a distortion correction device is provided, comprising: a determination module, used to determine an object detection frame corresponding to an object to be distorted and corrected in an image, and an object center of the object in the object detection frame; based on the object center point in the i-1 frame image and the object center point in the i-th frame image, determining a distortion correction confidence of the object in the i-th frame image mapped to a deformed mesh for distortion correction; an acquisition module, used to acquire the i-th frame image to be distorted and corrected, obtain the deformed mesh to be corrected in the i-th frame image to be distorted and corrected as a first deformed mesh, and remove a rolling shutter effect from the first deformed mesh to obtain a second deformed mesh, wherein the first deformed mesh is a mesh obtained after optical image stabilization and lens distortion correction are performed on the i-th frame image to be distorted and corrected; a processing module, used to determine a third deformed mesh from which the distortion correction is removed based on the distortion correction confidence, the first deformed mesh and the second deformed mesh; and based on the third deformed mesh, perform distortion correction on the object in the i-th frame image.

[0016] In one embodiment, the determination module determines the distortion correction confidence of the object in the i-th frame image mapped to the deformable mesh based on the center point of the object in the i-1th frame image and the center point of the object in the i-th frame image in the following manner: based on the center point of the object in the i-1th frame image and the center point of the object in the i-th frame image, determine the global initial distortion correction confidence of the object; based on the global initial distortion correction confidence and the discount factor of the grid point, determine the distortion correction confidence of the object in the i-th frame image mapped to the deformable mesh; the discount factor of the grid point is used to correct the distortion correction confidence of the grid point corresponding to it.

[0017] In one embodiment, the determination module determines the global initial distortion correction confidence of the object based on the object center point in the i-1th frame image and the object center point in the i-th frame image in the following manner: based on the object center point in the i-1th frame image and the object center point in the i-th frame image, obtain the external parameter matrix corresponding to the object detection frame in the i-1th frame image; based on the projection position of the object detection frame in the i-1th frame image, the imaging exposure time corresponding to the object center point in the i-1th frame image and the image to be distorted and corrected where the object center point in the i-1th frame image is located, and the external parameter matrix corresponding to the i-th frame object detection frame, obtain the motion matrix of the object center point from the i-1th frame image to the i-th frame; based on the object center point in the i-1th frame image, the object center point of the i-th frame and the motion matrix of the object center point from the i-1th frame image to the i-th frame, determine the first object distortion correction confidence of the object detection frame.

[0018] According to a third aspect of an embodiment of the present disclosure, a distortion correction device is provided, comprising: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to: execute the distortion correction method described in the first aspect or any one of the implementations of the first aspect.

[0019] According to a fourth aspect of an embodiment of the present disclosure, a storage medium is provided, in which instructions are stored. When the instructions in the storage medium are executed by a processor of a terminal, the terminal is enabled to execute any one of the aforementioned distortion correction methods.

[0020] The technical solution provided by the embodiment of the present disclosure may include the following beneficial effects: by determining the object detection frame corresponding to the object to be distorted and corrected in the image, and the object center of the object in the object detection frame, based on the object center point in the i-1 frame image and the object center point in the i frame image, the distortion correction confidence of the distortion correction mapped to the deformed mesh for the object in the i frame image is determined. Further, the i frame image to be distorted and corrected is obtained, and the deformed mesh to be corrected in the i frame image to be distorted and corrected is obtained as the first deformed mesh, and the rolling shutter effect is removed from the first deformed mesh to obtain the second deformed mesh, and the first deformed mesh is the mesh obtained after the i frame image to be distorted and corrected by optical image stabilization and lens distortion correction. Further, based on the distortion correction confidence, the first deformed mesh and the second deformed mesh, a third deformed mesh to remove the distortion correction is determined, and a deformed mesh without distortion is finally obtained through the present disclosure, and based on the third deformed mesh, the object in the i frame image is distorted and corrected, and the jello effect of the background is effectively removed while the foreground is dedistorted.

[0021] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0023] Figure 1 The figure is a flow chart of a distortion correction method according to an exemplary embodiment.

[0024] Figure 2 The flowchart is a method for determining a distortion correction confidence of an object in an i-th frame image mapped to a deformable mesh according to another exemplary embodiment of the present disclosure.

[0025] Figure 3 The present invention is a flowchart showing a method for determining a global initial distortion correction confidence of an object according to another exemplary embodiment of the present invention.

[0026] Figure 4 The figure is a flow chart showing a method of determining a discount factor of a grid point according to another exemplary embodiment of the present disclosure.

[0027] FIG5( a ) is a flowchart showing a method of determining grid points in a deformable grid to remove facial distortion according to another exemplary embodiment of the present disclosure.

[0028] FIG5( b ) is a schematic diagram showing a deformable mesh distortion correction according to another exemplary embodiment of the present disclosure.

[0029] Figure 6 The figure is a block diagram of a distortion correction device according to an exemplary embodiment.

[0030] Figure 7 The figure is a block diagram of a device for distortion correction according to an exemplary embodiment. DETAILED DESCRIPTION

[0031] Here, exemplary embodiments will be described in detail, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present disclosure.

[0032] With the development of smart terminals, users have higher and higher requirements for terminals with shooting functions. However, when users take selfies, distortion will be introduced due to deviations in lens manufacturing accuracy and assembly process, resulting in distortion of the original image.

[0033] In the related art, the distance between the camera and the face is generally used to determine a threshold. When the distance is above the threshold, face distortion correction is performed based on the distance, or face distortion is removed by separately correcting the foreground and background and then fusing them.

[0034] However, the image corrected by the above method will have obvious jello effect, unnatural stretching, holes and other phenomena.

[0035] Therefore, the present disclosure proposes a method for distortion correction, which can ensure that the object is dedistorted while avoiding the residual jello effect of the image after the distortion is removed, or the existence of unnatural stretching, holes, etc.

[0036] In one embodiment, the technical field involved in the present disclosure is the EIS (Electric Image Stabilization) of the terminal camera, which refers to the electronic image stabilization technology, which is an anti-shake capability achieved by a software algorithm. Furthermore, it can also be extended to other related computer vision fields involving object distortion correction, such as AR / VR, etc., which are not limited in the embodiments of the present disclosure.

[0037] In one embodiment, the present disclosure can be applied to intelligent terminal application scenarios such as video preview, video recording, live broadcast, video chat, etc., to correct object distortion in these scenarios. Furthermore, it can also be extended to a variety of terminal display devices other than smartphones, such as tablet computers, AR / VR head displays, etc., which are not limited in the embodiments of the present disclosure.

[0038] Figure 1 is a flowchart of a distortion correction method according to an exemplary embodiment. Figure 1As shown, the distortion correction method is used in a terminal and includes the following steps.

[0039] In step S101, an object detection frame corresponding to the object to be corrected for distortion in the image and an object center of the object in the object detection frame are determined.

[0040] The object to be distorted and corrected is the object information in the image taken by the terminal user during the self-portrait process. The object detection frame is the object detection frame of the terminal user.

[0041] In the disclosed embodiment, the object detection frame can be the detection result output by directly performing object detection on the image, or it can be the outer envelope frame of N key points output by 3D object pose estimation. The object center of the object in the object frame can be the center of the object detection frame, the center of the outer envelope frame of N key points output by 3D object pose estimation, or a certain object key point.

[0042] Furthermore, when the object detection frame is a face frame, it can be expressed as: face bbx ={top,letf,bottom,right}, the four values ​​represent the values ​​in the image coordinate system, so the four vertices of the object detection box can be expressed as:

[0043] P tl ={top,letf},P br ={bottom,right},P bl ={top,right},P tr ={bottom,letf}.

[0044] Among them, the upper left corner P tl and the lower right corner point P br (or the upper right corner P tr and the lower left corner point P bl ) represents the object detection box.

[0045] In step S102, based on the center point of the object in the i-1th frame image and the center point of the object in the i-th frame image, the distortion correction confidence of the object in the i-th frame image mapped to the deformable mesh is determined.

[0046] The deformable grid in the embodiment of the present disclosure is used to guide the mapping position of each pixel in the image after anti-shake / stabilization, by determining the distortion correction confidence of the object in the i-th frame image mapped to the deformable grid, and acting on the deformable grid to correct the distortion.

[0047] In step S103, the i-th frame of the image to be distorted and corrected is obtained, and the deformed grid to be corrected in the i-th frame of the image to be distorted and corrected is obtained as the first deformed grid, and the rolling shutter effect is removed from the first deformed grid to obtain the second deformed grid, where the first deformed grid is the grid obtained after optical image stabilization and lens distortion correction are performed on the i-th frame of the image to be distorted and corrected.

[0048] The first deformable grid is a grid obtained after optical image stabilization and lens distortion correction have been completed for the i-th frame of the image to be distorted and corrected. It is a 2×N×N dimensional array, indicating that the grid resolution is N×N, and each grid point represents a coordinate in a two-dimensional coordinate system.

[0049] Furthermore, in the disclosed embodiment, optical image stabilization (OIS) is achieved by placing the terminal lens in a suspension mechanism, combining the data of the gyroscope to obtain the jitter amplitude of the current device, and performing reverse compensation to obtain an anti-shake effect. In order to ensure the accuracy of EIS, the offset introduced by OIS needs to be reversely compensated when performing relevant calculations. Among them, EIS (Electric Image Stabilization) refers to electronic anti-shake technology, which is an anti-shake capability achieved through software algorithms.

[0050] In addition, lens distortion correction (LDC) is also required. In order to ensure the accuracy of EIS, the distortion introduced by the lens in the input image needs to be corrected.

[0051] Furthermore, in the disclosed embodiment, the second deformed mesh is the mesh obtained by removing the rolling shutter effect from the first deformed mesh. Rolling shutter (RS for short), most CMOS sensors of smart terminals use a row-by-row scanning method, and this scanning method causes all pixels in the image to not be exposed at the same time, resulting in image distortion. Therefore, when doing EIS, the rolling shutter needs to be corrected first.

[0052] It is understandable that rolling shutter can achieve a higher frame rate, but when the exposure is improper or the object moves quickly, partial exposure, skew, wobble, etc. will appear. This phenomenon that occurs when shooting with rolling shutter is defined as the jello effect. Therefore, the present invention removes the rolling shutter effect, that is, removes the jello effect.

[0053] In step S104, a third deformed mesh without distortion correction is determined based on the distortion correction confidence, the first deformed mesh, and the second deformed mesh.

[0054] A third deformed mesh from which the distortion is finally removed is determined through the distortion correction confidence, the first deformed mesh, and the second deformed mesh.

[0055] In step S105, distortion correction is performed on the object in the i-th frame image based on the third deformable mesh.

[0056] The third deformable mesh is a deformable mesh corresponding to the image from which the object distortion is removed, and the third deformable mesh is used to guide the object in the i-th frame image to perform distortion correction.

[0057] Through the above embodiments, the distortion of objects in the image is effectively removed, and reliance on TOF cameras or depth estimation is avoided, which is conducive to ensuring that the jello effect of the background is effectively removed while the foreground (such as a face) is dedistorted. It can adaptively cope with a variety of different shooting scenes, and the correction results are continuous without jumps.

[0058] Figure 2 The flowchart is a method for determining a distortion correction confidence of an object in an i-th frame image mapped to a deformable mesh according to another exemplary embodiment of the present disclosure.

[0059] like Figure 2 As shown, based on the center point of the object in the i-1th frame image and the center point of the object in the i-th frame image, the distortion correction confidence of the object in the i-th frame image mapped to the deformable mesh is determined, including the following steps S201 and S202. Step S201 and step S202 will be introduced below respectively.

[0060] In step S201, the global initial distortion correction confidence of the object is determined based on the center point of the object in the (i-1)th frame image and the center point of the object in the (i)th frame image.

[0061] The global initial distortion correction confidence is the global initial object distortion correction confidence of the object detection box.

[0062] In step S202, based on the global initial distortion correction confidence and the discount factor of the grid points, the distortion correction confidence of the object in the i-th frame image mapped to the deformable grid is determined.

[0063] The distortion correction confidence of the object in the current frame image mapped to the deformed grid is determined by the global initial distortion correction confidence and the discount factor of the grid points. Among them, the discount factor of the grid points is used to correct the distortion correction confidence of the grid points corresponding to it. It can be understood that the global initial distortion correction confidence is mainly used to remove distortion correction for the foreground (such as a face), but if the distortion correction is only performed on the foreground, it will cause an obvious edge jello effect between the foreground and the background. Therefore, in the embodiment of the present disclosure, a buffer is performed on the entire deformed grid during the process of removing object distortion through the discount factor, which is not limited to the foreground, and is mainly discounted for the transition area between the foreground and the background, so as to effectively remove the distortion of the entire image.

[0064] The following embodiments will describe in detail how to determine the confidence level of the global initial distortion correction of an object.

[0065] Figure 3 The present invention is a flowchart showing a method for determining a global initial distortion correction confidence of an object according to another exemplary embodiment of the present invention.

[0066] like Figure 3 As shown, based on the center point of the object in the i-1th frame image and the center point of the object in the i-th frame image, the global initial distortion correction confidence of the object is determined, including the following steps S301, S302 and S303. Step S301, step S302 and step S303 will be introduced respectively below.

[0067] In step S301, based on the center point of the object in the i-1th frame image and the center point of the object in the i-th frame image, an external parameter matrix corresponding to the object detection box in the i-th frame image is obtained.

[0068] In the embodiment of the present disclosure, the center point of the object in the i-th frame image is The center point of the object in the i-1th frame image is Among them, time t-1 and time t represent the imaging exposure time of the corresponding row of the image where the center point of the object in the previous frame and the center point of the object in the current frame are located, respectively.

[0069] Furthermore, the quaternion of the terminal attitude at time t-1 and time t can be obtained, respectively using Indicates that the external parameter matrix R corresponding to the object detection box in the i-th frame image is further calculated t-1 and R t .

[0070] Among them, quaternion is used to reflect the rotation of the terminal posture, and the posture represented by q at a certain moment is defined as q t (4), the number in brackets is the dimension of the vector; for both terminals and objects, the postures in three-dimensional space are represented by quaternions.

[0071] In step S302, based on the projection position of the object detection frame in the i-1th frame image, the imaging exposure times corresponding to the object center point in the i-1th frame image and the image to be distorted and corrected where the object center point in the i-th frame image is located, and the external parameter matrix corresponding to the i-th frame object detection frame, the motion matrix of the object center point from the i-1th frame image to the i-th frame is obtained.

[0072] The projection position of the center point of the object in the three-dimensional space on the i-th frame image is represented by x i =K·R t X, the projection position on the i-1th frame image is represented by x i-1 =K·R t-1 ·X, where K is the terminal's internal parameter matrix.

[0073] Therefore, the following formula is used to determine the motion matrix of the object center point mapped from the i-1th frame to the i-th frame image:

[0074]

[0075] According to the motion matrix, the coordinate position of the object after the terminal position moves can be calculated. express.

[0076] In step S303, a first object distortion correction confidence of the object detection frame is determined based on the object center point in the i-1th frame image, the object center point of the i-th frame, and the motion matrix of the object center point from the i-1th frame image to the i-th frame.

[0077] In the embodiment of the present disclosure, the center point of the object in the i-1th frame image may be The center point of the object in the i-1th frame image And according to the motion matrix, the coordinate position of the object after the terminal position moves can be calculated A first object distortion correction confidence of the object detection box is determined.

[0078] Furthermore, the present disclosure uses the following formula to determine the first object distortion correction confidence of the object detection frame:

[0079]

[0080]

[0081]

[0082]

[0083]

[0084] M proj =(x h × f +y h ×y f ) / H norm (7)

[0085] init_con=(H norm -M proj )×ADJUST_FACTOR (8)

[0086] Among them, H norm is the normalized value, M proj is the mapping value, ADJUST_FACTOR is the adjustment factor, and init_con is the first object distortion correction confidence of the object detection box.

[0087] In addition, before obtaining the global initial distortion correction confidence of the object, the present disclosure needs to set the vertex coordinates of the upper left corner P of the object detection frame to tl and the lower right corner point P br (or the upper right corner P tr and the lower left corner point P bl ) and the object center coordinates of the current frame image are normalized to [-frmHeight:frmHeight, -frmWidth:frmWidth] to ensure that the origin is located at the center of the image.

[0088] Through the above embodiments, it is ensured that the object within the object detection frame is dedistorted during the selfie process.

[0089] In the disclosed embodiment, after determining the confidence of the global initial distortion correction, it is also necessary to obtain the discount factor of each grid point in the deformed grid to determine whether some areas of each grid point can be discounted after the global distortion correction is performed to avoid the jello effect of obvious edges in the foreground and background.

[0090] The following embodiments will describe in detail how to determine the discount factor for each grid point.

[0091] Figure 4 The figure is a flow chart showing a method of determining a discount factor of a grid point according to another exemplary embodiment of the present disclosure.

[0092] like Figure 4 As shown, the process includes the following steps S401, S402, S403 and S404. Step S401, S402, S403 and S404 will be described below respectively.

[0093] In step S401, the Euclidean distance between the grid points and the center point of the object is determined.

[0094] In one embodiment of the present disclosure, the coordinates of each grid point in the deformed grid are expressed as (p i ,p j ) is represented by the coordinates of each grid point (p i ,p j ) and the object center point in the object detection box of the current frame, determine the Euclidean distance from each grid point to the object center point, denoted by dist.

[0095] In the embodiment of the present disclosure, the vertex coordinates of the object detection frame are obtained:

[0096] or

[0097]

[0098] in, is the coordinate of the upper left corner of the object detection box of the i-th frame, is the coordinate of the lower right corner of the object detection frame of the i-th frame, is the coordinate of the upper right corner of the object detection frame of the i-th frame, is the lower left corner coordinate of the object detection box in the i-th frame.

[0099] According to the vertex coordinates in the above embodiment, the center point coordinates of the object detection frame of the current frame can be determined, and bbx center It is expressed as:

[0100]

[0101] In yet another embodiment of the present disclosure, the distance for distortion correction of the object detection frame is determined according to the vertex coordinates of the object detection frame, and is represented by totalConRangeLen.

[0102] The following formula is used to determine the distance totalConRangeLen for the object detection frame to perform distortion correction:

[0103]

[0104] Through the above embodiment, the discount factor of each grid point is determined by judging the Euclidean distance from each grid point to the center point of the object and the distance of the object detection frame for distortion correction, with con_discount i,j Represents the discount factor.

[0105] In step S402 , if the Euclidean distance is less than or equal to the first distance, the discount factor is 1.

[0106] The first distance is the distance totalConRangeLen for the object detection frame to perform distortion correction. If dist≤totalConRangeLen, then

[0107] con1_discount i,j =1 (11-1)

[0108] It can be understood that when the Euclidean distance is less than or equal to the first distance, no discount is performed on the grid points within this area, and the object distortion is removed according to the first object distortion correction confidence.

[0109] In step S403, if the Euclidean distance is greater than the first distance and less than or equal to the second distance, the discount factor is con discount2 .

[0110] In the embodiment of the present disclosure, a certain distance outside the totalConRangeLen between the two vertices of the object detection box is set to BUFFER IEN It means that the buffer area is used as the object detection frame to remove the object distortion. The grid points in this area discount the degree of correction during the distortion correction process to ensure that the jello effect of the background is effectively removed while the foreground is corrected for object distortion, and there is no obvious edge between the foreground and the background.

[0111] The second distance is totalConRangeLen+BUFFER IEN When the Euclidean distance is greater than the first distance and less than or equal to the second distance, the discount factor is con2_discount i,j .

[0112] That is, when totalConRangeLen<dist≤totalConRangeLen+BUFFER IEN When con2_discount is determined, the following formula is used i,j :

[0113]

[0114] In step S404, if the Euclidean distance is greater than the second distance, the discount factor is 0.

[0115] If dist>totalConRangeLen+BUFFER IEN ,but

[0116] con3_discount i,j =0 (11-3)

[0117] That is, no distortion correction is performed on the grid points outside the buffer area.

[0118] In the implementation of the present disclosure, based on the first object distortion correction confidence init_con corresponding to each grid point in the object detection frame, the discount factor con_discount of each grid point i,j , the following formula is used to determine the distortion correction confidence of the object in the i-th frame image mapped to the deformable mesh:

[0119] final_con i,j =init_con×discount i,j (12)

[0120] Among them, final_con i,j Confidence for distortion correction.

[0121] In one embodiment, a third deformed mesh without distortion correction is determined based on the distortion correction confidence, the first deformed mesh, and the second deformed mesh according to the following formula:

[0122] grid final(i,j) =grid afterRSC(i,j) ×(1-final coni,j )+grid org(i,j) ×final coni,j (13)

[0123] Among them, grid org(i,j) is the first deformed grid, grid afterRSC(i,j) is the second deformed mesh, grid final(i,j) is the third deformed mesh, final coni,j Confidence for distortion correction.

[0124] Through the embodiment of the present disclosure, the deformation grid for removing the distortion of the i-th frame image is finally obtained, and the deformation grid is used to guide the i-th frame image to correct the distorted area. Not only can the object be dedistorted, but also the distortion of the foreground (such as the face) can be effectively removed without relying on the TOF camera or depth estimation, and the jello effect of the background can be effectively removed, avoiding unnatural stretching, holes and other effects.

[0125] FIG5( a ) is a flowchart showing a method of determining grid points in a deformable grid to remove facial distortion according to another exemplary embodiment of the present disclosure.

[0126] As shown in Fig. 5(a), the process includes the following steps S501, S502, S503 and S504. Step S501 includes S5011 and S5012, step S502 includes S5021 and S5022, and step S503 includes S5031 and S5032, which will be introduced below respectively.

[0127] In step S501, face information is standardized.

[0128] In step S5011, normalize to a coordinate system whose origin is the center of the image.

[0129] In step S5012, OIS and LDC correction are de-compensated.

[0130] In the embodiment of the present disclosure, when the object in the object adding frame is a face, the face is distorted. The face information is obtained, and the face information mainly includes the face frame and the face center.

[0131] From the above embodiments, it can be seen that the face frame can be bbx ={top,letf,bottom,right}, and the face information includes the vertex coordinates P of the face frame tl ={top,letf},P br ={bottom,right}, and the face center coordinates, and are standardized by default and normalized to [-frmHeight:frmHeight, -frmWidth:frmWidth].

[0132] Furthermore, the above three coordinate points are subjected to anti-OIS compensation, and the coordinate positions after the arrow lens distortion correction are obtained, which are recorded as And get the first deformed grid grid org(i,j) .

[0133] In step S502, the global initial face distortion correction confidence is obtained.

[0134] In step S5021, the normalized coordinates of the face center of the previous frame and the current frame are obtained; the camera pose from the previous frame to the current frame is calculated and the camera motion matrix is ​​calculated.

[0135] In step S5022, the face distortion correction confidence of each point homogeneity (initial) is calculated.

[0136] When there are multiple faces in the face frame, the center point of the face can be selected from the center point of the face frame.

[0137] According to the quaternion of the camera pose from the previous frame t-1 to the current frame t Determine the resulting camera motion matrix And finally get the coordinate position of the face after the camera position moves

[0138] Based on the face center coordinates of the previous frame and the current frame as well as The global initial face distortion correction confidence can be obtained according to the above formulas (2)-(8).

[0139] In step S503, the final face distortion correction confidence of the deformed mesh is obtained.

[0140] In step S5031, a buffer zone model is established to estimate the confidence factor of the face darkening correction for each point heterogeneity.

[0141] In step S5032, the face distortion correction confidence of each point anisotropy is calculated.

[0142] By determining the correction distance between the two vertices of the face frame, and presetting a distance outside this distance as the buffer area of ​​the face frame, the BUFFER IEN Indicates a buffer zone.

[0143] According to the above formulas (9)-(11), it can be determined whether the degree of distortion removal can be discounted when performing distortion correction for each grid point in the deformable grid, so that the dedistorted face and background are more natural.

[0144] Each grid point is based on its corresponding discount factor. According to formula (12), the final face distortion correction confidence of the deformed grid can be obtained, and the second deformed grid grid is obtained. afterRSC(i,j) .

[0145] In step S504, new coordinates of each point in the deformed mesh after removing the facial distortion are calculated.

[0146] After obtaining the first deformed mesh, the second deformed mesh, and the final face distortion correction confidence of the deformed mesh, the final dedistorted third deformed mesh grid is determined according to formula (13): final(i,j) , and obtain the new coordinates of each point in the deformed mesh to remove the face distortion, so as to guide the image to remove the face distortion. FIG5(b) is a schematic diagram of a deformed mesh distortion correction according to another exemplary embodiment of the present disclosure. As shown in FIG5(b), it is the change process of the deformed mesh.

[0147] Through the above embodiments, not only the facial distortion is effectively removed, but also unnatural stretching and the like are avoided.

[0148] Based on the same concept, the embodiment of the present disclosure also provides a distortion correction device.

[0149] It is understandable that the distortion correction device provided by the embodiment of the present disclosure includes hardware structures and / or software modules corresponding to the execution of each function in order to realize the above functions. In combination with the units and algorithm steps of each example disclosed in the embodiment of the present disclosure, the embodiment of the present disclosure can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the technical solution of the embodiment of the present disclosure.

[0150] Figure 6 is a block diagram of a distortion correction device according to an exemplary embodiment. Figure 6 The device 100 includes a determination module 101, an acquisition module 102 and a processing module 103.

[0151] The determination module 101 is configured to determine the object detection frame corresponding to the object to be distorted and corrected in the image, and the object center of the object in the object detection frame; based on the object center point in the i-1 frame image and the object center point in the i-th frame image, determine the distortion correction confidence of the distortion correction mapped to the deformable mesh for the object in the i-th frame image.

[0152] The acquisition module 102 is configured to acquire the i-th frame of the image to be distorted and corrected, obtain the deformed grid to be corrected in the i-th frame of the image to be distorted and corrected as the first deformed grid, and remove the rolling shutter effect of the first deformed grid to obtain the second deformed grid, where the first deformed grid is the grid obtained after the i-th frame of the image to be distorted and corrected by optical image stabilization and lens distortion correction.

[0153] The processing module 103 is configured to determine a third deformed mesh without distortion correction based on the distortion correction confidence, the first deformed mesh and the second deformed mesh; and perform distortion correction on the object in the i-th frame image based on the third deformed mesh.

[0154] In one embodiment, the determination module 101 is configured to determine the global initial distortion correction confidence of the object based on the center point of the object in the i-1th frame image and the center point of the object in the i-th frame image; determine the distortion correction confidence of the distortion correction mapped to the deformable grid for the object in the i-th frame image based on the global initial distortion correction confidence and the discount factor of the grid points; the discount factor of the grid points is used to correct the distortion correction confidence of the grid points corresponding to it.

[0155] In one embodiment, the determination module 101 is configured to obtain an external parameter matrix corresponding to an object detection frame in the i-th frame image based on the object center point in the i-1th frame image and the object center point in the i-th frame image; obtain a motion matrix of the object center point from the i-1th frame image to the i-th frame based on the projection position of the object detection frame in the i-1th frame image, the imaging exposure time corresponding to the object center point in the i-1th frame image and the image to be distorted and corrected where the object center point in the i-1th frame image is located, and the external parameter matrix corresponding to the i-th frame object detection frame; determine a first object distortion correction confidence of the object detection frame based on the object center point in the i-1th frame image, the object center point of the i-th frame, and the motion matrix of the object center point from the i-1th frame image to the i-th frame.

[0156] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0157] Figure 7 2 is a block diagram of a device 200 for distortion correction according to an exemplary embodiment. For example, the device 200 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0158] Reference Figure 7 , the device 200 may include one or more of the following components: a processing component 202 , a memory 204 , a power component 206 , a multimedia component 208 , an audio component 210 , an input / output (I / O) interface 212 , a sensor component 214 , and a communication component 216 .

[0159] The processing component 202 generally controls the overall operation of the device 200, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 202 may include one or more processors 220 to execute instructions to perform all or part of the steps of the above-described method. In addition, the processing component 202 may include one or more modules to facilitate interaction between the processing component 202 and other components. For example, the processing component 202 may include a multimedia module to facilitate interaction between the multimedia component 208 and the processing component 202.

[0160] The memory 204 is configured to store various types of data to support operations on the device 200. Examples of such data include instructions for any application or method operating on the device 200, contact data, phone book data, messages, pictures, videos, etc. The memory 204 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0161] The power component 206 provides power to the various components of the device 200. The power component 206 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 200.

[0162] The multimedia component 208 includes a screen that provides an output interface between the device 200 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 208 includes a front camera and / or a rear camera. When the device 200 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0163] The audio component 210 is configured to output and / or input audio signals. For example, the audio component 210 includes a microphone (MIC), and when the device 200 is in an operation mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 204 or sent via the communication component 216. In some embodiments, the audio component 210 also includes a speaker for outputting audio signals.

[0164] I / O interface 212 provides an interface between processing component 202 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.

[0165] The sensor assembly 214 includes one or more sensors for providing various aspects of the status assessment of the device 200. For example, the sensor assembly 214 can detect the open / closed state of the device 200, the relative positioning of components, such as the display and keypad of the device 200, the sensor assembly 214 can also detect the position change of the device 200 or a component of the device 200, the presence or absence of user contact with the device 200, the orientation or acceleration / deceleration of the device 200 and the temperature change of the device 200. The sensor assembly 214 can include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 214 can also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 214 can also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor or a temperature sensor.

[0166] The communication component 216 is configured to facilitate wired or wireless communication between the device 200 and other devices. The device 200 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 216 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 216 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0167] In an exemplary embodiment, the apparatus 200 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above method.

[0168] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 204 including instructions, and the instructions can be executed by the processor 220 of the device 200 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0169] It is to be understood that in the present disclosure, "plurality" refers to two or more than two, and other quantifiers are similar. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. The singular forms "a", "the" and "the" are also intended to include plural forms, unless the context clearly indicates other meanings.

[0170] It is further understood that the terms "first", "second", etc. are used to describe various information, but such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other, and do not indicate a specific order or degree of importance. In fact, the expressions "first", "second", etc. can be used interchangeably. For example, without departing from the scope of the present disclosure, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as the first information.

[0171] It can be further understood that, unless otherwise specified, “connection” includes a direct connection without other components between the two, and also includes an indirect connection with other components between the two.

[0172] It is further understood that, although the operations are described in a specific order in the drawings in the embodiments of the present disclosure, it should not be understood as requiring that the operations be performed in the specific order shown or in a serial order, or requiring that all the operations shown be performed to obtain the desired results. In certain environments, multitasking and parallel distortion correction may be advantageous.

[0173] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any modifications, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure.

[0174] It should be understood that the present disclosure is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the scope of the appended claims.

Claims

1. A distortion correction method, characterized in that: The distortion correction method comprises: Determine an object detection frame corresponding to the object to be corrected for distortion in the image, and an object center of the object in the object detection frame; Determine, based on the center point of the object in the i-1th frame image and the center point of the object in the i-th frame image, a distortion correction confidence of the object in the i-th frame image mapped to the deformable mesh; Acquire the i-th frame of the image to be distorted and corrected, obtain the deformed mesh to be corrected in the i-th frame of the image to be distorted and corrected as the first deformed mesh, and remove the rolling shutter effect of the first deformed mesh to obtain the second deformed mesh, wherein the first deformed mesh is the mesh obtained after the i-th frame of the image to be distorted and corrected by optical image stabilization and lens distortion correction; Determining a third deformed mesh from which the distortion correction is removed based on the distortion correction confidence, the first deformed mesh, and the second deformed mesh; Based on the third deformable grid, distortion correction is performed on the object in the i-th frame image.

2. The distortion correction method according to claim 1, characterized in that: The step of determining the distortion correction confidence of the object in the i-1 frame image mapped to the deformable mesh after distortion correction is performed on the object in the i-1 frame image based on the center point of the object in the i-1 frame image and the center point of the object in the i-th frame image includes: Determine a global initial distortion correction confidence of the object based on a center point of the object in the i-1th frame image and a center point of the object in the i-th frame image; Determine the distortion correction confidence of the object in the i-th frame image mapped to the deformable grid based on the global initial distortion correction confidence and the discount factor of the grid points; The discount factor of the grid point is used to correct the distortion correction confidence of the grid point corresponding to the grid point.

3. The distortion correction method according to claim 2, characterized in that: The determining of the global initial distortion correction confidence of the object based on the center point of the object in the i-1th frame image and the center point of the object in the i-th frame image includes: Based on the center point of the object in the i-1th frame image and the center point of the object in the i-th frame image, the external parameter matrix corresponding to the object detection box in the i-th frame image is obtained; Based on the projection position of the object detection frame in the i-1th frame image, the imaging exposure times corresponding to the center point of the object in the i-1th frame image and the image to be distorted and corrected where the center point of the object in the i-th frame image is located, and the external parameter matrix corresponding to the object detection frame of the i-th frame, a motion matrix of the object center point from the i-1th frame image to the i-th frame is obtained; A first object distortion correction confidence of the object detection frame is determined based on the object center point in the i-1th frame image, the object center point in the i-th frame, and a motion matrix of the object center point from the i-1th frame image to the i-th frame.

4. The distortion correction method according to claim 2 or 3, characterized in that: The discount factor of the grid point is determined in the following way: Determine the Euclidean distance between the grid points and the center point of the object; If the Euclidean distance is less than or equal to the first distance, the discount factor is 1; If the Euclidean distance is greater than the first distance and less than or equal to the second distance, the discount factor is Among them, con2_discount i,j is the discount factor, BUFFER IEN is a parameter factor, dist is the Euclidean distance, and totalConRangeLen is the distance between two vertices of the object detection box; If the Euclidean distance is greater than the second distance, the discount factor is 0; The first distance is the distance between two vertices of the object detection box, and the second distance is the sum of the distance between the two vertices of the object detection box and a parameter factor.

5. The distortion correction method according to claim 1, characterized in that: The determining, based on the distortion correction confidence, the first deformed mesh and the second deformed mesh, a third deformed mesh from which distortion correction is removed comprises: A third deformed mesh without distortion correction is determined based on the distortion correction confidence, the first deformed mesh, and the second deformed mesh according to the following formula: grid final(i,j) =grid afterRSC(i,j) ×(1-final coni,j )+grid org(i,j) ×final coni,j Among them, grid org(i,j) is the first deformed grid, grid afterRSC(i,j) For the second deformed mesh, grid final(i,j) is the third deformed mesh, final coni,j A confidence score is calculated for the distortion.

6. A distortion correction device, characterized in that: The distortion correction device comprises: A determination module is used to determine an object detection frame corresponding to the object to be distorted and corrected in the image, and an object center of the object in the object detection frame; based on the object center point in the i-1th frame image and the object center point in the i-th frame image, determine the distortion correction confidence of the object in the i-th frame image mapped to the deformable mesh for distortion correction; an acquisition module, configured to acquire an i-th frame of the image to be distorted and corrected, obtain a deformed mesh to be corrected in the i-th frame of the image to be distorted and corrected as a first deformed mesh, and remove a rolling shutter effect from the first deformed mesh to obtain a second deformed mesh, wherein the first deformed mesh is a mesh obtained after optical image stabilization and lens distortion correction are performed on the i-th frame of the image to be distorted and corrected; A processing module is used to determine a third deformed mesh with the distortion correction removed based on the distortion correction confidence, the first deformed mesh and the second deformed mesh; and perform distortion correction on the object in the i-th frame image based on the third deformed mesh.

7. The distortion correction device according to claim 6, characterized in that: The determination module determines the distortion correction confidence of the object in the i-th frame image mapped to the deformable mesh by distortion correction based on the center point of the object in the i-1th frame image and the center point of the object in the i-th frame image in the following manner: Determine a global initial distortion correction confidence of the object based on a center point of the object in the i-1th frame image and a center point of the object in the i-th frame image; Determine the distortion correction confidence of the object in the i-th frame image mapped to the deformable grid based on the global initial distortion correction confidence and the discount factor of the grid points; The discount factor of the grid point is used to correct the distortion correction confidence of the grid point corresponding to the grid point.

8. The distortion correction device according to claim 7, characterized in that: The determination module determines the global initial distortion correction confidence of the object based on the center point of the object in the i-1th frame image and the center point of the object in the i-th frame image in the following manner: Based on the center point of the object in the i-1th frame image and the center point of the object in the i-th frame image, the external parameter matrix corresponding to the object detection box in the i-th frame image is obtained; Based on the projection position of the object detection frame in the i-1th frame image, the imaging exposure times corresponding to the center point of the object in the i-1th frame image and the image to be distorted and corrected where the center point of the object in the i-th frame image is located, and the external parameter matrix corresponding to the object detection frame of the i-th frame, a motion matrix of the object center point from the i-1th frame image to the i-th frame is obtained; A first object distortion correction confidence of the object detection frame is determined based on the object center point in the i-1th frame image, the object center point in the i-th frame, and a motion matrix of the object center point from the i-1th frame image to the i-th frame.

9. A distortion correction device, characterized in that: include: processor; a memory for storing processor-executable instructions; Wherein, the processor is configured to: execute the distortion correction method described in any one of claims 1-5.

10. A storage medium, characterized in that: The storage medium stores instructions, and when the instructions in the storage medium are executed by a processor of the terminal, the terminal is enabled to execute the distortion correction method described in any one of claims 1 to 5.