Image correction method and device, and electronic equipment

The image correction method addresses the issue of distorted backgrounds by detecting target areas, calculating correction weights, and segmenting images to adaptively adjust correction, resulting in improved visual quality by reducing background curvature.

CN114049269BActive Publication Date: 2024-12-17GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111308695.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-05
Publication Date
2024-12-17
Estimated Expiration
2041-11-05

AI Technical Summary

Technical Problem

Traditional image correction methods often result in distorted background areas and inadequate visual effects due to the use of global correction techniques, which fail to account for regional differences in distortion levels.

Method used

An image correction method that detects target areas within an image, determines correction weights based on distance from a reference point, segments the image into regions, and fuses original and projected grids to adaptively adjust the correction degree by region, thereby reducing background curvature and enhancing visual quality.

Benefits of technology

The method effectively corrects distorted areas while minimizing background curvature, improving the visual effect of the image by adaptively adjusting the correction degree based on regional distortion levels.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114049269B_ABST
    Figure CN114049269B_ABST
Patent Text Reader

Abstract

The present application relates to an image correction method, comprising: acquiring an image to be corrected; detecting a target area where a target object is located in the image to be corrected; acquiring a target distance between the target area and a preset reference point in the image to be corrected, and determining a correction weight corresponding to the target area based on the target distance, wherein the correction weight corresponding to the target area is positively correlated with the target distance; segmenting the image to be corrected to obtain a plurality of segmented areas; determining a target correction weight corresponding to each segmented area based on an overlapping relationship between the segmented area and the target area; using the target correction weight, the original grid and the projected grid corresponding to each segmented area are merged to obtain a target grid corresponding to each segmented area, and the image to be corrected is corrected based on the target grid corresponding to each segmented area to obtain a target image after correction, thereby improving the visual effect of the corrected image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an image correction method and device, an electronic device, and a computer-readable storage medium. Background Art

[0002] With the development of technology in the field of computer technology, in some specific scenarios in the field of vision, it is necessary to correct the distorted images captured, so as to obtain images with better visual effects that meet the needs of different scenarios.

[0003] However, in traditional image correction methods, a global correction method is usually directly used to correct the image. Since there are curved lines in the background area of ​​the image corrected by this method, a good image correction effect cannot be obtained. Summary of the invention

[0004] The embodiments of the present application provide an image correction method and device, an electronic device, and a computer-readable storage medium, which can effectively correct the distorted areas in the image while reducing the background curvature and adaptively adjust the correction degree by region, thereby effectively improving the visual effect of the corrected image.

[0005] An image correction method, comprising:

[0006] Acquire an image to be corrected;

[0007] Detecting a target area where a target object is located in the image to be corrected;

[0008] Acquire a target distance between the target area and a preset reference point in the image to be corrected, and determine a correction weight corresponding to the target area based on the target distance, wherein the correction weight corresponding to the target area is positively correlated with the target distance;

[0009] Segmenting the image to be corrected to obtain a plurality of segmented regions;

[0010] Based on the overlapping relationship between the segmented areas and the target area, determining the target correction weight corresponding to each segmented area;

[0011] Based on the target correction weight, the original grid and the projected grid corresponding to each segmented area are fused to obtain the target grid corresponding to each segmented area, and the image to be corrected is corrected based on the target grid corresponding to each segmented area to obtain the target image after correction. The original grid is a grid map obtained by gridding the image to be corrected, and the projected grid is a grid map obtained by projecting the original grid.

[0012] An image correction device, comprising:

[0013] An acquisition module, used for acquiring an image to be corrected;

[0014] A detection module, used for detecting a target area where a target object is located in the image to be corrected;

[0015] A correction weight calculation module, used for obtaining a target distance between the target area and a preset reference point in the image to be corrected, and determining a correction weight corresponding to the target area based on the target distance, wherein the correction weight corresponding to the target area is positively correlated with the target distance;

[0016] A target correction weight determination module, used for segmenting the image to be corrected to obtain a plurality of segmented regions, and determining a target correction weight corresponding to each segmented region based on an overlapping relationship between the segmented regions and the target region;

[0017] The correction module is used to fuse the original grid and the projected grid corresponding to each segmented area based on the target correction weight to obtain the target grid corresponding to each segmented area, and perform correction processing on the image to be corrected based on the target grid corresponding to each segmented area to obtain the target image after correction processing. The original grid is a grid map obtained by gridding the image to be corrected, and the projected grid is a grid map obtained by projecting the original grid.

[0018] An electronic device includes a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the following steps:

[0019] Acquire an image to be corrected;

[0020] Detecting a target area where a target object is located in the image to be corrected;

[0021] Acquire a target distance between the target area and a preset reference point in the image to be corrected, and determine a correction weight corresponding to the target area based on the target distance, wherein the correction weight corresponding to the target area is positively correlated with the target distance;

[0022] Segmenting the image to be corrected to obtain a plurality of segmented regions;

[0023] Based on the overlapping relationship between the segmented areas and the target area, determining the target correction weight corresponding to each segmented area;

[0024] Based on the target correction weight, the original grid and the projected grid corresponding to each segmented area are fused to obtain the target grid corresponding to each segmented area, and the image to be corrected is corrected based on the target grid corresponding to each segmented area to obtain the target image after correction. The original grid is a grid map obtained by gridding the image to be corrected, and the projected grid is a grid map obtained by projecting the original grid.

[0025] A computer-readable storage medium stores a computer program, which, when executed by a processor, causes the processor to perform the following steps:

[0026] Acquire an image to be corrected;

[0027] Detecting a target area where a target object is located in the image to be corrected;

[0028] Acquire a target distance between the target area and a preset reference point in the image to be corrected, and determine a correction weight corresponding to the target area based on the target distance, wherein the correction weight corresponding to the target area is positively correlated with the target distance;

[0029] Segmenting the image to be corrected to obtain a plurality of segmented regions;

[0030] Based on the overlapping relationship between the segmented areas and the target area, determining the target correction weight corresponding to each segmented area;

[0031] Based on the target correction weight, the original grid and the projected grid corresponding to each segmented area are fused to obtain the target grid corresponding to each segmented area, and the image to be corrected is corrected based on the target grid corresponding to each segmented area to obtain the target image after correction. The original grid is a grid map obtained by gridding the image to be corrected, and the projected grid is a grid map obtained by projecting the original grid.

[0032] The above-mentioned image correction method, device, electronic device and computer-readable storage medium detect the target area where the target object is located in the image to be corrected by acquiring the image to be corrected; acquiring the target distance between the target area and a preset reference point in the image to be corrected, and determining the correction weight corresponding to the target area based on the target distance, wherein the correction weight corresponding to the target area is positively correlated with the target distance; segmenting the image to be corrected to obtain multiple segmented areas; determining the target correction weight corresponding to each segmented area based on the overlapping relationship between the segmented area and the target area; merging the original grid and the projected grid corresponding to each segmented area based on the target correction weight to obtain the target grid corresponding to each segmented area, and performing correction on the target grid corresponding to each segmented area based on the target correction weight. The image to be corrected is corrected to obtain a target image after the correction. The original grid is a grid map obtained by gridding the image to be corrected, and the projection grid is a grid map obtained by projecting the original grid. The correction weight corresponding to the target area increases with the increase of the corresponding target distance, and based on the overlapping relationship between the segmented area and the target area, the target correction weight corresponding to each segmented area is determined, and the original grid and the projection grid are merged, so that the overall correction of the portrait is retained to the greatest extent. At the same time, the curvature of the background straight line is weakened by scene, which can effectively correct the distorted area in the image and reduce the background curvature. The correction degree is adaptively adjusted by region, thereby effectively improving the visual effect of the corrected image. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0034] Figure 1 A diagram showing an application environment of an image correction method in an embodiment;

