Image Processing Method, Apparatus, Electronic Device, and Readable Storage Medium
By obtaining the area ratio of faces in a multi-person selfie photo, and automatically adjusting the face size with the largest or smallest area, the problem of inconsistent face ratio in a multi-person selfie photo is solved, and the coordination of face size in the photo is achieved.
Patent Information
- Application Number
- CN202111416480.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-19
- Publication Date
- 2025-07-08
- Estimated Expiration
- 2041-11-19
AI Technical Summary
When taking selfies for multiple people, the proportions of different faces in the selfie photo are inconsistent, resulting in inconsistent face sizes and affecting the beauty of the photo.
By obtaining the area ratio of multiple faces, if the ratio is greater than the threshold, the face with the largest or smallest area is enlarged or reduced until the ratio reaches the threshold to achieve proportional coordination.
Automatically adjust the size of the face to coordinate the proportion of each face in the selfie photo, improving the aesthetics of the selfie photo.
Smart Images

Figure CN114093005B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of image processing technology, and specifically relates to an image processing method, device, electronic device and readable storage medium. Background Art
[0002] At present, taking selfies with the front camera has become one of the most common ways to take photos on mobile terminals. According to the number of people in the photo, selfies can be divided into single-person selfies and group selfies. Among them, when taking a group selfie, the person who is closer to the camera will appear larger in the selfie, while the person who is farther away from the camera will appear smaller in the selfie, making the proportions of the faces unbalanced.
[0003] For example, in daily life, when taking selfies with multiple people, most people will choose to use a selfie stick to shoot, which will make the faces of people who are closer to the camera appear smaller in the selfie. However, it will also make the faces of other people who are farther away from the camera appear smaller in the selfie, and the faces may not be displayed clearly, which will also lead to an unbalanced proportion between the faces in the selfie. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide an image processing method, device, electronic device and readable storage medium, which can solve the problem of inconsistent proportions of multiple faces in photos taken when multiple people take selfies.
[0005] In a first aspect, an embodiment of the present application provides an image processing method, the method comprising:
[0006] Acquire a first image captured by a first camera;
[0007] When there are multiple faces in the first image, obtaining an area ratio of a face with the largest area to a face with the smallest area among the multiple faces;
[0008] When the area ratio is greater than a first preset threshold, enlarging or reducing at least one of the multiple faces in the first image to obtain a second image;
[0009] The second image is displayed.
[0010] In a second aspect, an embodiment of the present application provides an image processing device, the device comprising:
[0011] A first image acquisition module, used to acquire a first image captured by a first camera;
[0012] an area ratio acquisition module, configured to acquire, when there are multiple faces in the first image, an area ratio of a face with the largest area to a face with the smallest area among the multiple faces;
[0013] An image adjustment module, configured to, when the area ratio is greater than a first preset threshold, enlarge or reduce at least one of the multiple human faces in the first image to obtain a second image;
[0014] A display module, configured to display the second image.
[0015] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor, a memory, and a program or instruction stored on the memory and executable on the processor. When the program or instruction is executed by the processor, the steps of the image processing method described in the first aspect are implemented.
[0016] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the image processing method described in the first aspect are implemented.
[0017] In a fifth aspect, an embodiment of the present application provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor, and the processor is configured to run a program or instruction to implement the image processing method described in the first aspect.
[0018] In the embodiment of the present application, a first image collected by a first camera can be obtained; when there are multiple human faces in the first image, the area ratio of the largest human face to the smallest human face among the multiple human faces is obtained; when the area ratio is greater than a first preset threshold, at least one of the multiple human faces in the first image is enlarged or reduced to obtain a second image; and the second image is displayed.
[0019] Among them, the area ratio of the largest human face to the smallest human face among the multiple human faces can represent whether the proportion of the human faces in the first image is coordinated. Thus, when it is detected that there are multiple human faces in the first image and the proportion of the human faces is not coordinated, by enlarging or reducing at least one of the multiple human faces in the first image, the proportion of the human faces in the captured photo can be made coordinated. Therefore, the embodiment of the present application can solve the problem that the proportion of multiple human faces in the captured photo is not coordinated when taking a group selfie, compared with the prior art. Description of the Drawings
[0020] Figure 1 is a flowchart of the steps of an image processing method provided by an embodiment of the present application;
[0021] Figure 2 is a schematic diagram of reducing the largest human face in the first image provided by an embodiment of the present application;
[0022] Figure 3It is a schematic diagram provided by an embodiment of the present application for magnifying the face with the smallest area in the first image;
[0023] Figure 4 It is a schematic flowchart of a specific implementation manner of an image processing method provided by an embodiment of the present application;
[0024] Figure 5 It is a structural block diagram of an image processing device provided by an embodiment of the present application;
[0025] Figure 6 It is a schematic diagram of an electronic device provided by an embodiment of the present application;
[0026] Figure 7 It is a schematic hardware structure diagram of an electronic device provided by an embodiment of the present application. Specific implementation manner
[0027] Next, the technical solutions in the embodiments of the present application will be clearly described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art belong to the scope protected by the present application.
[0028] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, rather than to describe a specific order or sequence. It should be understood that such used data can be interchanged under appropriate circumstances so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. generally belong to the same category, and the number of objects is not limited. For example, the first object can be one or multiple. In addition, "and / or" in the specification and claims means at least one of the connected objects, and the character " / " generally represents an "or" relationship between the associated objects before and after.
[0029] Next, in conjunction with the accompanying drawings, the image processing method provided by the embodiments of the present application will be described in detail through specific embodiments and their application scenarios.
[0030] An embodiment of the present application provides an image processing method, as Figure 1 shown, the method may include the following steps:
[0031] Step 101: Obtain a first image collected by a first camera.
[0032] Among them, the first camera may be a front camera or a rear camera of a mobile terminal (such as a mobile phone).
[0033] When the first camera is a front camera, the image processing method according to the embodiments of the present application can be applied to the selfie mode, that is, an image with a harmonious face proportion can be obtained in the selfie mode; when the first camera is a rear camera, the image processing method according to the embodiments of the present application can obtain an image with a harmonious face proportion when the positions of multiple people relative to the first camera are inconvenient to move.
[0034] It can be seen from this that the embodiments of the present application can be applied to the shooting mode of the front camera and also to the shooting mode of the rear camera, that is, the first image of the shooting scene where multiple people are located captured by the camera can be obtained. Thus, in the case where there are multiple faces in the first image and the area ratio of the largest face to the smallest face among the multiple faces is greater than the first preset threshold, at least one of the multiple faces in the first image is enlarged or reduced to obtain a second image with a harmonious face proportion.
[0035] Step 102: When there are multiple faces in the first image, obtain the area ratio of the largest face to the smallest face among the multiple faces.
[0036] Among them, the area ratio of the largest face to the smallest face among the multiple faces can indicate whether the face proportion in the first image is harmonious. The area ratio of the largest face to the smallest face among the multiple faces being greater than the first preset threshold indicates that the face proportion in the first image is not harmonious; the area ratio of the largest face to the smallest face among the multiple faces being less than or equal to the first preset threshold indicates that the face proportion in the first image is harmonious.
[0037] In addition, face recognition is a biometric technology for identity recognition based on human facial feature information. An image containing a human face is collected through a camera, and the face is automatically detected and tracked in the image, and then a rectangle is drawn on the original image to frame all the faces. That is, a face detection frame can be displayed on the photo preview interface, and the size of the face detection frame can represent the size of the face.
[0038] Step 103: When the area ratio is greater than the first preset threshold, enlarge or reduce at least one of the multiple faces in the first image to obtain a second image.
[0039] In the embodiments of the present application, the area ratio being greater than the first preset threshold indicates that the proportion of multiple faces in the first image is not harmonious. Therefore, in this case, at least one face in the first image needs to be enlarged or reduced to obtain a second image with a harmonious face proportion.
[0040] Step 104: Display the second image.
[0041] Among them, a second image indicating that the second image is about to obtain a harmonious face ratio is displayed on the screen of the mobile terminal.
[0042] In addition, after the second image is displayed, if a photographing instruction is received, the second image can be generated into a photo, so that a photo with a harmonious face ratio can be obtained.
[0043] It can be seen from the above steps 101 to 104 that in the embodiment of the present application, the first image collected by the first camera can be obtained; when there are multiple faces in the first image, the area ratio of the largest face to the smallest face among the multiple faces is obtained; when the area ratio is greater than a first preset threshold, at least one of the multiple faces in the first image is enlarged or reduced to obtain a second image; the second image is displayed.
[0044] Among them, the area ratio of the largest face to the smallest face among multiple faces can represent whether the face ratio in the first image is harmonious. Therefore, when it is detected that there are multiple faces in the first image and the face ratio is not harmonious, by enlarging or reducing at least one of the multiple faces in the first image, the face ratio in the captured photo can be made harmonious. Therefore, the embodiment of the present application can solve the problem that the face ratios of multiple faces in the captured photo are not harmonious when taking a group selfie, as compared with the prior art.
[0045] Optionally, reducing at least one of the multiple faces in the first image includes:
[0046] Reducing the face of the first target person in the first image, where the first target person is the person to whom the largest face in the first image belongs.
[0047] It can be seen that in the embodiment of the present application, when the area ratio of the largest face to the smallest face in the first image is greater than the first preset threshold, the largest face in the first image can be reduced to make the face ratio in the obtained second image harmonious.
[0048] Similarly, in order to obtain a second image with a harmonious face ratio, in addition to reducing the largest face in the first image, the smallest face in the first image can also be enlarged.
[0049] Among them, when adjusting the size of the human face in the first image, specifically whether to reduce the human face with the largest area or enlarge the human face with the smallest area can be determined according to the actual needs of the user. For example, two prompt options are displayed on the screen of the mobile terminal. For example, the prompt options include a magnification option and a reduction option. The magnification option is used to enlarge the human face with the smallest area in the first image, and the reduction option is used to reduce the human face with the largest area in the first image. Thus, when the magnification option is selected, the human face with the smallest area in the first image is enlarged, and when the reduction option is selected, the human face with the largest area in the first image is reduced.
[0050] In addition, in the case where there are multiple human faces with the largest or smallest area in the first image, all the human faces with the largest area can be reduced, or all the human faces with the smallest area can be enlarged.
[0051] Optionally, reducing the human face of the first target person in the first image includes:
[0052] Obtaining the area of the face detection frame of each human face in the first image;
[0053] Calculating the average value of the areas of the face detection frames;
[0054] Reducing the human face of the first target person in the first image so that the absolute value of the difference between the area of the face detection frame of the first target person and the average value is less than or equal to a second preset threshold.
[0055] It can be seen from this that in the embodiment of the present application, the human face of the first target person (the person to whom the human face with the largest area belongs) can be reduced so that the absolute value of the difference between the area of the face detection frame of the first target person and the average value is less than or equal to the second preset threshold, that is, the human face with the largest area in the first image can be reduced to the average size of the human faces in the first image to achieve the effect of coordinated human face proportions.
[0056] Similarly, the process of enlarging the human face with the smallest area in the first image described above may include:
[0057] Enlarging the human face of the second target person in the first image so that the absolute value of the difference between the area of the face detection frame of the second target person and the average value is less than or equal to the second preset threshold, where the second target person is the person to whom the human face with the smallest area in the first image belongs.
[0058] It can be seen that in the embodiments of the present application, the face of the second target person (the person to whom the face with the smallest area belongs) can be enlarged so that the absolute value of the difference between the area of the face detection box of the second target person and the average value is less than or equal to the second preset threshold, that is, the face with the smallest area in the first image can be enlarged to the average size of the faces in the first image to achieve the effect of coordinated face proportion.
[0059] In addition, in the embodiments of the present application, the area of the face detection box is used as the face area, rather than obtaining the face contour and then calculating the area of the face contour, which can simplify the calculation process of the face area and thus improve the processing speed.
[0060] Optionally, the step of reducing the face of the first target person in the first image so that the absolute value of the difference between the area of the face detection box of the first target person and the average value is less than or equal to the second preset threshold includes:
[0061] Obtaining a third image, where the shooting scene of the third image is the same as that of the first image, and the absolute value of the difference between the area of the face detection box of the first target person in the third image and the average value is less than or equal to the second preset threshold;
[0062] In the case where the face of the first target person in the first image does not occlude the faces of other persons in the first image, replacing the image in the face detection box of the first target person in the first image with the image in the first target area, where the first target area is the area covered by the first target detection box where the face of the first target person in the third image is located, and the first target detection box corresponds to the face detection box of the first target person in the first image.
[0063] In the embodiments of the present application, the first target detection box has the same shape and size as the face detection box of the first target person in the first image.
[0064] It can be seen that in the embodiments of the present application, when reducing the face of the first target person in the first image, if the face of the first target person in the first image does not occlude the faces of other persons, a third image with the area of the face detection box of the first target person in the same shooting scene being close to the average area of the face detection boxes (that is, the absolute value of the difference between the two is less than or equal to the second preset threshold) can be obtained again, and then by means of image replacement, the image in the face detection box of the first target person in the first image is replaced with the image in the corresponding area of the third image, so as to achieve the purpose of reducing the face of the first target person in the first image.
[0065] That is, in the embodiments of the present application, an image replacement method is adopted to achieve the purpose of reducing the face of the first target person in the first image. For example Figure 2 As shown, the image within the first detection frame 204 can be replaced with the image within the second detection frame 205, so as to obtain the second image 203 with a harmonious face ratio.
[0066] It should be noted here that since the area of the face detection frame of the first target person in the third image is smaller than the area of the face detection frame of the first target face in the first image, therefore, for the faces of other people other than the first target person in the shooting scene, the area of the face detection frame in the third image is smaller than the area of the face detection frame in the first image. For example Figure 2 As shown, the area of the face detection frame of the same person in the first image 201 is smaller than the area of the face detection frame in the third image 202.
[0067] Similarly, the above-mentioned method of enlarging the face of the second target person in the first image so that the absolute value of the difference between the area of the face detection frame of the second target person and the average value is less than or equal to the second preset threshold includes:
[0068] Obtain a fourth image, where the shooting scene of the fourth image is the same as the shooting scene of the first image, and the absolute value of the difference between the area of the face detection frame of the second target person in the fourth image and the average value is less than or equal to the second preset threshold;
[0069] When there is no occlusion between the face of the second target person in the first image and the faces of other people other than the second target person in the first image, replace the image within the second target area in the first image with the image within the face detection frame of the second target person in the fourth image, where the second target area is the area covered by the second target detection frame where the face of the second target person in the first image is located, and the second target detection frame corresponds to the face detection frame of the second target person in the fourth image.
[0070] In the embodiments of the present application, the second target detection frame has the same shape and size as the face detection frame of the second target person in the fourth image.
[0071] It can be seen that in the embodiments of the present application, when magnifying the face of the second target person in the first image, if there is no occlusion between the face of the second target person and the faces of other persons in the first image, a fourth image can be re-acquired in the same shooting scene, where the area of the face detection frame of the second target person is close to the average area of the face detection frame (i.e., the absolute value of the difference between the two is less than or equal to the second preset threshold). Thus, by means of image replacement, the image within the second target area in the first image is replaced with the image within the face detection frame of the second target person in the fourth image, so as to achieve the purpose of magnifying the face of the second target person in the first image.
[0072] That is, in the embodiments of the present application, the image replacement method is adopted to achieve the purpose of magnifying the face of the second target person in the first image. For example Figure 3 as shown, the image within the third detection frame 304 can be replaced with the image within the fourth detection frame 305, so as to obtain the second image 303 with a harmonious face proportion.
[0073] It should be noted here that since the area of the face detection frame of the second target person in the fourth image is larger than the area of the face detection frame of the second target face in the first image, therefore, for the faces of other persons other than the second target person within the shooting scene, the area of the face detection frame in the fourth image is larger than the area of the face detection frame in the first image. For example Figure 3 as shown, the area of the face detection frame of the same person in the first image 301 is smaller than the area of the face detection frame in the fourth image 302.
[0074] In addition, in the prior art, manual matte extraction can be performed later to adjust the size of the face in the image. However, such an operation is too time-consuming. In the embodiments of the present application, when there are multiple faces in the shooting scene, the proportions of the multiple faces are not harmonious, and the face to be magnified or reduced is not occluded by other faces, the image replacement method can be automatically adopted to adjust the size of the face in the image, thereby simplifying the operation of image processing and saving the image processing time.
[0075] Among them, when the face to be magnified or reduced in the first image is not occluded by other faces, the above-mentioned image replacement method can be adopted. When the face to be magnified or reduced in the first image is occluded by other faces, a preset identifier can be displayed on the face detection frame of the face to be magnified or reduced in the first image, so as to indicate that there is occlusion between the faces and the person being photographed needs to adjust the position to cancel the occlusion.
[0076] In addition, in the embodiments of the present application, an image replacement method is adopted to reduce the face of the first target person in the first image. Therefore, the shooting scene of the above-mentioned third image should be the same as that of the first image. In order to make the image content of the third image more consistent with that of the first image, the second camera and the first camera can be controlled to capture images of the same shooting scene simultaneously.
[0077] Similarly, in the embodiments of the present application, an image replacement method is adopted to enlarge the face of the second target person in the first image. Therefore, the shooting scene of the above-mentioned fourth image should be the same as that of the first image. In order to make the image content of the fourth image more consistent with that of the first image, the second camera and the first camera can be controlled to capture images of the same shooting scene simultaneously.
[0078] Optionally, the obtaining of the third image includes:
[0079] Controlling the second camera to start, so that the second camera adjusts the shooting parameters according to the average value and captures the third image according to the shooting parameters.
[0080] Wherein, the second camera can be an ultra-wide-angle camera. The ultra-wide-angle camera can produce a strong contrast effect of far and near for scenes with little difference in distance, and can represent a narrow space as a relatively broad scene.
[0081] As can be seen from the above, in the embodiments of the present application, the third image in which the absolute value of the difference between the area of the face detection frame of the first target person captured by the second camera and the above-mentioned average value is less than or equal to the second preset threshold can be captured.
[0082] Similarly, optionally, the obtaining of the fourth image includes:
[0083] Controlling the second camera to start, so that the second camera adjusts the shooting parameters according to the average value and captures the fourth image according to the shooting parameters.
[0084] That is, the fourth image in which the absolute value of the difference between the area of the face detection frame of the second target person captured by the second camera and the above-mentioned average value is less than or equal to the second preset threshold can be captured.
[0085] Optionally, the obtaining of the area ratio of the largest face to the smallest face among the multiple faces includes:
[0086] Obtaining the area of the face detection frame of each person in the first image;
[0087] Calculating the area ratio of the largest face detection frame to the smallest face detection frame as the area ratio of the largest face to the smallest face among the multiple faces.
[0088] In the embodiment of the present application, the area of the face detection frame is used as the face area. Therefore, the area ratio of the face with the largest area to the face with the smallest area is the area ratio of the face detection frame with the largest area to the face detection frame with the smallest area.
[0089] Optionally, before enlarging or reducing at least one of the multiple faces in the first image, the method further includes:
[0090] When the area ratio is greater than a first preset threshold, displaying preset prompt information, wherein the preset prompt information is used to prompt the user whether to adjust the face size;
[0091] The step of enlarging or reducing at least one of the plurality of faces in the first image comprises:
[0092] When a preset operation is received within a preset time of displaying the preset prompt information, at least one of the multiple faces in the first image is enlarged or reduced.
[0093] Among them, when the area ratio of the face with the largest area to the face with the smallest area among the multiple faces in the first image is greater than a first preset threshold, a preset prompt message can be displayed to prompt the user that the current face proportions are not coordinated, so that when a preset operation of the user (such as a click operation on the adjustment control displayed in the photo preview interface or a preset sliding operation on the touch screen) is received within a preset time (for example, 10 seconds) of displaying the preset prompt message, at least one face in the first image can be enlarged or reduced; and if the preset operation of the user is not received within the preset time of displaying the prompt message, the step of "enlarging or reducing the face with the smallest area or the face with the largest area in the first image" is not executed.
[0094] That is, in the embodiment of the present application, it is possible to select whether to enlarge or reduce at least one face in the first image (that is, to select whether to adjust the face to make its proportions coordinated) according to the actual requirements of the user.
[0095] In summary, if Figure 4 As shown, a specific implementation of an image processing method in an embodiment of the present application can be described as follows:
[0096] Step H1: capturing a first image of a shooting scene through a main camera of a mobile terminal, wherein the first image may also be displayed on a photo preview interface;
[0097] Step H2: Detect the number of faces in the first image. If there are multiple faces, obtain the area of each face detection frame, and calculate the area ratio of the face detection frame with the largest area to the face detection frame with the smallest area in the image.
[0098] Step H3: When the area ratio obtained in Step H2 is less than the first preset threshold (for example, the first preset threshold is 2), display the first image. Thereafter, if a photographing instruction is received, generate a photo from the first image;;
[0099] Step H4: When the area ratio obtained in Step H2 is greater than or equal to the first preset threshold (for example, the first preset threshold is 2), calculate the average value of the areas of the face detection frames in the first image;
[0100] Step H5: Adjust the shooting parameters of the ultra-wide-angle camera, that is, make the absolute value of the difference between the area of the face of the first target person in the image of the shooting scene captured by the ultra-wide-angle camera and the average value obtained in Step H3 less than or equal to the second preset threshold, where the first target person is the person to whom the face with the largest face detection frame area in the first image belongs;
[0101] Step H6: Simultaneously capture the image of the shooting scene through the main camera and the ultra-wide-angle camera with adjusted shooting parameters, so as to perform image replacement, that is, when there is no occlusion between the face of the first target person and the faces of other persons in the image captured by the main camera at this time, replace the image within the face detection frame of the first target person in the image captured by the main camera at this time with the image within the first target detection frame where the face of the first target person is located in the image captured by the ultra-wide-angle camera, to obtain a second image, and the first target detection frame corresponds to the face detection frame of the first target person captured by the main camera at this time.
[0102] Step H7: Display the second image on the photographing preview interface.
[0103] Among them, after Step H7, Step H8 may further be included;
[0104] Step H8: After obtaining a photographing instruction, generate a photo from the second image.
[0105] As can be seen from the above, in the embodiments of the present application, multiple cameras arranged in front can be used to automatically adjust the faces during group selfies, so that the size ratios of multiple faces are coordinated, thereby reducing the post-processing process and improving the user's photographing experience.
[0106] It should be noted that for the method provided in the embodiments of the present application, the execution subject may be a device, or a control module in the recognition device for executing the method. In the embodiments of the present application, the device executing the method is taken as an example to illustrate the device provided in the embodiments of the present application.
[0107] The above introduces the image processing method provided in the embodiments of the present application. Next, the image processing device provided in the embodiments of the present application will be introduced with reference to the accompanying drawings.
[0108] See Figure 5 , the embodiment of the present application further provides an image processing apparatus 500, including the following modules:
[0109] The first image acquisition module 501 is configured to acquire a first image captured by a first camera;
[0110] The area ratio acquisition module 502 is configured to acquire the area ratio of the face with the largest area to the face with the smallest area among multiple faces in the first image when there are multiple faces in the first image;
[0111] The image adjustment module 503 is configured to, when the area ratio is greater than a first preset threshold, enlarge or reduce at least one face among the multiple faces in the first image to obtain a second image;
[0112] The display module 504 is configured to display the second image.
[0113] Optionally, the image adjustment module 503 includes:
[0114] The reduction sub-module is configured to reduce the face of a first target person in the first image, where the first target person is the person to whom the face with the largest area in the first image belongs.
[0115] Optionally, the reduction sub-module includes:
[0116] The acquisition unit is configured to acquire the area of the face detection frame of each face in the first image;
[0117] The average value calculation unit is configured to calculate the average value of the areas of the face detection frames;
[0118] The reduction unit is configured to reduce the face of the first target person in the first image so that the absolute value of the difference between the area of the face detection frame of the first target person and the average value is less than or equal to a second preset threshold.
[0119] Optionally, the reduction unit is specifically configured to:
[0120] Acquire a third image, where the shooting scene of the third image is the same as that of the first image, and the absolute value of the difference between the area of the face detection frame of the first target person in the third image and the average value is less than or equal to the second preset threshold;
[0121] When there is no occlusion between the face of the first target person in the first image and the faces of other persons in the first image except the first target person, replace the image in the face detection frame of the first target person in the first image with the image in the first target area, where the first target area is the area covered by the first target detection frame where the face of the first target person is located in the third image, and the first target detection frame corresponds to the face detection frame of the first target person in the first image.
[0122] Optionally, when obtaining the third image, the shrinking unit is specifically configured to:
[0123] Control the second camera to start, so that the second camera adjusts the shooting parameters according to the average value and captures the third image according to the shooting parameters.
[0124] Optionally, the area ratio obtaining module 502 includes:
[0125] An obtaining sub-module, configured to obtain the area of the face detection frame of each person in the first image;
[0126] An area ratio calculation sub-module, configured to calculate the area ratio of the face detection frame with the largest area to the face detection frame with the smallest area as the area ratio of the face with the largest area to the face with the smallest area among the multiple faces.
[0127] Optionally, the image processing device 500 further includes:
[0128] An information display module, configured to display a preset prompt message when the area ratio is greater than a first preset threshold, where the preset prompt message is used to prompt the user whether to adjust the face size;
[0129] The image adjustment module 503 includes:
[0130] An image adjustment sub-module, configured to enlarge or reduce at least one of the multiple faces in the first image when a preset operation is received within a preset time for displaying the preset prompt message.
[0131] It can be seen that in the embodiments of the present application, the first image collected by the first camera can be obtained; when there are multiple faces in the first image, the area ratio of the face with the largest area to the face with the smallest area among the multiple faces can be obtained; when the area ratio is greater than the first preset threshold, at least one of the multiple faces in the first image is enlarged or reduced to obtain a second image; and the second image is displayed.
[0132] Among them, the ratio of the area of the largest face to the area of the smallest face among multiple faces can indicate whether the proportion of faces in the first image is coordinated. Therefore, when multiple faces are detected in the first image and the proportion of the faces is uncoordinated, at least one of the multiple faces in the first image is enlarged or reduced so that the proportion of the faces in the captured photo is coordinated. Therefore, the embodiments of the present application can solve the problem that the proportion of multiple faces in the photo obtained by taking a group selfie is uncoordinated, as compared with the prior art.
[0133] The device in the embodiments of the present application can be a device, or a component, an integrated circuit, or a chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a handheld computer, a vehicle-mounted electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc., and the non-mobile electronic device can be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine, or a self-service machine, etc. The embodiments of the present application do not make specific limitations.
[0134] The device in the embodiments of the present application can be a device with an operating system. The operating system can be an Android operating system, an iOS operating system, or other possible operating systems. The embodiments of the present application do not make specific limitations.
[0135] The device provided in the embodiments of the present application can implement Figure 1 each process implemented by the method embodiments. To avoid repetition, details are not described herein again.
[0136] Optionally, as Figure 6 shown, the embodiments of the present application further provide an electronic device, including a processor, a memory 602, and a program or instruction stored on the memory 602 and executable on the processor 601. When the program or instruction is executed by the processor 601, it implements each process of the above method embodiments and can achieve the same technical effect. To avoid repetition, details are not described herein again.
[0137] It should be noted that the electronic device in the embodiments of the present application includes the above-mentioned mobile electronic devices and non-mobile electronic devices.
[0138] Figure 7Schematic diagram of the hardware structure of an electronic device according to an embodiment of the present application.
[0139] The electronic device 700 includes, but is not limited to: a radio frequency unit 701, a network module 702, an audio output unit 703, an input unit 704, a sensor 705, a display unit 706, a user input unit 707, an interface unit 708, a memory 709, and a processor 710 and other components.
[0140] Those skilled in the art can understand that the electronic device 700 may further include a power supply (such as a battery) for supplying power to each component. The power supply can be logically connected to the processor 710 through a power management system, so as to realize functions such as management of charging, discharging, and power consumption management through the power management system. Figure 7 The electronic device structure shown does not limit the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or have different component arrangements, which will not be elaborated here.
[0141] Among them, the electronic device 700 further includes a first camera.
[0142] The processor 710 is configured to perform the following steps:
[0143] Obtain a first image collected by the first camera;
[0144] When there are multiple human faces in the first image, obtain the area ratio of the largest human face to the smallest human face among the multiple human faces;
[0145] When the area ratio is greater than a first preset threshold, zoom in or out at least one of the multiple human faces in the first image to obtain a second image.
[0146] The display unit 706 is configured to perform the following steps:
[0147] Display the second image.
[0148] Optionally, when the processor 710 zooms out at least one of the multiple human faces in the first image, it is specifically configured to:
[0149] Zoom out the human face of the first target person in the first image, where the first target person is the person to whom the largest human face in the first image belongs.
[0150] Optionally, when the processor 710 zooms out the human face of the first target person in the first image, it is specifically configured to:
[0151] Obtain the area of the face detection frame of each human face in the first image;
[0152] Calculate the average value of the areas of the face detection frames;
[0153] Shrink the face of the first target person in the first image so that the absolute value of the difference between the area of the face detection frame of the first target person and the average value is less than or equal to a second preset threshold.
[0154] Optionally, when shrinking the face of the first target person in the first image so that the absolute value of the difference between the area of the face detection frame of the first target person and the average value is less than or equal to a second preset threshold, the processor 710 is specifically configured to:
[0155] Obtain a third image, where the shooting scene of the third image is the same as that of the first image, and the absolute value of the difference between the area of the face detection frame of the first target person in the third image and the average value is less than or equal to the second preset threshold;
[0156] In the case where the face of the first target person in the first image does not occlude the faces of other persons in the first image except the first target person, replace the image in the face detection frame of the first target person in the first image with the image in the first target area, where the first target area is the area covered by the first target detection frame where the face of the first target person is located in the third image, and the first target detection frame corresponds to the face detection frame of the first target person in the first image.
[0157] Optionally, the electronic device further includes a second camera; when obtaining the third image, the processor 710 is specifically configured to:
[0158] Control the second camera to start so that the second camera adjusts the shooting parameters according to the average value and captures the third image according to the shooting parameters.
[0159] Optionally, when obtaining the ratio of the area of the largest face to the area of the smallest face among the multiple faces, the processor 710 is specifically configured to:
[0160] Obtain the area of the face detection frame of each person in the first image;
[0161] Calculate the ratio of the area of the largest face detection frame to the area of the smallest face detection frame as the ratio of the area of the largest face to the area of the smallest face among the multiple faces.
[0162] Optionally, before enlarging or shrinking at least one face among the multiple faces in the first image, the processor 710 is specifically configured to:
[0163] When the area ratio is greater than a first preset threshold, displaying preset prompt information, wherein the preset prompt information is used to prompt the user whether to adjust the face size;
[0164] The step of enlarging or reducing at least one of the plurality of faces in the first image comprises:
[0165] When a preset operation is received within a preset time of displaying the preset prompt information, at least one of the multiple faces in the first image is enlarged or reduced.
[0166] In the embodiment of the present application, when it is detected that there are multiple faces in the first image and the proportions of the faces are not coordinated, at least one of the multiple faces in the first image is enlarged or reduced so that the proportions of the faces in the taken photo are coordinated. Therefore, compared with the prior art, the embodiment of the present application can solve the problem of the inconsistent proportions of multiple faces in the photos taken when multiple people take selfies.
[0167] It should be understood that in the embodiment of the present application, the input unit 704 may include a graphics processor (Graphics Processing Unit, GPU) 7041 and a microphone 7042, and the graphics processor 7041 processes the image data of the static picture or video obtained by the image capture device (such as a camera) in the video capture mode or the image capture mode. The display unit 706 may include a display panel 7061, and the display panel 5061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 707 includes a touch panel 7071 and other input devices 7072. The touch panel 7071 is also called a touch screen. The touch panel 7071 may include two parts: a touch detection device and a touch controller. Other input devices 7072 may include but are not limited to a physical keyboard, a function key (such as a volume control button, a switch button, etc.), a trackball, a mouse, and a joystick, which will not be repeated here. The memory 709 can be used to store software programs and various data, including but not limited to applications and operating systems. The processor 710 can integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, the user interface, and the application program, etc., and the modem processor mainly processes wireless communication. It is understandable that the above-mentioned modem processor may not be integrated into the processor 710.
[0168] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned image processing method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0169] Among them, the processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disc, etc.
[0170] Another embodiment of the present application provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement each process of the above embodiment of the image processing method and can achieve the same technical effects. To avoid repetition, it will not be elaborated here.
[0171] It should be understood that the chip mentioned in the embodiments of the present application can also be referred to as a system-on-chip, system chip, chip system, or system-on-chip, etc.
[0172] It should be noted that in this article, the term "including", "comprising" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, the element defined by the statement "including one..." does not exclude the existence of additional identical elements in the process, method, article or device including that element. In addition, it should be pointed out that the methods and devices in the embodiments of the present application are not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in a reverse order according to the functions involved. For example, the methods described can be performed in an order different from that described, and various steps can also be added, omitted, or combined. In addition, the features described with reference to certain examples can be combined in other examples.
[0173] Through the description of the above embodiments, those skilled in the art can clearly understand that the above embodiment methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. The computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disc) and includes several instructions for causing a terminal (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present application.
[0174] The embodiments of the present application have been described above in conjunction with the accompanying drawings. However, the present application is not limited to the above specific embodiments. The above specific embodiments are merely illustrative and not restrictive. Under the inspiration of the present application, those of ordinary skill in the art can also make many forms without departing from the purpose of the present application and the scope protected by the claims, and all of them fall within the protection scope of the present application.
Claims
1. An image processing method, characterized in that, The method includes: Obtaining a first image collected by a first camera; When there are multiple human faces in the first image, obtaining the area ratio of the largest human face to the smallest human face among the multiple human faces; When the area ratio is greater than a first preset threshold, reducing at least one of the multiple human faces in the first image to obtain a second image; Displaying the second image; Wherein, reducing at least one of the multiple human faces in the first image includes: Obtaining a third image collected by a second camera, the shooting scene of the third image being the same as that of the first image, and the absolute value of the difference between the area of the face detection frame of a first target person in the third image and the average value of the areas of the face detection frames of each human face in the first image being less than or equal to a second preset threshold; When there is no occlusion between the face of the first target person in the first image and the faces of other persons except the first target person in the first image, replacing the image in the face detection frame of the first target person in the first image with the image in a first target area; wherein, the first target area is the area covered by a first target detection frame where the face of the first target person is located in the third image, the first target detection frame corresponding to the face detection frame of the first target person in the first image, and the first target detection frame having the same shape and size as the face detection frame of the first target person in the first image.
2. The method according to claim 1, wherein: The first target person is the person to whom the largest human face in the first image belongs.
3. The method according to claim 2, wherein Reducing the face of the first target person in the first image includes: Obtaining the area of the face detection frame of each human face in the first image; Calculating the average value of the areas of the face detection frames.
4. The method according to claim 3, wherein The obtaining the third image collected by the second camera includes: Controlling the second camera to start, so that the second camera adjusts the shooting parameters according to the average value and captures the third image according to the shooting parameters.
5. The method according to claim 1, wherein The obtaining the area ratio of the largest human face to the smallest human face among the multiple human faces includes: Obtaining the area of the face detection frame of each person in the first image; Calculating the area ratio of the largest face detection frame to the smallest face detection frame as the area ratio of the largest human face to the smallest human face among the multiple human faces.
6. The method according to claim 1, characterized in that Before reducing at least one of the multiple human faces in the first image, the method further includes: When the area ratio is greater than a first preset threshold, displaying a preset prompt message, where the preset prompt message is used to prompt the user whether to adjust the face size; Reducing at least one of the multiple human faces in the first image includes: When a preset operation is received within a preset time for displaying the preset prompt message, reducing at least one of the multiple human faces in the first image.
7. An image processing apparatus, characterized in that, The device includes: A first image acquisition module, configured to acquire a first image captured by a first camera; An area ratio acquisition module, configured to, when there are multiple human faces in the first image, acquire an area ratio between the human face with the largest area and the human face with the smallest area among the multiple human faces; An image adjustment module, configured to, when the area ratio is greater than a first preset threshold, reduce at least one of the multiple human faces in the first image to obtain a second image; wherein, reducing at least one of the multiple human faces in the first image includes: acquiring a third image captured by a second camera, the shooting scene of the third image being the same as the shooting scene of the first image, and the absolute value of the difference between the area of the face detection frame of a first target person in the third image and the average value of the areas of the face detection frames of each human face in the first image being less than or equal to a second preset threshold; when there is no occlusion between the face of the first target person in the first image and the faces of other persons except the first target person in the first image, replacing the image in the face detection frame of the first target person in the first image with the image in a first target area; wherein, the first target area is the area covered by a first target detection frame where the face of the first target person is located in the third image, the first target detection frame corresponding to the face detection frame of the first target person in the first image, and the first target detection frame having the same shape and size as the face detection frame of the first target person in the first image; A display module, configured to display the second image.
8. An electronic device, characterized in that, It includes a processor, a memory, and a program or instruction stored on the memory and executable on the processor. When the program or instruction is executed by the processor, the steps of the image processing method according to any one of claims 1-6 are implemented.
9. A readable storage medium, characterized in that, A program or instruction is stored on the readable storage medium. When the program or instruction is executed by the processor, the steps of the image processing method according to any one of claims 1-6 are implemented.
Citation Information
Patent Citations
Shooting method and mobile terminal
CN107181913A
Camera starting method and device
CN111669505A
Image processing method, device, equipment and storage medium
CN113570510A