[0035] Figure 2 is a schematic flow chart of an image correction method in one embodiment;

[0036] Figure 3 is an initial grid map corresponding to the image to be corrected in one embodiment;

[0037] Figure 4 is a target grid map corresponding to the image to be corrected in one embodiment;

[0038] Figure 5 A schematic diagram of adjusting a face region to obtain a target region in one embodiment;

[0039] Figure 6 A schematic diagram of determining a correction weight corresponding to a target area based on a target distance and a reference distance in one embodiment;

[0040] Figure 7 Schematic diagram of determining a correction weight corresponding to a target area based on a target distance, a first reference distance, and a second reference distance in one embodiment

[0041] Figure 8 is a structural block diagram of an image correction device in one embodiment;

[0042] Fig. 9 FIG. 4 is a block diagram of the internal structure of an electronic device in one embodiment. DETAILED DESCRIPTION

[0043] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0044] Figure 1 FIG. 1 is an application environment diagram of an image correction method in an embodiment. Figure 1 As shown, the application environment includes a terminal 110 and a server 120. The image correction method can be completed independently by the terminal 110 or the server 120, or can be completed by the terminal 110 or the server 120 in cooperation. The terminal 110 or the server 120 obtains the image to be corrected, and detects the target area where the target object is located in the image to be corrected;

[0045] Obtain the target distance between the target area and the preset reference point in the image to be corrected, determine the correction weight corresponding to the target area based on the target distance, and the correction weight corresponding to the target area increases as the corresponding target distance increases; segment the image to be corrected to obtain the corresponding segmented area; determine the target correction weight corresponding to each segmented area based on the overlapping relationship between the segmented area and the target area; fuse the original grid and the projected grid corresponding to each segmented area based on the target correction weight to obtain the target grid corresponding to each segmented area, and perform correction processing on the image to be corrected based on the target grid corresponding to each segmented area to obtain the corrected target image. The terminal 110 may be a terminal device including a mobile phone, a tablet computer, a PDA (Personal Digital Assistant), a car computer, a wearable device, etc. The terminal device can obtain various types of images to be corrected, including but not limited to continuous image frames in a video, images captured in real time, images downloaded from a server, etc. The server 120 may be a server or a server cluster.

[0046] Figure 2 FIG. 4 is a flowchart of an image correction method in one embodiment. Figure 2 The image correction method shown can be applied to the above-mentioned terminal 110 or server 120, including:

[0047] Step 202: Acquire the image to be corrected.

[0048] Among them, the image to be corrected refers to the image that needs to be corrected. Due to the complex environment in which the photographed object is located, the image captured in certain specific scenes may produce distortion and other phenomena, which makes the visual effect of the captured image poor, so it is necessary to correct the distorted area or deformed area in the captured image. For example, the distortion of the image captured by the wide-angle camera is large, and the intuitive feeling is that the image area at the edge of the image is curved. Therefore, in view of this phenomenon, the camera can be calibrated to obtain the internal reference, and then the collected image can be subjected to distortion correction processing to obtain the corrected image, thereby eliminating the distortion. The image to be corrected may include an image captured by the terminal, a video stream image captured by the camera, or an image to be corrected obtained by the terminal from the network. For example, the image to be corrected in the embodiment of the present application may be a video frame image in the video stream data, and some areas in the video frame image may be distorted, resulting in poor visual effects of the video frame image, so correction processing is required.

[0049] Specifically, the terminal can obtain the image to be corrected captured by the camera. In addition, the terminal can also download the image from the server or other cloud platform, and use the downloaded image as the image to be corrected. The method of obtaining the image to be corrected is not limited here. It can be understood that the image to be corrected in this embodiment can also be each frame of the video stream captured in real time as the image to be corrected.

[0050] For example, a user may start an application with an image recognition function in a terminal through a trigger operation, and the application calls a built-in camera in the terminal to acquire an image to be corrected.

[0051] Step 204: Detect the target area where the target object is located in the image to be corrected.

[0052] The target object refers to the object that is distorted in the image to be corrected, for example, the target object may include a distorted face, a distorted portrait, a distorted object, a distorted animal, etc. The target area refers to the area where the distorted object in the image to be corrected is located, for example, the target area may include the area where the distorted face is located and the area where the distorted portrait is located, etc.

[0053] Specifically, after the terminal obtains the image to be corrected, the terminal can detect the target area where the target object that is distorted in the image to be corrected is located. For example, the portrait in the image to be corrected is used as the target object for explanation. There are usually two ways to determine the correction range of the portrait, namely face detection and portrait segmentation. In the traditional way, the local correction method usually requires relatively fine portrait edge information, otherwise the lines of the portrait edge will be distorted after correction. However, in the embodiment of the present application, fine portrait edge information is not required. After the terminal obtains the image to be corrected, the terminal can use a preset face detection method to detect the target object that is distorted in the image to be corrected, that is, the terminal can use any third-party face detection technology to detect the target object that is distorted in the image to be corrected, and the target face frame in the image to be corrected can be obtained. The range of the target face frame is usually from the eyebrows of the target face to the chin of the target face. The target face frame is the target area where the distorted target face in the image to be corrected detected by the terminal is located. In addition, the terminal can further optimize and adjust the detected target face frame appropriately. For example, the terminal can optimize and adjust the target face frame appropriately according to a preset optimization and adjustment method to obtain an optimized and adjusted target face frame, such as taking the face as the center and expanding a preset range around to obtain an optimized and adjusted target face frame. It can be understood that the detection method used in the embodiments of the present application includes but is not limited to face detection, and can also include other detection methods. The method for detecting the target area where the target object is located is not specifically limited here.

[0054] Step 206 , obtaining a target distance between the target area and a preset reference point in the image to be corrected, and determining a correction weight corresponding to the target area based on the target distance, wherein the correction weight corresponding to the target area is positively correlated with the target distance.

[0055] The position of the preset reference point can be customized, and is generally the center of the image to be corrected. According to experiments, the target area of ​​the image captured by the camera with a larger field of view, such as a face, has a greater degree of distortion. In the same image, the closer the target area is to the edge of the image, the greater the degree of distortion. Therefore, target areas at different positions in the image have different degrees of correction.

[0056] Specifically, the correction degree of the area closer to the center position of the image to be corrected is smaller, and the correction degree of the area closer to the edge position of the image to be corrected is greater. The algorithm for calculating the target distance between the target area and the preset reference point in the image to be corrected can be customized, such as calculating the distance between the target point at the preset position of the target area and the preset reference point of the image to be corrected as the target distance, where the target point can be the center point of the target area or the vertex of the target area. When there are multiple target points, the final target distance can be determined based on the distance between the multiple target points and the preset reference point in the image to be corrected. The preset reference point of the image to be corrected can be the center point of the image to be corrected, or a point within a preset range of the center point of the image to be corrected, and can be customized according to the content or needs of the image.

[0057] The correction weight corresponding to the target area increases as the corresponding target distance increases. One or more reference distances can be set, and the correction weight corresponding to the target area can be determined based on the functional relationship between the target distance and the reference distance. The reference distance can be determined based on image attributes, such as image width, image acquisition parameters, such as the field of view corresponding to the image, etc.

[0058] In one embodiment, a first reference distance and a second reference distance are set, wherein the first reference distance is greater than the second reference distance, when the target distance is less than or equal to the second reference distance, the correction weight corresponding to the target area is determined by the first function, when the target distance is greater than the second reference distance and less than the first reference distance, the correction weight corresponding to the target area is determined by the second function, and when the target distance is greater than or equal to the first reference distance, the correction weight corresponding to the target area is determined by the third function. Through multiple reference distances, different functional relationships can be set within different distance ranges to calculate the correction weight corresponding to the target area, thereby improving the adaptability and accuracy of the correction weight determination.

[0059] Step 208 , segmenting the image to be corrected to obtain a plurality of segmented regions, and determining the target correction weight corresponding to each segmented region based on the overlapping relationship between the segmented regions and the target region.

[0060] Specifically, the size of the block size of the image block segmentation can be customized. In one embodiment, the image is divided into four areas of the same size. A target area can overlap with one or more segmented areas at the same time, and a segmented area can overlap with one or more target areas at the same time. The conditions for determining whether there is an overlap can be customized, such as exceeding a preset area to determine that there is an overlapping relationship, or reaching a preset ratio to determine that there is an overlapping relationship. The target area that has an overlapping relationship with the segmented area is obtained as a reference area, and the target correction weight corresponding to the segmented area is determined according to the correction weight of the reference area, wherein the determination method can be customized. For example, when there are multiple reference areas, the correction weights corresponding to the reference areas are weighted to obtain the target correction weight corresponding to the segmented area, or the maximum correction weight in the reference area is selected as the target correction weight.

[0061] In one embodiment, the target correction weight corresponding to each segmented area can also be adjusted based on facial features, gender, age and other information. According to the preferences of different users, it is decided whether to correct the face better or keep the background better. The correction of the target area will cause the background straight line to bend, so a balance is needed between the two. In one embodiment, when a female user uses it, the overall correction weight is increased to ensure that the face shape is not distorted. When a male user uses it, the overall correction weight is reduced, so that the background straight line is less bent while slightly correcting the face.

[0062] Step 210, based on the target correction weight, the original grid and the projected grid corresponding to each segmented area are merged to obtain the target grid corresponding to each segmented area, and the image to be corrected is corrected based on the target grid corresponding to each segmented area to obtain the corrected target image. The original grid is a grid map obtained by gridding the image to be corrected, and the projected grid is a grid map obtained by projecting the original grid.

[0063] Among them, gridding processing refers to gridding processing of the image to be corrected. Gridding is to divide the image to be corrected into many small units. As the top priority of pre-processing of finite element analysis, the degree of matching between gridding and calculation target and the quality of grid determine the quality of subsequent finite element calculation. For example, gridding can include structured gridding and unstructured gridding, and gridding processing methods can include multiple gridding processing methods such as directly using open source grid tools and custom grid processing methods. The original grid refers to the grid map obtained after gridding the image to be corrected. For example, according to the preset grid parameters, the image to be corrected is gridded to obtain the original grid map corresponding to the image to be corrected, wherein each segmented area has a corresponding original grid in the original grid map corresponding to the image to be corrected according to the position relationship. The original grid map can include at least one of a uniform grid map, a non-uniform initial grid map, and the like. A uniform initial grid map means that the grid density of the original grid map is uniform, and a non-uniform initial grid map means that the grid density of the original grid map is non-uniform.

[0064] Projection transformation refers to the projection transformation processing of the grid map. The projection transformation processing may include multiple types of projection transformation processing methods. For example, the projection transformation processing method in the embodiment of the present application may be a stereographic projection transformation (i.e., stereoscopic plane projection). In geometry, stereoscopic plane projection (projection) is a mapping that projects a spherical surface onto a plane. A projection grid map refers to a grid map composed of grid points after projection transformation is performed on all grid points of the original grid map. Each segmented area has a corresponding projection grid in the projection grid map corresponding to the image to be corrected according to the positional relationship.

[0065] Specifically, the original mesh and the projected mesh corresponding to each segmented area are fused based on the target correction weight. The larger the target correction weight, the higher the fusion ratio of the projected mesh during fusion. If the target correction weight is 0, it means that only the original mesh exists in the target mesh. If the target correction weight is the maximum correction value, it means that only the projected mesh exists in the target mesh. In one embodiment, the original mesh and the projected mesh are fused by the following formula: Mesh = L / 10*stereo mesh + (1-L / 10)*original mesh, Mesh represents the target mesh, and the stereo mesh represents the mesh obtained by stereographic projection transformation (i.e., spherical plane projection). When the terminal adopts the spherical plane projection transformation, the terminal performs a spherical plane projection transformation on all mesh points in the target area to obtain a stereo mesh, wherein the formula of the spherical plane projection transformation is as follows:

[0066] d=min(W,H)

[0067] r0=d / (2.0*tan(0.5*atan(d / (2.0*f))))

[0068] rp=sqrt(x^2+y^2)

[0069] theta=tan(y / x)

[0070] ru=r0*tan(0.5*atan(rp / f));

[0071] X'=ru*sin(theta)

[0072] Y'=ru*cos(theta)

[0073] Where W is the image width, H is the image height, f is the equivalent focal length of the camera corresponding to the image, x, y are the grid coordinates before projection, and X', Y' are the grid coordinates after projection.

[0074] Correction processing refers to performing distortion correction processing on the image to be corrected based on the target grid. For example, the correction processing method used in this example can be a grid interpolation correction calculation method. For example, Figure 3 As shown, it is a schematic diagram of correcting the image to be corrected based on the target grid map. Figure 3 is the initial grid corresponding to the image to be corrected, Figure 4 is the target grid corresponding to the image to be corrected. That is, the terminal can interpolate the image to be corrected based on the target grid obtained after adjustment by using the grid interpolation correction calculation method to obtain the corrected target image.

[0075] In the traditional method, interpolation calculation usually needs to calculate the mapping relationship of each pixel in the image, so the amount of calculation is too large. In this embodiment, the image to be corrected is gridded, so only the mapping relationship of the grid points needs to be calculated to perform interpolation. The other pixel points inside the four grid vertices corresponding to the target area can be mapped in the form of affine transformation. Therefore, the additional amount of calculation is greatly reduced, thereby effectively improving the computational efficiency of the image distortion correction processing. Since different segmented areas correspond to different target correction weights, the obtained target grid adaptively adjusts the fusion ratio of the original grid and the projected grid during fusion, so that the target grid can effectively correct the distorted area in the image during the correction processing, while reducing the background curvature, and adaptively adjust the correction degree by region, thereby effectively improving the visual effect of the corrected image.

[0076] The image correction method in this embodiment obtains the image to be corrected, detects the target area where the target object is located in the image to be corrected; obtains the target distance between the target area and a preset reference point in the image to be corrected, and determines the correction weight corresponding to the target area based on the target distance, wherein the correction weight corresponding to the target area is positively correlated with the target distance; segments the image to be corrected to obtain a plurality of segmented areas; determines the target correction weight corresponding to each segmented area based on the overlapping relationship between the segmented area and the target area; fuses the original grid and the projected grid corresponding to each segmented area based on the target correction weight to obtain the target grid corresponding to each segmented area, and corrects the image to be corrected based on the target grid corresponding to each segmented area. Positive processing is performed to obtain a target image after correction processing. The original grid is a grid map obtained by gridding the image to be corrected, and the projection grid is a grid map obtained by projecting the original grid. The correction weight corresponding to the target area increases with the increase of the corresponding target distance, and based on the overlapping relationship between the segmented area and the target area, the target correction weight corresponding to each segmented area is determined, and the original grid and the projection grid are merged to retain the overall correction of the portrait to the greatest extent. At the same time, the curvature of the background straight line is weakened by scene, which can effectively correct the distorted area in the image and reduce the background curvature. The correction degree is adaptively adjusted by region, thereby effectively improving the visual effect of the corrected image.

[0077] In one embodiment, step 204 includes: detecting a face region of a target object in the image to be corrected; and expanding the face region to obtain a target region, wherein the target region includes a head region of the target object.

[0078] Specifically, face detection can be used to first distinguish between scenes with faces and scenes without faces. For scenes without faces, no distortion correction is performed, and the target correction weight of the image to be corrected is 0. If a face is present, the face area is expanded to obtain a target area, and the target area includes the head area of ​​the target object. If it is a frontal face, the target area includes the hair. If it is a side face, the target area includes the side area of ​​the head. The target area may be a regular shape area, such as a rectangular area. It may also be a trapezoidal area or other shapes that are adaptively adjusted according to the detection results. In one embodiment, the target area where the target object is located is a rectangular frame with the face as the core, including the hair, and the side face includes the back of the head and other areas. Figure 5 As shown, it is a schematic diagram of adjusting the target area. Figure 5 (1) is a schematic diagram of the target face frame. Figure 5 (2) is a schematic diagram of the target face frame after optimization and adjustment. That is, the terminal can use any face detection technology to detect the area where the target face is located in the image to be corrected, and obtain the following Figure 5Further, the terminal can optimize and adjust the detected target face frame area using a preset optimization adjustment method, and obtain the following: Figure 5 The optimized and adjusted target face frame area shown in (2) is used as the target area.

[0079] In this embodiment, after the face area is detected, the face area is expanded to obtain the area including the head as the target area where the target object is located, so that the face area and the head area form a whole, thereby improving the accuracy of subsequent calculation of the target distance and the target correction weight through the target area, thereby improving the quality of the corrected image.

[0080] In one embodiment, Figure 6 As shown, the target area is a rectangular area, and step 206 includes:

[0081] Step 206A, obtaining each vertex of the target area, calculating the radial distance between each vertex and a preset reference point in the image to be corrected, and obtaining the maximum value of the radial distances of each vertex as the target distance.

[0082] Specifically, if the target area is a rectangular area including four vertices, the radial distances between the four vertices and a preset reference point in the image to be corrected are calculated, wherein the preset reference point may be the center point of the image to be corrected, and the maximum value is obtained from each radial distance as the target distance.

[0083] Step 206B: determining a reference distance according to the size of the image to be corrected and the field of view angle corresponding to the image to be corrected.

[0084] Specifically, the size of the image to be corrected includes length and width, and the first reference distance can be determined according to the size of the image to be corrected, and the determination method can be customized. The second reference distance is determined according to the field of view corresponding to the image to be corrected, and the determination method can be customized, wherein the second reference distance is smaller than the first reference distance.

[0085] Step 206C: determining a correction weight corresponding to the target area based on the target distance and the reference distance.

[0086] Specifically, the correction weight corresponding to the target area is determined according to the relationship between the target distance and the first reference distance and the second reference distance. Different functions can be determined for different distance ranges, and the correction weight corresponding to the target area is obtained with the target distance as a variable. Different functions can be linear functions or nonlinear functions, and it is only necessary to satisfy that the correction weight corresponding to the target area obtained according to the function increases with the increase of the corresponding target distance. It can be understood that within a certain distance range, the correction weight corresponding to the target area can be a fixed value.

[0087] In this embodiment, the target distance is determined based on the maximum radial distance between the vertex position and a preset reference point in the image to be corrected, and the correction weight corresponding to the target area is determined based on the relationship between the reference distance and the target distance. Different distance relationships exist between different target distances and reference distances, so the corresponding correction weight can be determined based on different algorithms, thereby improving the accuracy and adaptability of the correction weight determination.

[0088] In one embodiment, Figure 7 As shown, the reference distance is determined according to the size of the image to be corrected and the field of view angle corresponding to the image to be corrected, and the correction weight corresponding to the target area is determined based on the target distance and the reference distance, including:

[0089] Step 302: determine a first reference distance according to the size of the image to be corrected, and determine a second reference distance according to the field of view corresponding to the image to be corrected.

[0090] Specifically, the size of the image to be corrected can be calculated to obtain the first reference distance. In one embodiment, the width of the image to be corrected is divided by 2 as the first reference distance. The second reference distance is determined according to the field of view corresponding to the image to be corrected. The size of the field of view determines the field of view of the optical instrument. The field of view can be FOV. Images corresponding to different field of views use different second reference distances.

[0091] Step 304: If the target distance is less than or equal to the second reference distance, determine that the correction weight corresponding to the target area is the first target weight.

[0092] Specifically, take the largest radial distance r from the image center among the four vertices of the target area box, take the second reference distance as r0, and draw a circle with r0 as the radius in the image to be corrected. If r is less than or r0, the correction weight corresponding to the target area is determined to be the first target weight. The size of the first target weight can be customized. In one embodiment, the first target weight is 0, indicating that the target area close to the center point of the image does not need to be corrected.

[0093] Step 306: If the target distance is greater than the second reference distance and less than the first reference distance, the correction weight corresponding to the target area is the second target weight, and the second target weight increases monotonically with the target distance.

[0094] Specifically, if r is less than the first reference distance and r is greater than r0, the weight increases monotonically. In one embodiment, r is between r0 and col / 2, and the weight increases monotonically, where col represents the width of the image to be corrected. The increase can be linear or nonlinear, and the increase curve can be obtained based on experiments and subjective adjustments.

[0095] Step 308, if the target distance is greater than or equal to the first reference distance, the correction weight corresponding to the target area is the third target weight; wherein the first target weight is less than the second target weight, the second target weight is less than the third target weight, and the first reference distance is greater than the second reference distance.

[0096] Specifically, if the target distance is greater than or equal to the first reference distance, the correction weight corresponding to the target area is determined to be the third target weight, and the size of the third target weight can be customized. In one embodiment, the first target weight is the maximum value, indicating that the target area close to the edge of the image is corrected to the maximum extent. The first target weight is less than the second target weight, the second target weight is less than the third target weight, and the first reference distance is greater than the second reference distance, thereby ensuring that the correction weight corresponding to the target area increases with the increase of the corresponding target distance.

[0097] In this embodiment, different correction weights are determined for different target areas through the relationship between the target distance and the first reference distance and the second reference distance. When the target area is smaller than the second reference distance, indicating that it is closer to the center of the image, a smaller correction weight is set as a fixed value. When the target area is larger than the first reference distance, indicating that it is closer to the edge of the image, a larger correction weight is set as a fixed value. When the target area is between the first reference distance and the second reference distance, a variable correction weight is set. The weight increases monotonically with the size of the target distance, so that the correction weight can be adaptively adjusted according to the position of the target area, thereby improving the matching and accuracy of the correction weight determination.

[0098] In one embodiment, after step 208, it also includes: obtaining a weight correction coefficient based on the area of ​​the target area; correcting the correction weight corresponding to the target area according to the weight correction coefficient, and the weight correction coefficient makes the correction weight corresponding to the target area inversely correlated with the area of ​​the target area.

[0099] Specifically, when the size of the face reaches a certain size, such as when it is very close to the camera, the distortion becomes less obvious in subjective perception. Therefore, faces of different sizes also have different correction weights. Based on the size of the target area, a smaller weight correction coefficient is set for a target area with a large area, so that after the weight correction coefficient is applied to the correction weight corresponding to the target area, the correction weight becomes smaller. In one embodiment, the corresponding weight correction coefficient can be set according to the ratio of the area of ​​the target area to the total area of ​​the image to be corrected. The larger the ratio, the smaller the weight correction coefficient. For example, for a 4000*3000 pixel image to be corrected, when the area of ​​the target area is 300*300, the weight correction coefficient is set to 1, when the area of ​​the target area is 400*400, the weight correction coefficient is set to 0.8, and when the area of ​​the target area is 800*800, the weight correction coefficient is set to 0.1. The specific corresponding relationship can be customized as needed.

[0100] In this embodiment, the correction weight corresponding to the target area is adjusted by the area of ​​the target area. The larger the area of ​​the target area, the smaller the correction weight will be. Therefore, the correction weight corresponding to the target area can be corrected by the weight correction coefficient to further conform to the viewing characteristics of the human eye.

[0101] In one embodiment, in step 208, based on the overlapping relationship between the segmented area and the target area, determining the target correction weight corresponding to each segmented area includes: for each segmented area, taking the target area having an overlapping area with the segmented area as the reference area of ​​the segmented area; obtaining the maximum correction weight among the correction weights corresponding to the reference areas of the segmented area as the target correction weight corresponding to the segmented area.

[0102] Specifically, for each segmented area, a target area having an overlapping area with the segmented area is obtained. For example, if the target area having an overlapping area with the segmented area includes three face areas A, B and C, then the three face areas A, B and C are all used as reference areas of the segmented area, and the maximum correction weight among the correction weights corresponding to the reference areas of the segmented area is obtained as the target correction weight corresponding to the segmented area, that is, the maximum value is obtained from the correction weights corresponding to the three face areas A, B and C as the target correction weight corresponding to the segmented area. If the image to be corrected has 4 segmented areas, the target correction weights corresponding to each segmented area are determined using the above method for each of the 4 segmented areas.

[0103] In this embodiment, the maximum correction weight among the correction weights in the target area having an overlapping area with the segmented area is used as the target correction weight corresponding to the segmented area, so that when there are multiple target areas in the segmented area, the target correction weight can be adaptively determined.

[0104] In one embodiment, step 210 includes: obtaining a global projection grid corresponding to the current segmented area; obtaining a first fusion coefficient and a second fusion coefficient based on a target correction weight; using the first fusion coefficient as the fusion weight of the global projection grid, and the second fusion coefficient as the original grid fusion weight, and fusing the original grid and the projection grid corresponding to the current segmented area to obtain a target grid corresponding to the current segmented area, wherein the first fusion coefficient is positively correlated with the target correction weight, and the second fusion coefficient is negatively correlated with the target correction weight.

[0105] Specifically, the global projection grid refers to the grid obtained by processing the original grid with global projection. The relationship between the target correction weight and the fusion coefficient can be customized to obtain the fusion weight of the global projection grid and the fusion weight corresponding to the original grid respectively. The larger the target correction weight, the larger the fusion weight of the global projection grid during the fusion process. Therefore, the target correction weight is positively correlated with the first fusion coefficient, and the target correction weight is negatively correlated with the second fusion coefficient. For example, in one embodiment, the target correction weight is L, where the first fusion coefficient is L / 10, and the second fusion coefficient is 1-L / 10.

[0106] In this embodiment, the matching first fusion coefficient and the second fusion coefficient are obtained by adaptively calculating the target correction weight, so that the global projection grid and the original grid are fused according to different fusion weights to obtain a target grid with better correction image effect.

[0107] In one embodiment, the method further includes: acquiring video stream data, the video stream data including multiple video frame images; and performing correction processing on the video frame images in sequence as images to be corrected to obtain corresponding multiple target image frames.

[0108] Specifically, the terminal can obtain video stream data, and the video stream data can be real-time video stream data acquired by a camera built into the terminal, or non-real-time video stream data downloaded from a server by the terminal. Further, the terminal can use each frame of video frame image in the video stream data as an image to be corrected for correction processing to obtain multiple frames of target images. That is, the terminal uses each frame of video frame image in the video stream data as an image to be corrected, and detects the target area where the target object in the image to be corrected is located; obtains the target distance between the target area and a preset reference point in the image to be corrected, and determines the correction weight corresponding to the target area based on the reference distance, and the correction weight corresponding to the target area increases as the corresponding target distance increases; the image to be corrected is segmented to obtain the corresponding segmented area; based on the overlapping relationship between the segmented area and the target area, the target correction weight corresponding to each segmented area is determined; based on the target correction weight, the original grid and the projected grid corresponding to each segmented area are merged to obtain the target grid corresponding to each segmented area, and the image to be corrected is corrected based on the target grid corresponding to each segmented area to obtain the corrected target image, and after correcting each video frame image, a video stream after distortion correction processing is obtained.

[0109] In this embodiment, by using the video frame image as the image to be corrected for correction processing, the distorted area in the image can be effectively corrected, while the background curvature can be reduced, and the correction degree can be adaptively adjusted by region, thereby effectively improving the visual effect of the corrected image. In addition, the correction processing in this embodiment has a high computational efficiency and can process video stream data in real time, effectively ensuring the continuity and image quality of video stream viewing.

[0110] In one embodiment, after determining the target correction weights corresponding to each segmented area based on the overlapping relationship between the segmented area and the target area, it also includes: obtaining a forward image of the image to be corrected in the video stream data; determining the current segmented area from the segmented areas, and obtaining a forward segmented area that matches the current segmented area in the forward image; and obtaining a smoothed target correction weight corresponding to the current segmented area based on the smoothed target correction weight corresponding to the forward segmented area and the target correction weight corresponding to the current segmented area.

[0111] Specifically, with the target correction weights corresponding to the segmented areas, a relatively accurate correction result can be obtained for each frame. However, in the video, if the correction degree between frames differs too much, it will cause image jumps, which greatly affects the viewing quality of the user. Therefore, based on the smoothed target correction weights corresponding to the forward video frames, the target correction weights corresponding to each segmented area are smoothed. The smoothed target correction weight corresponding to the current segmented area is obtained by solving the following formula:

[0112]

[0113] in, represents the target correction weight after smoothing, L represents the original target correction weight, t represents the time, t-1 represents the previous time in the video stream, wherein w1 and w2 represent weighting coefficients, which can be customized. In one embodiment, w1=0.9, w2=0.1.

[0114] For scenarios with high real-time requirements, The smoothed target correction weight corresponding to the current segmented area is quickly calculated.

[0115] Specifically, when performing the calculation, it is necessary to first obtain the forward image of the image to be corrected in the video stream data, and then obtain the forward segmentation area corresponding to the current segmentation area from the forward image, that is, the area at the same position, so as to obtain the smoothed target correction weight corresponding to the forward segmentation area, and further smooth the target correction weight corresponding to the current segmentation area through the above formula.

[0116] In this embodiment, the target correction weight of the current image is smoothed by the smoothed target correction weight corresponding to the forward image in the video stream, thereby improving the smoothness between the images in the video stream and further improving the quality of the corrected video image.

[0117] In a specific embodiment, it can be applied to the scene of real-time processing of portrait distortion correction in video stream data. The following takes the real-time correction of the portrait distortion area in the video stream data as an example to illustrate the image correction method provided by the embodiment of the present application, including the following steps:

[0118] 1. Scene judgment

[0119] Take a frame of image in the real-time video stream data as the image to be corrected, detect the target area where the target object is located in the image to be corrected, and use face detection to first detect the image to be corrected to distinguish between scenes with portraits and scenes without portraits. No portrait distortion correction is performed for scenes without portraits, and the target correction weight is 0. The target correction degree is defined as 0-10, where 0 means no correction at all and 10 means full correction. For scenes with portraits, the next step is to calculate the target correction weight. In the embodiment of the present application, detailed portrait edge information is not required. After the terminal obtains the image to be corrected, the terminal can use any face detection technology to obtain the target face frame in the image to be corrected. The range of the target face frame is usually from the eyebrows of the target face to the chin of the target face. The terminal can further perform appropriate optimization adjustments based on the angle of the face, for example, Figure 4The (2) shown is a schematic diagram of the optimized and adjusted target face frame. That is, the terminal appropriately enlarges the original target face frame according to the angle of the face to obtain the target area where the face is located. One frame of an image may include one or more target areas. In this embodiment, no portrait edge information is required, and only the face frame information is used for appropriate optimization and adjustment, greatly reducing the extra calculation amount, thereby effectively improving the calculation efficiency of image distortion correction processing.

[0120] 2. Correction weight calculation

[0121] According to experiments, for the target area of an image captured by a shooting device with a larger field of view angle, such as the face, the greater the degree of distortion. In the same picture, the greater the degree of distortion of the target area closer to the image edge. Therefore, the target areas at different positions in the image have different correction degrees L. For the portrait in the center of the image, L = 0, and for the portrait close to the image edge, L = 10. When the size of the face reaches a certain extent, including when it is very close to the camera, the distortion becomes less obvious subjectively. Therefore, different sizes of faces also have different correction weights. In this application, the correction degrees of all n faces in the image are calculated respectively, denoted as L1 - Ln.

[0122] Specifically, take the maximum radial distance r from the four vertices of the face target area to the center of the image. Divide the width of the image to be corrected by 2, that is, col / 2 as the first reference distance. Determine the second reference distance r0 according to the field of view angle corresponding to the image to be corrected. With the second reference distance as r0, draw a circle with a radius of r0 in the image to be corrected. If r >= col / 2, the target weight corresponding to the face target area is 10. If r <= r0, the target weight corresponding to the face target area is 0. If r0 < r < col / 2, the target weight increases monotonically and non-linearly with the increase of r, and the increasing curve can be obtained according to experiments and subjective adjustment.

[0123] Obtain a weight correction coefficient based on the area of the face target area, and correct the correction weight corresponding to the target area according to the weight correction coefficient. The weight correction coefficient makes the correction weight corresponding to the target area inversely proportional to the area of the target area. For example, if the area of face target area A > the area of face target area B, then the weight correction coefficient of face target area A is 0.3, and the area of face target area B is 0.8. The larger the area of the face target area, the smaller the weight correction coefficient. Multiply the weight correction coefficient by the target weight corresponding to the face target area to obtain the corrected target weight.

[0124] 3. Partition correction degree calculation

[0125] The image to be corrected is evenly divided into 4 regions to obtain the corresponding 4 segmented regions. For each segmented region, the maximum value of the face correction weight in the region is taken as the target correction weight of the region, which is defined as the four values ​​of L_lu, L-ru, L-ld, and L-rd.

[0126] Specifically, for each segmented region, a target face region having an overlapping area with the current segmented region is obtained as a reference region for the current segmented region. For example, if the target face region having an overlapping area with the current segmented region includes face region A and face region B, face region A and face region B are used as reference regions for the current segmented region. The maximum correction weight among the correction weights corresponding to the reference regions of the current segmented region is obtained as the target correction weight corresponding to the current segmented region.

[0127] 4. Calculation of smoothing correction degree

[0128] When performing calculations, it is necessary to first obtain the forward image of the image to be corrected in the video stream data, and then obtain the forward segmentation area corresponding to the current face target area from the forward image, that is, the area at the same position, so as to obtain the smoothed target correction weight corresponding to the forward segmentation area, and further smooth the target correction weight corresponding to the current face target area by the following formula:

[0129]

[0130] in, represents the target correction weight after smoothing, L represents the original target correction weight, t represents the time, t-1 represents the previous time in the video stream, wherein w1 and w2 represent weighting coefficients, which can be customized. In one embodiment, w1=0.9, w2=0.1.

[0131] 5. Target mesh generation

[0132] Use the target correction weights corresponding to the four segmented areas to perform grid calculations on the four segmented areas of the image to be corrected:

[0133] Mesh = L / 10*stereo mesh + (1-L / 10)*original mesh

[0134] Among them, Mesh represents the target mesh, and stereo mesh represents the mesh obtained by stereographic projection transformation (i.e., stereoscopic plane projection).

[0135] The terminal performs distortion correction processing on each segmented area of ​​the video frame image based on the target grid corresponding to each segmented area, so as to obtain a target image after the distortion correction processing.

[0136] In this embodiment, an image in real-time video stream data is obtained as the image to be corrected, and a target area where a face is located in the image to be corrected is detected; a target distance between the target area and a center point in the image to be corrected is obtained, and a correction weight corresponding to the target area is determined based on the target distance, and the correction weight corresponding to the target area increases as the corresponding target distance increases, and the image to be corrected is segmented to obtain corresponding segmented areas; based on the overlapping relationship between the segmented areas and the target areas, the target correction weight corresponding to each segmented area is determined; based on the forward image of the image to be corrected in the video stream data, the target correction weight is smoothed, and based on the smoothed target correction weight, the original grid and the projected grid corresponding to each segmented area are fused to obtain the target grid corresponding to each segmented area. The image to be corrected is corrected based on the target grid corresponding to each segmented area to obtain the corrected target image, and the images in the real-time video stream data are corrected in turn to obtain the target video stream, wherein the correction weight corresponding to the target area increases with the increase of the corresponding target distance, and based on the overlapping relationship between the segmented area and the target area, the target correction weight corresponding to each segmented area is determined, and the original grid and the projected grid are merged, so that the overall correction of the portrait is retained to the greatest extent, and the curvature of the background straight line is weakened by the scene, which can effectively correct the distorted area in the image, and reduce the background curvature, and the correction degree is adaptively adjusted by region, thereby effectively improving the visual effect of the corrected image. The target correction weight of the current image is smoothed by the smoothed target correction weight corresponding to the forward image in the video stream, which improves the smoothness between the images in the video stream and further improves the quality of the corrected video image.

[0137] It should be understood that although Figure 2 , 6 The steps in the flowchart of -7 are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2 , 6 -At least part of the steps in 7 may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0138] Figure 8 FIG. 4 is a structural block diagram of an image correction device 400 according to an embodiment. Figure 8As shown, an image correction device 400 includes: an acquisition module 402, a detection module 404, a correction weight calculation module 406, a target correction weight determination module 408, and a correction module 410. Among them:

[0139] The acquisition module 402 is used to acquire the image to be corrected.

[0140] The detection module 404 is used to detect the target area where the target object is located in the image to be corrected.

[0141] The correction weight calculation module 406 is used to obtain the target distance between the target area and a preset reference point in the image to be corrected, and determine the correction weight corresponding to the target area based on the target distance. The correction weight corresponding to the target area is positively correlated with the target distance.

[0142] The target correction weight determination module 408 is used to segment the image to be corrected to obtain a plurality of segmented regions, and determine the target correction weight corresponding to each segmented region based on the overlapping relationship between the segmented regions and the target region.

[0143] The correction module 410 is used to fuse the original grid and the projected grid corresponding to each segmented area based on the target correction weight to obtain the target grid corresponding to each segmented area, and to perform correction processing on the image to be corrected based on the target grid corresponding to each segmented area to obtain the target image after correction processing. The original grid is a grid map obtained by gridding the image to be corrected, and the projected grid is a grid map obtained by projecting the original grid.

[0144] The image correction device 400 in this embodiment obtains the image to be corrected, detects the target area where the target object is located in the image to be corrected; obtains the target distance between the target area and a preset reference point in the image to be corrected, and determines the correction weight corresponding to the target area based on the target distance, wherein the correction weight corresponding to the target area is positively correlated with the target distance; segments the image to be corrected to obtain multiple segmented areas; determines the target correction weight corresponding to each segmented area based on the overlapping relationship between the segmented area and the target area; and fuses the original grid and the projected grid corresponding to each segmented area based on the target correction weight to obtain the target grid corresponding to each segmented area, wherein the original grid is a grid map obtained by gridding the image to be corrected. The projection grid is a grid map obtained by projecting the original grid. The image to be corrected is corrected based on the target grids corresponding to each segmented area to obtain a corrected target image. The correction weight corresponding to the target area increases with the increase of the corresponding target distance, and the target correction weight corresponding to each segmented area is determined based on the overlapping relationship between the segmented area and the target area. The original grid and the projection grid are merged to retain the overall correction of the portrait to the greatest extent. At the same time, the curvature of the background straight line is weakened according to the scene, which can effectively correct the distorted area in the image and reduce the background curvature. The correction degree is adaptively adjusted by region, thereby effectively improving the visual effect of the corrected image.

[0145] In one embodiment, the detection module 404 is further used to detect the face region of the target object in the image to be corrected; the face region is expanded to obtain the target region, wherein the target region includes the head region of the target object.

[0146] The image correction device 400 in this embodiment, after detecting the face area, obtains the target area by expanding the face area, and the target area includes the head area of ​​the target object, so that the face area and the head area form a whole, thereby improving the accuracy of subsequent calculation of the target distance and the target correction weight through the target area, thereby improving the quality of the corrected image.

[0147] In one embodiment, the target area is a rectangular area, and the correction weight calculation module 406 is also used to obtain each vertex of the target area; calculate the radial distance between each vertex and a preset reference point in the image to be corrected, and obtain the maximum value of the radial distances of each vertex as the target distance; determine the reference distance according to the size of the image to be corrected and the field of view corresponding to the image to be corrected; and determine the correction weight corresponding to the target area based on the target distance and the reference distance.

[0148] The image correction device 400 in this embodiment determines the target distance based on the maximum radial distance between the vertex position and a preset reference point in the image to be corrected, and determines the correction weight corresponding to the target area based on the relationship between the reference distance and the target distance. Different target distances have different distance relationships with the reference distance, so the corresponding correction weight can be determined based on different algorithms, which improves the accuracy and adaptability of the correction weight determination.

[0149] In one embodiment, the correction weight calculation module 406 is also used to determine a first reference distance according to the size of the image to be corrected; determine a second reference distance according to the field of view corresponding to the image to be corrected; if the target distance is less than or equal to the second reference distance, then determine that the correction weight corresponding to the target area is the first target weight; if the target distance is greater than the second reference distance and less than the first reference distance, then the correction weight corresponding to the target area is the second target weight, and the second target weight increases monotonically with the target distance; if the target distance is greater than or equal to the first reference distance, then the correction weight corresponding to the target area is the third target weight; wherein the first target weight is less than the second target weight, the second target weight is less than the third target weight, and the first reference distance is greater than the second reference distance.

[0150] In this embodiment, different correction weights are determined for different target areas through the relationship between the target distance and the first reference distance and the second reference distance. When the target area is smaller than the second reference distance, indicating that it is closer to the center of the image, a smaller correction weight is set as a fixed value. When the target area is larger than the first reference distance, indicating that it is closer to the edge of the image, a larger correction weight is set as a fixed value. When the target area is between the first reference distance and the second reference distance, a variable correction weight is set. The weight increases monotonically with the size of the target distance, so that the correction weight can be adaptively adjusted according to the position of the target area, thereby improving the matching and accuracy of the correction weight determination.

[0151] In one embodiment, the correction weight calculation module 406 is also used to obtain a weight correction coefficient based on the area of ​​the target area; the correction weight corresponding to the target area is corrected according to the weight correction coefficient, and the weight correction coefficient makes the correction weight corresponding to the target area inversely correlated with the area of ​​the target area.

[0152] The image correction device 400 in this embodiment adjusts the correction weight corresponding to the target area by the area of ​​the target area. The larger the target area, the smaller the correction weight. Thus, the correction weight corresponding to the target area can be corrected by the weight correction coefficient to further conform to the viewing characteristics of the human eye.

[0153] In one embodiment, the target correction weight determination module 408 is also used to, for each segmented area, use the target area having an overlapping area with the segmented area as a reference area for the segmented area; and obtain the maximum correction weight among the correction weights corresponding to the reference areas of the segmented area as the target correction weight corresponding to the segmented area.

[0154] The image correction device 400 in this embodiment uses the maximum correction weight among the correction weights in the target area that has an overlapping area with the segmented area as the target correction weight corresponding to the segmented area, so that when there are multiple target areas in the segmented area, the target correction weight can be adaptively determined.

[0155] In one embodiment, the correction module 410 is also used to obtain a global projection grid corresponding to the current segmented area; obtain a first fusion coefficient and a second fusion coefficient based on a target correction weight; use the first fusion coefficient as the fusion weight of the global projection grid, and the second fusion coefficient as the original grid fusion weight, and fuse the original grid and the projection grid corresponding to the current segmented area to obtain a target grid corresponding to the current segmented area, wherein the first fusion coefficient is positively correlated with the target correction weight, and the second fusion coefficient is negatively correlated with the target correction weight.

[0156] The image correction device 400 in this embodiment obtains the matching first fusion coefficient and second fusion coefficient by adaptively calculating the target correction weight, thereby fusing the global projection grid and the original grid according to different fusion weights to obtain a target grid with better image correction effect.

[0157] In one embodiment, the apparatus further comprises:

[0158] The video stream processing module 412 is used to obtain video stream data, which includes multiple video frame images; the video frame images are sequentially used as images to be corrected for correction processing to obtain corresponding multiple target image frames.

[0159] The image correction device 400 in this embodiment can effectively correct the distorted area in the image by using the video frame image as the image to be corrected, while reducing the background curvature and adaptively adjusting the correction degree by region, thereby effectively improving the visual effect of the corrected image. In addition, the correction processing in this embodiment has a high computational efficiency and can process video stream data in real time, effectively ensuring the continuity and image quality of video stream viewing.

[0160] In one embodiment, the target correction weight determination module 408 is also used to obtain a forward image of the image to be corrected in the video stream data; determine the current segmented area from the segmented areas, and obtain a forward segmented area that matches the current segmented area in the forward image; based on the smoothed target correction weight corresponding to the forward segmented area and the target correction weight corresponding to the current segmented area, obtain the smoothed target correction weight corresponding to the current segmented area.

[0161] In this embodiment, the target correction weight of the current image is smoothed by the smoothed target correction weight corresponding to the forward image in the video stream, thereby improving the smoothness between the images in the video stream and further improving the quality of the video image after correction.

[0162] For the specific definition of the image correction device, please refer to the definition of the image correction method above, which will not be repeated here. Each module in the above-mentioned image correction device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0163] Fig. 9 FIG. 1 is a schematic diagram of the internal structure of an electronic device in one embodiment. Fig. 9 As shown, the electronic device includes a processor and a memory connected via a system bus. The processor is used to provide computing and control capabilities to support the operation of the entire electronic device. The memory may include a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The computer program can be executed by the processor to implement the image correction method provided in each of the above embodiments. The internal memory provides a cache operating environment for the operating system computer program in the non-volatile storage medium. The electronic device may be a mobile phone, a server, etc.

[0164] The implementation of each module in the image correction device provided in the embodiment of the present application can be in the form of a computer program. The computer program can be run on a terminal or a server. The program modules constituted by the computer program can be stored in the memory of the terminal or the server. When the computer program is executed by the processor, the image correction method described in the embodiment of the present application is implemented.

[0165] The present application also provides a computer-readable storage medium, one or more non-volatile computer-readable storage media containing computer-executable instructions, which, when executed by one or more processors, enable the processors to perform the image correction method described in the present application.

[0166] A computer program product comprising instructions, when running on a computer, enables the computer to execute the image correction method described in the embodiments of the present application.

[0167] Any reference to memory, storage, database or other medium used in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM), which is used as an external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0168] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. An image correction method, characterized in that: include: Acquire an image to be corrected; Detecting a target area where a target object is located in the image to be corrected; Acquire a target distance between the target area and a preset reference point in the image to be corrected, and determine a correction weight corresponding to the target area based on the target distance, wherein the correction weight corresponding to the target area is positively correlated with the target distance; Segmenting the image to be corrected to obtain a plurality of segmented regions; Based on the overlapping relationship between the segmented areas and the target area, determining the target correction weight corresponding to each segmented area; Get the global projection grid corresponding to the current segmentation area; Obtaining a first fusion coefficient and a second fusion coefficient based on the target correction weight; The first fusion coefficient is used as the fusion weight of the global projection grid, and the second fusion coefficient is used as the original grid fusion weight. The original grid and the projection grid corresponding to the current segmented area are fused to obtain a target grid corresponding to the current segmented area. The first fusion coefficient is positively correlated with the target correction weight, and the second fusion coefficient is negatively correlated with the target correction weight. The image to be corrected is corrected based on the target grids corresponding to each segmented area to obtain a corrected target image. The original grid is a grid map obtained by gridding the image to be corrected, and the projection grid is a grid map obtained by projecting the original grid.

2. The method according to claim 1, characterized in that The detecting of the target area where the target object is located in the image to be corrected comprises: Detecting a face region of a target object in the image to be corrected; The face region is expanded to obtain a target region, wherein the target region includes a head region of the target object.

3. The method according to claim 1, characterized in that The target area is a rectangular area, and obtaining a target distance between the target area and a preset reference point in the image to be corrected, and determining a correction weight corresponding to the target area based on the target distance includes: Obtaining each vertex of the target area; Calculating the radial distance between each vertex and a preset reference point in the image to be corrected, and obtaining the maximum value of the radial distances of each vertex as the target distance; Determine the reference distance according to the size of the image to be corrected and the field of view angle corresponding to the image to be corrected; A correction weight corresponding to the target area is determined based on the target distance and the reference distance.

4. The method according to claim 3, characterized in that The step of determining the reference distance according to the size of the image to be corrected and the field of view angle corresponding to the image to be corrected, and determining the correction weight corresponding to the target area based on the target distance and the reference distance includes: Determine a first reference distance according to the size of the image to be corrected; Determine a second reference distance according to the field of view corresponding to the image to be corrected; If the target distance is less than or equal to the second reference distance, determining the correction weight corresponding to the target area to be the first target weight; If the target distance is greater than the second reference distance and less than the first reference distance, the correction weight corresponding to the target area is the second target weight, and the second target weight increases monotonically with the target distance; If the target distance is greater than or equal to the first reference distance, the correction weight corresponding to the target area is the third target weight; wherein the first target weight is less than the second target weight, the second target weight is less than the third target weight, and the first reference distance is greater than the second reference distance.

5. The method according to claim 1, characterized in that After determining the correction weight corresponding to the target area based on the target distance, the method further includes: Obtaining a weight correction coefficient based on the area of ​​the target area; The correction weight corresponding to the target area is corrected according to the weight correction coefficient, and the weight correction coefficient makes the correction weight corresponding to the target area inversely correlated with the area of ​​the target area.

6. The method according to claim 1, characterized in that The determining the target correction weight corresponding to each segmented area based on the overlapping relationship between the segmented area and the target area includes: For each segmented region, a target region having an overlapping area with the segmented region is used as a reference region of the segmented region; The maximum correction weight among the correction weights corresponding to the reference area of ​​the segmented area is obtained as the target correction weight corresponding to the segmented area.

7. The method according to claim 1, characterized in that The method further comprises: Acquire video stream data, wherein the video stream data includes multiple video frame images; The video frame images are sequentially used as images to be corrected for correction processing to obtain corresponding multiple frames of target images.

8. The method according to claim 7, characterized in that After determining the target correction weight corresponding to each segmented area based on the overlapping relationship between the segmented area and the target area, the method further includes: Acquire a forward image of the image to be corrected in the video stream data; Determine a current segmented region from the segmented regions, and obtain a forward segmented region matched by the current segmented region in the forward image; Based on the smoothed target correction weight corresponding to the forward segmented region and the target correction weight corresponding to the current segmented region, the smoothed target correction weight corresponding to the current segmented region is obtained.

9. An image correction device, characterized in that: include: An acquisition module, used for acquiring an image to be corrected; A detection module, used for detecting a target area where a target object is located in the image to be corrected; A correction weight calculation module, used for obtaining a target distance between the target area and a preset reference point in the image to be corrected, and determining a correction weight corresponding to the target area based on the target distance, wherein the correction weight corresponding to the target area is positively correlated with the target distance; A target correction weight determination module, used for segmenting the image to be corrected to obtain a plurality of segmented regions, and determining a target correction weight corresponding to each segmented region based on an overlapping relationship between the segmented regions and the target region; A correction module is used to obtain a global projection grid corresponding to a current segmented area, obtain a first fusion coefficient and a second fusion coefficient based on a target correction weight, use the first fusion coefficient as the fusion weight of the global projection grid, and use the second fusion coefficient as the original grid fusion weight, fuse the original grid and the projection grid corresponding to the current segmented area to obtain a target grid corresponding to the current segmented area, the first fusion coefficient is positively correlated with the target correction weight, and the second fusion coefficient is negatively correlated with the target correction weight, perform correction processing on the image to be corrected based on the target grids corresponding to each segmented area, and obtain a target image after correction processing, the original grid is a grid map obtained by gridding the image to be corrected, and the projection grid is a grid map obtained by projecting the original grid. 10 . An electronic device comprising a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the image correction method according to claim 1 .

11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the image correction method according to any one of claims 1 to 8 is implemented.

12. A computer program product comprising instructions, which, when executed on a computer, enables the computer to implement the image correction method according to any one of claims 1 to 8.